cros_bundle_firmware: Use enter/exit instead of del
This change makes use of Python's 'with' construct which is a nicer way to
deal with the finalization problem.
BUG=chromium-os:17298
TEST=run cros_bundle_firmware; check that output is still consistent and
output directory is removed.
Change-Id: I81045a5e52af68f512dbf4a48a6151832e7c47d5
Reviewed-on: http://gerrit.chromium.org/gerrit/5592
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
diff --git a/host/lib/tools.py b/host/lib/tools.py
index 586f5a6..8d8bed2 100755
--- a/host/lib/tools.py
+++ b/host/lib/tools.py
@@ -78,8 +78,12 @@
self.outdir = None # We have no output directory yet
self._delete_tempdir = None # And no temporary directory to delete
- def __del__(self):
- self.FinalizeOutputDir()
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, traceback):
+ self.FinalizeOutputDir()
+ return False
def _SetRoot(self, root_dir):
"""Sets the root directory for the build envionrment.