Improved command execution logging.

This commit is contained in:
Bastian Kleineidam 2010-11-15 21:29:19 +01:00
parent 79493755c5
commit 0d7a90e0f0
1 changed files with 7 additions and 3 deletions

View File

@ -89,9 +89,12 @@ def backtick (cmd):
def run (cmd, **kwargs):
"""Run command without error checking.
@return: command return code"""
args = (" ".join(map(shell_quote, cmd)),
", ".join("%s=%s" % (k, shell_quote(v)) for k, v in kwargs.items()))
log_info("running %s with %s" % args)
# Note that shell_quote_nt() result is not suitable for copy-paste
# (especially on Unix systems), but it looks nicer than shell_quote().
log_info("running %s" % " ".join(map(shell_quote_nt, cmd)))
if kwargs:
log_info(" with %s" % ", ".join("%s=%s" % (k, shell_quote(str(v)))\
for k, v in kwargs.items()))
return subprocess.call(cmd, **kwargs)
@ -103,6 +106,7 @@ def run_checked (cmd, **kwargs):
raise PatoolError(msg)
return retcode
@memoized
def guess_mime (filename):
"""Guess the MIME type of given filename using file(1) and if that