]> arthur.barton.de Git - bup.git/blobdiff - lib/cmd/bup
Use pytest item results to preserve tmpdirs on failure
[bup.git] / lib / cmd / bup
index 92807a50254ba244f904ff33628f4fde5bfbec8a..03d98c54440aec457cdb5a12ba78a1e9b3ddbd3d 100755 (executable)
@@ -21,29 +21,25 @@ while test -L "$cmdpath"; do
 done
 script_home="$(cd "$(dirname "$cmdpath")" && pwd -P)"
 cd "$top"
-exec "$script_home/bup-python" "$0"
+exec "$script_home/../../config/bin/python" "$0"
 """
 # end of bup preamble
 
 from __future__ import absolute_import, print_function
+
+import os, sys
+sys.path[:0] = [os.path.dirname(os.path.realpath(__file__)) + '/..']
+
 import errno, getopt, os, re, select, signal, subprocess, sys
 from subprocess import PIPE
 
-from bup.compat import environ, restore_lc_env
+from bup.compat import environ, fsdecode
 from bup.io import path_msg
-
-if sys.version_info[0] != 2 \
-   and not environ.get(b'BUP_ALLOW_UNEXPECTED_PYTHON_VERSION') == b'true':
-    print('error: bup may crash with python versions other than 2, or eat your data',
-          file=sys.stderr)
-    sys.exit(2)
-
-restore_lc_env()
-
 from bup import compat, path, helpers
 from bup.compat import add_ex_tb, add_ex_ctx, argv_bytes, wrap_main
 from bup.helpers import atoi, columnate, debug1, log, merge_dict, tty_width
 from bup.io import byte_stream, path_msg
+from bup.options import _tty_width
 
 cmdpath = path.cmddir()
 
@@ -76,7 +72,7 @@ def usage(msg=""):
     cmds = []
     for c in sorted(os.listdir(cmdpath)):
         if c.startswith(b'bup-') and c.find(b'.') < 0:
-            cname = c[4:].decode('iso-8859-1')
+            cname = fsdecode(c[4:])
             if cname not in common:
                 cmds.append(c[4:].decode(errors='backslashreplace'))
     log(columnate(cmds, '    '))
@@ -159,7 +155,8 @@ if fix_stdout or fix_stderr:
     tty_env = merge_dict(environ,
                          {b'BUP_FORCE_TTY': (b'%d'
                                              % ((fix_stdout and 1 or 0)
-                                                + (fix_stderr and 2 or 0)))})
+                                                + (fix_stderr and 2 or 0))),
+                          b'BUP_TTY_WIDTH': b'%d' % _tty_width(), })
 else:
     tty_env = environ