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