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/cros_output.py b/host/lib/cros_output.py
index d8891bf..b638db7 100644
--- a/host/lib/cros_output.py
+++ b/host/lib/cros_output.py
@@ -45,9 +45,13 @@
# TODO(sjg): Move this into Chromite libraries when we have them
self.stdout_is_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
- def __del__(self):
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, traceback):
"""Clean up and remove any progress message."""
self.ClearProgress()
+ return False
def UserIsPresent(self):
"""This returns True if it is likely that a user is present.