]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/cmd/fuse.py
fuse: detect fusepy module
[bup.git] / lib / bup / cmd / fuse.py
old mode 100755 (executable)
new mode 100644 (file)
index b1be8ac..78073ee
@@ -9,7 +9,13 @@ except ImportError:
           file=sys.stderr)
     sys.exit(2)
 if not hasattr(fuse, '__version__'):
-    print('error: fuse module is too old for fuse.__version__', file=sys.stderr)
+    if hasattr(fuse, 'FUSE'):
+        print('error: python fuse module appears to be fusepy, not python-fuse\n'
+              '       please install https://github.com/libfuse/python-fuse',
+              file=sys.stderr)
+    else:
+        print('error: fuse module may need to be upgraded (no fuse.__version__)',
+              file=sys.stderr)
     sys.exit(2)
 fuse.fuse_python_api = (0, 2)
 
@@ -106,6 +112,7 @@ class BupFs(fuse.Fuse):
         # Return None since read doesn't need the file atm...
         # If we *do* return the file, it'll show up as the last argument
         #return vfs.fopen(repo, item)
+        return None
 
     def read(self, path, size, offset):
         path = argv_bytes(path)
@@ -146,17 +153,17 @@ def main(argv):
         o.fatal('only one mount point argument expected')
 
     git.check_repo_or_die()
-    repo = LocalRepo()
-    f = BupFs(repo=repo, verbose=opt.verbose, fake_metadata=(not opt.meta))
-
-    # This is likely wrong, but the fuse module doesn't currently accept bytes
-    f.fuse_args.mountpoint = extra[0]
-
-    if opt.debug:
-        f.fuse_args.add('debug')
-    if opt.foreground:
-        f.fuse_args.setmod('foreground')
-    f.multithreaded = False
-    if opt.allow_other:
-        f.fuse_args.add('allow_other')
-    f.main()
+    with LocalRepo() as repo:
+        f = BupFs(repo=repo, verbose=opt.verbose, fake_metadata=(not opt.meta))
+
+        # This is likely wrong, but the fuse module doesn't currently accept bytes
+        f.fuse_args.mountpoint = extra[0]
+
+        if opt.debug:
+            f.fuse_args.add('debug')
+        if opt.foreground:
+            f.fuse_args.setmod('foreground')
+        f.multithreaded = False
+        if opt.allow_other:
+            f.fuse_args.add('allow_other')
+        f.main()