Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Unified Diff: client/common_lib/autotemp.py

Issue 4823005: Merge remote branch 'cros/upstream' into tempbranch (Closed) Base URL: http://git.chromium.org/git/autotest.git@master
Patch Set: patch Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/bin/partition.py ('k') | client/common_lib/base_packages.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/common_lib/autotemp.py
diff --git a/client/common_lib/autotemp.py b/client/common_lib/autotemp.py
index 536d81c127839959aef6064b3763fddd00c9aa64..bbe737eab2c382d0c4d28abeddf1fa7b4378ccaf 100644
--- a/client/common_lib/autotemp.py
+++ b/client/common_lib/autotemp.py
@@ -31,6 +31,7 @@ class tempfile(object):
t = autotemp.tempfile(unique_id='fig')
t.name # name of file
t.fd # file descriptor
+ t.fo # file object
t.clean() # clean up after yourself
"""
def __init__(self, unique_id, suffix='', prefix='', dir=None,
@@ -40,6 +41,7 @@ class tempfile(object):
self.fd, self.name = module_tempfile.mkstemp(suffix=suffix,
prefix=prefix,
dir=dir, text=text)
+ self.fo = os.fdopen(self.fd)
def clean(self):
@@ -47,15 +49,17 @@ class tempfile(object):
Remove the temporary file that was created.
This is also called by the destructor.
"""
+ if self.fo:
+ self.fo.close()
if self.name and os.path.exists(self.name):
os.remove(self.name)
- self.fd = self.name = None
+ self.fd = self.fo = self.name = None
def __del__(self):
try:
- if self.name:
+ if self.name is not None:
logging.debug('Clean was not called for ' + self.name)
self.clean()
except:
« no previous file with comments | « client/bin/partition.py ('k') | client/common_lib/base_packages.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698