Return diff command error code.

This commit is contained in:
Bastian Kleineidam 2010-03-11 17:54:09 +01:00
parent 9d859bc21c
commit 282701e675
2 changed files with 9 additions and 5 deletions

View File

@ -342,7 +342,7 @@ def run_archive_cmdlist (archive_cmdlist):
cmdlist, runkwargs = archive_cmdlist
else:
cmdlist, runkwargs = archive_cmdlist, {}
util.run(cmdlist, **runkwargs)
util.run_checked(cmdlist, **runkwargs)
def make_file_readable (filename):
@ -440,7 +440,7 @@ def handle_archive (archive, command, *args, **kwargs):
"""Handle archive file command; with nice error reporting."""
try:
if command == "diff":
_diff_archives(archive, args[0])
res = _diff_archives(archive, args[0])
else:
_handle_archive(archive, command, *args, **kwargs)
res = 0
@ -465,7 +465,7 @@ def _diff_archives (archive1, archive2):
try:
dir1 = _handle_archive(archive1, 'extract', outdir=tmpdir1)
dir2 = _handle_archive(archive2, 'extract', outdir=tmpdir2)
util.run([diff, "-BurN", dir1, dir2])
return util.run([diff, "-BurN", dir1, dir2])
finally:
shutil.rmtree(tmpdir1, onerror=util.log_error)
shutil.rmtree(tmpdir2, onerror=util.log_error)

View File

@ -85,6 +85,11 @@ def backtick (cmd):
def run (cmd, **kwargs):
"""Run command and raise PatoolError on error."""
return subprocess.call(cmd, **kwargs)
def run_checked (cmd, **kwargs):
"""Run command and raise PatoolError on error."""
retcode = subprocess.call(cmd, **kwargs)
if retcode:
@ -92,7 +97,6 @@ def run (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