From 3ec372e54633c7d21bae73cd7985ea87d8ef53b0 Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Sat, 4 Oct 2008 20:59:46 -1000 Subject: [PATCH] Make the cleanup() function just remove the tmpdir location. --- src/bin/lorax | 3 +-- src/pylorax/__init__.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bin/lorax b/src/bin/lorax index e58fb610..abef5db6 100755 --- a/src/bin/lorax +++ b/src/bin/lorax @@ -130,5 +130,4 @@ if __name__ == "__main__": sys.stderr.write("Error writing %s/.discinfo file.\n" % (output,)) # clean up - trash = [yumconf, treedir, buildinstdir] - pylorax.cleanup(trash) + pylorax.cleanup() diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py index 2004e2ea..2c1f3719 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -201,13 +201,14 @@ def cleanup(trash=[]): """ - if trash is []: - return + if trash != []: + for item in trash: + if os.path.isdir(item): + shutil.rmtree(item, ignore_errors=True) + else: + os.unlink(item) - for item in trash: - if os.path.isdir(item): - shutil.rmtree(item, ignore_errors=True) - else: - os.unlink(item) + if os.path.isdir(conf['tmpdir']): + shutil.rmtree(conf['tmpdir'], ignore_errors=True) return