From 14d591194e80db52b8d98e29aa01a9e93f415ae0 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Mon, 5 Apr 2010 02:39:40 +0200 Subject: [PATCH] Use error function with correct number of arguments for rmtree() --- patoolib/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/patoolib/__init__.py b/patoolib/__init__.py index 460cc9c..c929bda 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -468,6 +468,12 @@ def handle_archive (archive, command, *args, **kwargs): return res +def rmtree_log_error (func, path, exc): + """Error log function for shutil.rmtree().""" + msg = "Error in %s(%s): %s" % (func.__name__, path, str(exc[1])) + util.log_error(msg) + + def _diff_archives (archive1, archive2): """Show differences between two archives.""" diff = util.find_program("diff") @@ -480,8 +486,8 @@ def _diff_archives (archive1, archive2): path2 = _handle_archive(archive2, 'extract', outdir=tmpdir2) return util.run([diff, "-urN", path1, path2]) finally: - shutil.rmtree(tmpdir1, onerror=util.log_error) - shutil.rmtree(tmpdir2, onerror=util.log_error) + shutil.rmtree(tmpdir1, onerror=rmtree_log_error) + shutil.rmtree(tmpdir2, onerror=rmtree_log_error) def _repack_archive (archive1, archive2): @@ -494,4 +500,4 @@ def _repack_archive (archive1, archive2): os.chdir(tmpdir) _handle_archive(archive, 'create', *files) finally: - shutil.rmtree(tmpdir, onerror=util.log_error) + shutil.rmtree(tmpdir, onerror=rmtree_log_error)