3 from arvados.fuse import *
7 if __name__ == '__main__':
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 parser.add_argument('--exec', type=str, help="""Mount, run a command, then unmount and exit""", dest="ex")
18 args = parser.parse_args()
20 # Create the request handler
21 operations = Operations(os.getuid(), os.getgid())
23 if args.collection != None:
24 # Set up the request handler with the collection at the root
25 e = operations.inodes.add_entry(Directory(llfuse.ROOT_INODE))
26 operations.inodes.load_collection(e, arvados.CollectionReader(arvados.Keep.get(args.collection)))
28 # Set up the request handler with the 'magic directory' at the root
29 operations.inodes.add_entry(MagicDirectory(llfuse.ROOT_INODE, operations.inodes))
31 # FUSE options, see mount.fuse(8)
34 # Enable FUSE debugging (logs each FUSE request)
38 # Initialize the fuse connection
39 llfuse.init(operations, args.mountpoint, opts)
42 t = threading.Thread(None, lambda: llfuse.main())
45 # wait until the driver is finished initializing
46 operations.initlock.wait()
49 rc = subprocess.call(args.ex, shell=True)
53 subprocess.call(["fusermount", "-u", args.mountpoint])