Return diff command error code.
This commit is contained in:
parent
9d859bc21c
commit
282701e675
|
@ -342,7 +342,7 @@ def run_archive_cmdlist (archive_cmdlist):
|
||||||
cmdlist, runkwargs = archive_cmdlist
|
cmdlist, runkwargs = archive_cmdlist
|
||||||
else:
|
else:
|
||||||
cmdlist, runkwargs = archive_cmdlist, {}
|
cmdlist, runkwargs = archive_cmdlist, {}
|
||||||
util.run(cmdlist, **runkwargs)
|
util.run_checked(cmdlist, **runkwargs)
|
||||||
|
|
||||||
|
|
||||||
def make_file_readable (filename):
|
def make_file_readable (filename):
|
||||||
|
@ -440,7 +440,7 @@ def handle_archive (archive, command, *args, **kwargs):
|
||||||
"""Handle archive file command; with nice error reporting."""
|
"""Handle archive file command; with nice error reporting."""
|
||||||
try:
|
try:
|
||||||
if command == "diff":
|
if command == "diff":
|
||||||
_diff_archives(archive, args[0])
|
res = _diff_archives(archive, args[0])
|
||||||
else:
|
else:
|
||||||
_handle_archive(archive, command, *args, **kwargs)
|
_handle_archive(archive, command, *args, **kwargs)
|
||||||
res = 0
|
res = 0
|
||||||
|
@ -465,7 +465,7 @@ def _diff_archives (archive1, archive2):
|
||||||
try:
|
try:
|
||||||
dir1 = _handle_archive(archive1, 'extract', outdir=tmpdir1)
|
dir1 = _handle_archive(archive1, 'extract', outdir=tmpdir1)
|
||||||
dir2 = _handle_archive(archive2, 'extract', outdir=tmpdir2)
|
dir2 = _handle_archive(archive2, 'extract', outdir=tmpdir2)
|
||||||
util.run([diff, "-BurN", dir1, dir2])
|
return util.run([diff, "-BurN", dir1, dir2])
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(tmpdir1, onerror=util.log_error)
|
shutil.rmtree(tmpdir1, onerror=util.log_error)
|
||||||
shutil.rmtree(tmpdir2, onerror=util.log_error)
|
shutil.rmtree(tmpdir2, onerror=util.log_error)
|
||||||
|
|
|
@ -85,6 +85,11 @@ def backtick (cmd):
|
||||||
|
|
||||||
|
|
||||||
def run (cmd, **kwargs):
|
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."""
|
"""Run command and raise PatoolError on error."""
|
||||||
retcode = subprocess.call(cmd, **kwargs)
|
retcode = subprocess.call(cmd, **kwargs)
|
||||||
if retcode:
|
if retcode:
|
||||||
|
@ -92,7 +97,6 @@ def run (cmd, **kwargs):
|
||||||
raise PatoolError(msg)
|
raise PatoolError(msg)
|
||||||
return retcode
|
return retcode
|
||||||
|
|
||||||
|
|
||||||
@memoized
|
@memoized
|
||||||
def guess_mime (filename):
|
def guess_mime (filename):
|
||||||
"""Guess the MIME type of given filename using file(1) and if that
|
"""Guess the MIME type of given filename using file(1) and if that
|
||||||
|
|
Loading…
Reference in New Issue