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.',
14 Note: When using the --exec feature, you must either specify the
15 mountpoint before --exec, or mark the end of your --exec arguments
18 parser.add_argument('mountpoint', type=str, help="""Mount point.""")
19 parser.add_argument('--collection', type=str, help="""Collection locator""")
20 parser.add_argument('--debug', action='store_true', help="""Debug mode""")
21 parser.add_argument('--exec', type=str, nargs=argparse.REMAINDER,
22 dest="exec_args", metavar=('command', 'args', '...', '--'),
23 help="""Mount, run a command, then unmount and exit""")
25 args = parser.parse_args()
27 # Create the request handler
28 operations = Operations(os.getuid(), os.getgid())
30 if args.collection != None:
31 # Set up the request handler with the collection at the root
32 e = operations.inodes.add_entry(Directory(llfuse.ROOT_INODE))
33 operations.inodes.load_collection(e, arvados.CollectionReader(arvados.Keep.get(args.collection)))
35 # Set up the request handler with the 'magic directory' at the root
36 operations.inodes.add_entry(MagicDirectory(llfuse.ROOT_INODE, operations.inodes))
38 # FUSE options, see mount.fuse(8)
41 # Enable FUSE debugging (logs each FUSE request)
45 # Initialize the fuse connection
46 llfuse.init(operations, args.mountpoint, opts)
49 t = threading.Thread(None, lambda: llfuse.main())
52 # wait until the driver is finished initializing
53 operations.initlock.wait()
56 rc = subprocess.call(args.exec_args, shell=False)
60 subprocess.call(["fusermount", "-u", "-z", args.mountpoint])