]> git.arvados.org - arvados.git/blob - sdk/python/bin/arv-mount
Added basic unit test for fuse mount.
[arvados.git] / sdk / python / bin / arv-mount
1 #!/usr/bin/env python
2
3 from arvados.fuse import * 
4
5 if __name__ == '__main__':
6     # Handle command line parameters
7     parser = argparse.ArgumentParser(
8         description='Mount Keep data under the local filesystem.')
9     parser.add_argument('mountpoint', type=str, help="""Mount point.""")
10     parser.add_argument('--collection', type=str, help="""Collection locator""")
11     parser.add_argument('--debug', action='store_true', help="""Debug mode""")
12
13     args = parser.parse_args()
14
15     # Create the request handler
16     operations = Operations(os.getuid(), os.getgid())
17
18     if args.collection != None:
19         # Set up the request handler with the collection at the root
20         e = operations.inodes.add_entry(Directory(llfuse.ROOT_INODE))
21         operations.inodes.load_collection(e, arvados.CollectionReader(arvados.Keep.get(args.collection)))
22     else:
23         # Set up the request handler with the 'magic directory' at the root
24         operations.inodes.add_entry(MagicDirectory(llfuse.ROOT_INODE, operations.inodes))
25
26     # FUSE options, see mount.fuse(8)
27     opts = []
28
29     # Enable FUSE debugging (logs each FUSE request)
30     if args.debug:
31         opts += ['debug']
32     
33     # Initialize the fuse connection
34     llfuse.init(operations, args.mountpoint, opts)
35
36     # Run the main loop
37     #try:
38     llfuse.main()
39     #except:
40     #    llfuse.close(unmount=True)
41     #    raise
42     #
43     #llfuse.close(unmount=True)