from wvtest import WVPASSEQ, wvfailure_count
from bup import helpers
+from bup.compat import fsencode, str_type
+from bup.io import byte_stream
@contextmanager
# Assumes (of course) this file is at the top-level of the source tree
-_bup_tmp = realpath(dirname(__file__.encode('iso-8859-1')) + b'/t/tmp')
+_bup_tmp = realpath(dirname(fsencode(__file__))) + b'/t/tmp'
try:
os.makedirs(_bup_tmp)
except OSError as e:
out, err = p.communicate(input=input)
if check and p.returncode != 0:
raise Exception('subprocess %r failed with status %d%s'
- % (' '.join(map(quote, cmd)), p.returncode,
+ % (cmd, p.returncode,
(', stderr: %r' % err) if err else ''))
return ex_res(out=out, err=err, proc=p, rc=p.returncode)
def logcmd(cmd):
- if isinstance(cmd, basestring):
- print(cmd, file=sys.stderr)
+ s = helpers.shstr(cmd)
+ if isinstance(cmd, str_type):
+ print(s, file=sys.stderr)
else:
- print(' '.join(map(quote, cmd)), file=sys.stderr)
+ # bytes - for now just escape it
+ print(s.decode(errors='backslashreplace'), file=sys.stderr)
def ex(cmd, **kwargs):
"""Print cmd to stderr and then run it as per ex(...).
logcmd(cmd)
result = run(cmd, **kwargs)
if result.err:
- sys.stderr.write(result.err)
+ sys.stderr.flush()
+ byte_stream(sys.stderr).write(result.err)
return result
def exo(cmd, **kwargs):