From fd4e283258e169a10a749db4f2ee141366c7e379 Mon Sep 17 00:00:00 2001 From: Manoj Gupta Date: Wed, 9 Nov 2016 12:09:36 -0800 Subject: 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 Tested-by: Manoj Gupta Reviewed-by: Caroline Tice --- crosperf/download_images.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'crosperf/download_images.py') 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): -- cgit v1.2.3