summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmorph12
-rw-r--r--morphlib/tempdir.py10
-rw-r--r--morphlib/tempdir_tests.py11
3 files changed, 3 insertions, 30 deletions
diff --git a/morph b/morph
index 485dd469..9b81f277 100755
--- a/morph
+++ b/morph
@@ -145,9 +145,7 @@ class Morph(cliapp.Application):
# build things in this order
ret.append(builder.build(blobs, order))
- # we may not have permission to tempdir.remove()
- ex = morphlib.execute.Execute('.', lambda msg: None)
- ex.runv(["rm", "-rf", tempdir.dirname])
+ tempdir.remove()
if args:
raise cliapp.AppException('Extra args on command line: %s' % args)
@@ -285,9 +283,7 @@ class Morph(cliapp.Application):
self.msg('Building %s' % first_blob)
ret.append(builder.build_single(first_blob, blobs, order))
- # we may not have permission to tempdir.remove()
- ex = morphlib.execute.Execute('.', lambda msg: None)
- ex.runv(["rm", "-rf", tempdir.dirname])
+ tempdir.remove()
if args:
raise cliapp.AppException('Extra args on command line: %s' % args)
@@ -355,9 +351,7 @@ class Morph(cliapp.Application):
# build the tuple and all its dependencies
result.append(controller.build(blobs, order))
- # we may not have permission to tempdir.remove()
- ex = morphlib.execute.Execute('.', lambda msg: None)
- ex.runv(["rm", "-rf", tempdir.dirname])
+ tempdir.remove()
if args:
raise cliapp.AppException('Extra args on command line: %s' % args)
diff --git a/morphlib/tempdir.py b/morphlib/tempdir.py
index 9780b685..6377fdbc 100644
--- a/morphlib/tempdir.py
+++ b/morphlib/tempdir.py
@@ -34,16 +34,6 @@ class Tempdir(object):
shutil.rmtree(self.dirname)
self.dirname = None
- def clear(self):
- '''Clear temporary directory of everything.'''
- logging.debug('Removing contents of %s' % self.dirname)
- for x in os.listdir(self.dirname):
- filename = self.join(x)
- if os.path.isdir(filename):
- shutil.rmtree(filename)
- else:
- os.remove(filename)
-
def join(self, relative):
'''Return full path to file in temporary directory.
diff --git a/morphlib/tempdir_tests.py b/morphlib/tempdir_tests.py
index 977769b0..ae2b6a59 100644
--- a/morphlib/tempdir_tests.py
+++ b/morphlib/tempdir_tests.py
@@ -56,14 +56,3 @@ class TempdirTests(unittest.TestCase):
self.assertEqual(self.tempdir.join('/foo'),
os.path.join(self.tempdir.dirname, 'foo'))
- def test_clears_when_empty(self):
- self.tempdir.clear()
- self.assertEqual(os.listdir(self.tempdir.dirname), [])
-
- def test_clears_when_not_empty(self):
- os.mkdir(self.tempdir.join('foo'))
- with open(self.tempdir.join('bar'), 'w') as f:
- f.write('bar')
- self.tempdir.clear()
- self.assertEqual(os.listdir(self.tempdir.dirname), [])
-