]> arthur.barton.de Git - bup.git/blobdiff - lib/cmd/ftp-cmd.py
ftp: handle lack of readline in input
[bup.git] / lib / cmd / ftp-cmd.py
index 87fd3cedf9446c41119341d0641a5eb102944f62..02a6fecef014609806e827c0c3a0b7aa222a6c1e 100755 (executable)
@@ -9,7 +9,7 @@ for arg in "$@"; do
     arg_i=$((arg_i + 1))
 done
 # Here to end of preamble replaced during install
-bup_python="$(dirname "$0")/bup-python" || exit $?
+bup_python="$(dirname "$0")/../../config/bin/python" || exit $?
 exec "$bup_python" "$0"
 """
 # end of bup preamble
@@ -20,10 +20,12 @@ exec "$bup_python" "$0"
 # (e.g. ISO-8859-1).
 
 from __future__ import absolute_import, print_function
-import sys, os, stat, fnmatch
+import os, fnmatch, stat, sys
+
+sys.path[:0] = [os.path.dirname(os.path.realpath(__file__)) + '/..']
 
 from bup import _helpers, compat, options, git, shquote, ls, vfs
-from bup.compat import argv_bytes
+from bup.compat import argv_bytes, fsdecode
 from bup.helpers import chunkyreader, handle_ctrl_c, log
 from bup.io import byte_stream, path_msg
 from bup.repo import LocalRepo
@@ -37,7 +39,8 @@ class OptionError(Exception):
 
 def do_ls(repo, args, out):
     try:
-        opt = ls.opts_from_cmdline(args, onabort=OptionError)
+        opt = ls.opts_from_cmdline([fsdecode(arg) for arg in args],
+                                   onabort=OptionError)
     except OptionError as e:
         log('error: %s' % e)
         return
@@ -52,11 +55,20 @@ def write_to_file(inf, outf):
 def inputiter():
     if os.isatty(stdin.fileno()):
         while 1:
-            try:
-                yield _helpers.readline(b'bup> ')
-            except EOFError:
-                print()  # Clear the line for the terminal's next prompt
-                break
+            if hasattr(_helpers, 'readline'):
+                try:
+                    yield _helpers.readline(b'bup> ')
+                except EOFError:
+                    print()  # Clear the line for the terminal's next prompt
+                    break
+            else:
+                out.write(b'bup> ')
+                out.flush()
+                read_line = stdin.readline()
+                if not read_line:
+                    print('')
+                    break
+                yield read_line
     else:
         for line in stdin:
             yield line