]> git.michaelhowe.org Git - packages/b/bup.git/commitdiff
cmd/ftp: if completion fails due to FileNotFound, just eat it.
authorGabriel Filion <lelutin@gmail.com>
Tue, 27 Jul 2010 07:24:23 +0000 (03:24 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Tue, 27 Jul 2010 07:27:42 +0000 (03:27 -0400)
Just as bash would do, if you're trying to complete a filename that doesn't
exist, just don't offer any completions.  In this case, it only happens if
you try to complete through a broken symlink.

Now that we've fixed this case, enable the printing of exception tracebacks
in case of *other* kinds of completion errors, since we don't expect there
to be any.

[Committed by apenwarr based on an unofficial patch from Gabriel]

cmd/ftp-cmd.py

index 0635f0769804b522a6210be744204f9defc41d1e..6c9a9992ab7ea8e224b555298cf3136330b364cc 100755 (executable)
@@ -43,9 +43,12 @@ def _completer_get_subs(line):
     (qtype, lastword) = shquote.unfinished_word(line)
     (dir,name) = os.path.split(lastword)
     #log('\ncompleter: %r %r %r\n' % (qtype, lastword, text))
-    n = pwd.resolve(dir)
-    subs = list(filter(lambda x: x.name.startswith(name),
-                       n.subs()))
+    try:
+        n = pwd.resolve(dir)
+        subs = list(filter(lambda x: x.name.startswith(name),
+                           n.subs()))
+    except vfs.NoSuchFile, e:
+        subs = []
     return (dir, name, qtype, lastword, subs)
 
 
@@ -105,13 +108,12 @@ def completer(text, state):
                                           terminate=True) + ' '
             return text + ret
     except Exception, e:
-        if 0:
-            log('\n')
-            try:
-                import traceback
-                traceback.print_tb(sys.exc_traceback)
-            except Exception, e2:
-                log('Error printing traceback: %s\n' % e2)
+        log('\n')
+        try:
+            import traceback
+            traceback.print_tb(sys.exc_traceback)
+        except Exception, e2:
+            log('Error printing traceback: %s\n' % e2)
         log('\nError in completion: %s\n' % e)