X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=main.py;h=7f632beaa997f0a7dd6bbff8066f32f4b80dff96;hb=aab82669cb0efd0a275e0ccd14ee779e894455ea;hp=19675cd109e897e31fd718452ce21e3dc1e9daab;hpb=40642ff27e4c9860d34c713b4388ee98d62b2f52;p=bup.git diff --git a/main.py b/main.py index 19675cd..7f632be 100755 --- a/main.py +++ b/main.py @@ -5,9 +5,15 @@ exec "$bup_python" "$0" ${1+"$@"} """ # end of bup preamble -from __future__ import absolute_import +from __future__ import absolute_import, print_function import errno, re, sys, os, subprocess, signal, getopt +if sys.version_info[0] != 2 \ + and not os.environ.get('BUP_ALLOW_UNEXPECTED_PYTHON_VERSION') == 'true': + print('error: bup may crash with python versions other than 2, or eat your data', + file=sys.stderr) + sys.exit(2) + from subprocess import PIPE from sys import stderr, stdout import select @@ -198,16 +204,15 @@ def filter_output(src_out, src_err, dest_out, dest_err): print_clean_line(dest, pending.pop(fd, []), width) else: split = sep_rx.split(buf) - if len(split) > 2: - while len(split) > 1: - content, sep = split[:2] - split = split[2:] - print_clean_line(dest, - pending.pop(fd, []) + [content], - width, - sep) - else: - assert(len(split) == 1) + while len(split) > 1: + content, sep = split[:2] + split = split[2:] + print_clean_line(dest, + pending.pop(fd, []) + [content], + width, + sep) + assert(len(split) == 1) + if split[0]: pending.setdefault(fd, []).extend(split) except BaseException as ex: pending_ex = chain_ex(add_ex_tb(ex), pending_ex)