gooftool: remove created temporary report archive
The CreateReportArchiveBlob function won't remove created archive file
by itself. Therefore, a lot of temporary files will keep under /tmp/
directory. Delete the report archive after read out the content.
BUG=None
TEST=manual
Change-Id: I5e40ca9b22c775ec6e93bdbc090d98dd82a63b29
Reviewed-on: https://chromium-review.googlesource.com/385396
Commit-Ready: Wei-Han Chen <stimim@chromium.org>
Tested-by: Wei-Han Chen <stimim@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
diff --git a/py/gooftool/commands.py b/py/gooftool/commands.py
index bd304b1..0ecf77b 100755
--- a/py/gooftool/commands.py
+++ b/py/gooftool/commands.py
@@ -561,8 +561,12 @@
Returns:
An xmlrpclib.Binary object containing a .tar.xz file.
"""
- with open(CreateReportArchive(*args, **kwargs)) as f:
- return xmlrpclib.Binary(f.read())
+ report_archive = CreateReportArchive(*args, **kwargs)
+ try:
+ with open(report_archive) as f:
+ return xmlrpclib.Binary(f.read())
+ finally:
+ os.unlink(report_archive)
def CreateReportArchive(device_sn=None, add_file=None):