]> arthur.barton.de Git - bup.git/blobdiff - cmd/ftp-cmd.py
gc: move core code to bup.gc module
[bup.git] / cmd / ftp-cmd.py
index 62f2cbc89af27d097c804265e9366338f85a5963..44fe68ca58142a5b1abadbd9880527334f796353 100755 (executable)
@@ -1,7 +1,15 @@
-#!/usr/bin/env python
+#!/bin/sh
+"""": # -*-python-*-
+bup_python="$(dirname "$0")/bup-python" || exit $?
+exec "$bup_python" "$0" ${1+"$@"}
+"""
+# end of bup preamble
+
 import sys, os, stat, fnmatch
+
 from bup import options, git, shquote, vfs, ls
-from bup.helpers import *
+from bup.helpers import chunkyreader, handle_ctrl_c, log
+
 
 handle_ctrl_c()
 
@@ -14,7 +22,7 @@ class OptionError(Exception):
 def do_ls(cmd_args):
     try:
         ls.do_ls(cmd_args, pwd, onabort=OptionError)
-    except OptionError, e:
+    except OptionError as e:
         return
 
 
@@ -44,7 +52,7 @@ def _completer_get_subs(line):
         n = pwd.resolve(dir)
         subs = list(filter(lambda x: x.name.startswith(name),
                            n.subs()))
-    except vfs.NoSuchFile, e:
+    except vfs.NoSuchFile as e:
         subs = []
     return (dir, name, qtype, lastword, subs)
 
@@ -110,12 +118,12 @@ def completer(text, state):
                 ret = shquote.what_to_add(qtype, lastword, fullname,
                                           terminate=True) + ' '
             return text + ret
-    except Exception, e:
+    except Exception as e:
         log('\n')
         try:
             import traceback
             traceback.print_tb(sys.exc_traceback)
-        except Exception, e2:
+        except Exception as e2:
             log('Error printing traceback: %s\n' % e2)
         log('\nError in completion: %s\n' % e)
 
@@ -144,7 +152,10 @@ else:
     if readline:
         readline.set_completer_delims(' \t\n\r/')
         readline.set_completer(completer)
-        readline.parse_and_bind("tab: complete")
+        if sys.platform.startswith('darwin'):
+            # MacOS uses a slighly incompatible clone of libreadline
+            readline.parse_and_bind('bind ^I rl_complete')
+        readline.parse_and_bind('tab: complete')
         init_readline_vars()
     lines = inputiter()
 
@@ -190,7 +201,7 @@ for line in lines:
                             outf = open(n.name, 'wb')
                             write_to_file(inf, outf)
                             outf.close()
-                        except Exception, e:
+                        except Exception as e:
                             rv = 1
                             log('  error: %s\n' % e)
         elif cmd == 'help' or cmd == '?':
@@ -200,7 +211,7 @@ for line in lines:
         else:
             rv = 1
             raise Exception('no such command %r' % cmd)
-    except Exception, e:
+    except Exception as e:
         rv = 1
         log('error: %s\n' % e)
         #raise