3 from arvados.fuse import *
8 if __name__ == '__main__':
9 # Handle command line parameters
10 parser = argparse.ArgumentParser(
11 description='Mount Keep data under the local filesystem.',
13 Note: When using the --exec feature, you must either specify the
14 mountpoint before --exec, or mark the end of your --exec arguments
17 parser.add_argument('mountpoint', type=str, help="""Mount point.""")
18 parser.add_argument('--collection', type=str, help="""Collection locator""")
19 parser.add_argument('--debug', action='store_true', help="""Debug mode""")
20 parser.add_argument('--exec', type=str, nargs=argparse.REMAINDER,
21 dest="exec_args", metavar=('command', 'args', '...', '--'),
22 help="""Mount, run a command, then unmount and exit""")
24 args = parser.parse_args()
26 # Create the request handler
27 operations = Operations(os.getuid(), os.getgid())
29 if args.collection != None:
30 # Set up the request handler with the collection at the root
31 e = operations.inodes.add_entry(Directory(llfuse.ROOT_INODE))
32 operations.inodes.load_collection(e, arvados.CollectionReader(arvados.Keep.get(args.collection)))
34 # Set up the request handler with the 'magic directory' at the root
35 operations.inodes.add_entry(MagicDirectory(llfuse.ROOT_INODE, operations.inodes))
37 # FUSE options, see mount.fuse(8)
40 # Enable FUSE debugging (logs each FUSE request)
44 # Initialize the fuse connection
45 llfuse.init(operations, args.mountpoint, opts)
48 t = threading.Thread(None, lambda: llfuse.main())
51 # wait until the driver is finished initializing
52 operations.initlock.wait()
56 rc = subprocess.call(args.exec_args, shell=False)
58 sys.stderr.write('arv-mount: %s -- exec %s\n' % (str(e), args.exec_args))
60 except Exception as e:
61 sys.stderr.write('arv-mount: %s\n' % str(e))
63 subprocess.call(["fusermount", "-u", "-z", args.mountpoint])