diff options
author | Manoj Gupta <manojgupta@google.com> | 2016-11-09 12:09:36 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-11-10 12:09:17 -0800 |
commit | fd4e283258e169a10a749db4f2ee141366c7e379 (patch) | |
tree | 275a6a23c69b0259c088932d97e08f97c3b2480c /crosperf/download_images.py | |
parent | c00e1d61dd82a9f9eab25e45b888b6f6966904b2 (diff) | |
download | toolchain-utils-fd4e283258e169a10a749db4f2ee141366c7e379.tar.gz |
Crosperf: Remove tar file after uncompressing image
Remove downloaded chromium image.tar.xz file after uncompression.
Change 2 step untar and uncompress to 1. Catch exceptions during
uncompression to avoid having a corrupted bin file if
uncompression is interrupted.
BUG: chromium:663426
TEST: crosperf unit tests pass
Change-Id: I82f674a26bf99cb3491e7db770664c73c004a93b
Reviewed-on: https://chrome-internal-review.googlesource.com/303875
Commit-Ready: Manoj Gupta <manojgupta@google.com>
Tested-by: Manoj Gupta <manojgupta@google.com>
Reviewed-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'crosperf/download_images.py')
-rw-r--r-- | crosperf/download_images.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/crosperf/download_images.py b/crosperf/download_images.py index cabeeb5a..14a91427 100644 --- a/crosperf/download_images.py +++ b/crosperf/download_images.py @@ -79,15 +79,32 @@ class ImageDownloader(object): return # Uncompress and untar the downloaded image. - command = ('cd /tmp/%s ;unxz chromiumos_test_image.tar.xz; ' - 'tar -xvf chromiumos_test_image.tar' % build_id) + command = ('cd /tmp/%s ; tar -Jxf chromiumos_test_image.tar.xz ' % build_id) if self.log_level != 'verbose': self._logger.LogOutput('CMD: %s' % command) print('(Uncompressing and un-tarring may take a couple of minutes...' 'please be patient.)') + try: + retval = self._ce.ChrootRunCommand(chromeos_root, command) + if retval != 0: + raise MissingImage('Cannot uncompress image: %s.' % build_id) + except Exception: + # Exception in uncompressing file, so cleanup + command = ('cd /tmp/%s ; rm -f chromiumos_test_image.bin; ' % build_id) + # Remove the partially extracted bin file to avoid issues with future runs + _ = self._ce.ChrootRunCommand(chromeos_root, command) + # Raise exception again + raise + + # Remove uncompressed file + command = ('cd /tmp/%s ; rm -f chromiumos_test_image.tar.xz; ' % build_id) + if self.log_level != 'verbose': + self._logger.LogOutput('CMD: %s' % command) + print('(Removing file chromiumos_test_image.tar.xz.)') + # try removing file, its ok to have an error, print if encountered retval = self._ce.ChrootRunCommand(chromeos_root, command) if retval != 0: - raise MissingImage('Cannot uncompress image: %s.' % build_id) + print('(Warning: Could not remove file chromiumos_test_image.tar.xz .)') def DownloadSingleAutotestFile(self, chromeos_root, build_id, package_file_name): |