X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/975c10c5b8ccc7d12ee4df993e06a359c4bbec93..cf7e30873ef4b92cc8ec099b2bb344391a070e93:/sdk/python/bin/arv-mount?ds=sidebyside diff --git a/sdk/python/bin/arv-mount b/sdk/python/bin/arv-mount index 613db12f8c..5e773dfbc6 100755 --- a/sdk/python/bin/arv-mount +++ b/sdk/python/bin/arv-mount @@ -3,17 +3,23 @@ from arvados.fuse import * import arvados import subprocess +import argparse if __name__ == '__main__': - api = arvados.api() - # Handle command line parameters parser = argparse.ArgumentParser( - description='Mount Keep data under the local filesystem.') + description='Mount Keep data under the local filesystem.', + epilog=""" +Note: When using the --exec feature, you must either specify the +mountpoint before --exec, or mark the end of your --exec arguments +with "--". +""") parser.add_argument('mountpoint', type=str, help="""Mount point.""") parser.add_argument('--collection', type=str, help="""Collection locator""") parser.add_argument('--debug', action='store_true', help="""Debug mode""") - parser.add_argument('--exec', type=str, help="""Mount, run a command, then unmount and exit""") + parser.add_argument('--exec', type=str, nargs=argparse.REMAINDER, + dest="exec_args", metavar=('command', 'args', '...', '--'), + help="""Mount, run a command, then unmount and exit""") args = parser.parse_args() @@ -38,17 +44,24 @@ if __name__ == '__main__': # Initialize the fuse connection llfuse.init(operations, args.mountpoint, opts) - if args.exec: + if args.exec_args: t = threading.Thread(None, lambda: llfuse.main()) t.start() # wait until the driver is finished initializing operations.initlock.wait() - rc = subprocess.call(args.exec) - - subprocess.call(["fusermount", "-u", args.mountpoint]) + rc = 255 + try: + rc = subprocess.call(args.exec_args, shell=False) + except OSError as e: + sys.stderr.write('arv-mount: %s -- exec %s\n' % (str(e), args.exec_args)) + rc = e.errno + except Exception as e: + sys.stderr.write('arv-mount: %s\n' % str(e)) + finally: + subprocess.call(["fusermount", "-u", "-z", args.mountpoint]) - return rc + exit(rc) else: llfuse.main()