summaryrefslogtreecommitdiffstats
path: root/puppethost.py
diff options
context:
space:
mode:
authorTodd Zullinger <tmz@pobox.com>2009-08-28 14:08:13 -0400
committerTodd Zullinger <tmz@pobox.com>2009-08-28 14:08:13 -0400
commitb834081493101080cf2001a3d87c7b6d7a47491d (patch)
tree391d75d2cdaf1dfe6d6a33bf68280c30c1459f3e /puppethost.py
parent42cb7ade8c8b049cd46d7053fb514c6b4463cd19 (diff)
downloadpuppet-host-package-b834081493101080cf2001a3d87c7b6d7a47491d.tar.gz
puppet-host-package-b834081493101080cf2001a3d87c7b6d7a47491d.tar.xz
puppet-host-package-b834081493101080cf2001a3d87c7b6d7a47491d.zip
Don't run cleanup() in rpm(), call it explicitly
Running cleanup() from rpm() made it impossible to create a tarball or other package after rpm() was called because it deleted the tmpdir, which was made a class variable in ae26808.
Diffstat (limited to 'puppethost.py')
-rw-r--r--puppethost.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/puppethost.py b/puppethost.py
index e1ce7ef..91c429b 100644
--- a/puppethost.py
+++ b/puppethost.py
@@ -187,10 +187,7 @@ class PuppetHost(object):
rpmdir = self.opts['rpmdir']
if not self.tarball or not os.path.exists(self.tarball):
- try: self.tar()
- except:
- self._cleanup(self.tmpdir)
- raise
+ self.tar()
spec = '%s/puppet-%s.spec' % (self.tmpdir, self.hostname)
@@ -209,11 +206,9 @@ class PuppetHost(object):
cmd = 'rpm -q --qf "%s/%s" --specfile %s' % (rpmdir, rpm_fmt, spec)
status, rpm = commands.getstatusoutput(cmd)
if status:
- self._cleanup(self.tmpdir)
raise PuppetHostError('Failed to get rpm filename:\n%s' % rpm)
if os.path.exists(rpm) and not self.opts['force_package']:
- self._cleanup(self.tmpdir)
raise PuppetHostError('%s exists, not overwriting' % rpm)
if self.opts['verbose']:
@@ -228,13 +223,11 @@ class PuppetHost(object):
status, output = commands.getstatusoutput(cmd)
if status or not os.path.exists(rpm):
- self._cleanup(self.tmpdir)
raise PuppetHostError('Error building rpm:\n', output)
if self.opts['verbose']:
print 'done'
- self._cleanup(self.tmpdir)
self.packages.append(('rpm', rpm))
def _check_files(self):
@@ -247,9 +240,11 @@ class PuppetHost(object):
error += '\t%s' % f
raise PuppetHostError(error)
- def _cleanup(self, dir):
- if os.path.isdir(dir):
- shutil.rmtree(dir)
+ def cleanup(self, dirs=[]):
+ dirs.append(self.tmpdir)
+ for d in dirs:
+ if os.path.isdir(d):
+ shutil.rmtree(d)
@property
def files(self):