--exec works
authorPeter Amstutz <peter.amstutz@curoverse.com>
Thu, 20 Feb 2014 15:27:33 +0000 (15:27 +0000)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Thu, 20 Feb 2014 15:27:33 +0000 (15:27 +0000)
sdk/python/bin/arv-mount

index 613db12f8c7038b9a920f1946f92a339910bc046..0cab824613de7f2a6d8dbada24c8c640fa570b92 100755 (executable)
@@ -13,7 +13,7 @@ if __name__ == '__main__':
     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, help="""Mount, run a command, then unmount and exit""", dest="ex")
 
     args = parser.parse_args()
 
@@ -38,17 +38,20 @@ if __name__ == '__main__':
     # Initialize the fuse connection
     llfuse.init(operations, args.mountpoint, opts)
 
-    if args.exec:
+    if args.ex:
         t = threading.Thread(None, lambda: llfuse.main())
         t.start()
 
         # wait until the driver is finished initializing
         operations.initlock.wait()
 
-        rc = subprocess.call(args.exec)
+        try:
+            rc = subprocess.call(args.ex, shell=True)
+        except:
+            rc = 255
+        finally:
+            subprocess.call(["fusermount", "-u", args.mountpoint])
 
-        subprocess.call(["fusermount", "-u", args.mountpoint])
-
-        return rc
+        exit(rc)
     else:
         llfuse.main()