Use TMPDIR for temporary data, and catch keyboard interrupts.

This commit is contained in:
Bastian Kleineidam 2010-03-11 17:15:03 +01:00
parent a30d44c6a5
commit 9d859bc21c
2 changed files with 10 additions and 2 deletions

View File

@ -444,6 +444,9 @@ def handle_archive (archive, command, *args, **kwargs):
else:
_handle_archive(archive, command, *args, **kwargs)
res = 0
except KeyboardInterrupt, msg:
util.log_info("aborted")
res = 1
except util.PatoolError, msg:
util.log_error(msg)
res = 1
@ -457,8 +460,8 @@ def _diff_archives (archive1, archive2):
diff = util.find_program("diff")
if not diff:
raise util.PatoolError("diff(1) is required for showing archive differences, please install it")
tmpdir1 = util.tmpdir(dir=os.getcwd())
tmpdir2 = util.tmpdir(dir=os.getcwd())
tmpdir1 = util.tmpdir()
tmpdir2 = util.tmpdir()
try:
dir1 = _handle_archive(archive1, 'extract', outdir=tmpdir1)
dir2 = _handle_archive(archive2, 'extract', outdir=tmpdir2)

View File

@ -279,6 +279,11 @@ def log_error (msg, out=sys.stderr):
print >> out, "patool error:", msg
def log_info (msg, out=sys.stderr):
"""Print info message to stderr (or any other given output)."""
print >> out, "patool:", msg
def log_internal_error (out=sys.stderr):
"""Print internal error message to stderr."""
print >> out, "patool: internal error"