-def logcmd(cmd):
- if isinstance(cmd, basestring):
- print(cmd, file=stderr)
- else:
- print(' '.join(map(quote, cmd)), file=stderr)
-
-def exc(cmd, shell=False):
- logcmd(cmd)
- check_call(cmd, shell=shell)
-
-def exo(cmd, stdin=None, stdout=True, stderr=False, shell=False, check=True):
- logcmd(cmd)
- p = Popen(cmd,
- stdin=None,
- stdout=(PIPE if stdout else None),
- stderr=PIPE,
- shell=shell)
- out, err = p.communicate()
- if check and p.returncode != 0:
- raise Exception('subprocess %r failed with status %d, stderr: %r'
- % (' '.join(argv), p.returncode, err))
- return out, err, p
-
-def bup(*args):
- return exo((bup_cmd,) + args)[0]
-
-def bupc(*args):
- return exc((bup_cmd,) + args)
-