summaryrefslogtreecommitdiff
path: root/lkft
diff options
context:
space:
mode:
authorYongqin Liu <yongqin.liu@linaro.org>2019-03-18 12:59:37 +0800
committerYongqin Liu <yongqin.liu@linaro.org>2019-03-18 12:59:37 +0800
commitf487143d73aad73c52298a2c554f235eee482058 (patch)
treea94d6906710d6a4faa1d3ba8ca7fcb309e013918 /lkft
parent7f324d55d14ae11ea68608fbf899e73d2b11f242 (diff)
lkft: deal with the case that files not exist
or file format incorrect problem Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Diffstat (limited to 'lkft')
-rw-r--r--lkft/views.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/lkft/views.py b/lkft/views.py
index 6639718..a9df320 100644
--- a/lkft/views.py
+++ b/lkft/views.py
@@ -53,6 +53,7 @@ class DotDict(dict):
def download_urllib(url, path):
+ check_dict = {'file_not_exist': False}
import urllib
def Schedule(a,b,c):
'''
@@ -60,6 +61,11 @@ def download_urllib(url, path):
b: the size of the block
c: the size of the file
'''
+ if c == -1:
+ #global file_not_exist
+ check_dict['file_not_exist'] = True
+ return
+
per = 100.0 * a * b / c
if per > 100 :
per = 100
@@ -70,7 +76,9 @@ def download_urllib(url, path):
sys.stdout.write("\r %.2f%%" % per)
sys.stdout.flush()
urllib.urlretrieve(url, path, Schedule)
- logger.info("File is saved to %s" % path)
+ if not check_dict['file_not_exist']:
+ logger.info("File is saved to %s" % path)
+ return check_dict['file_not_exist']
def get_attachment_urls(jobs=[]):
@@ -138,11 +146,18 @@ def download_attachments_save_result(jobs=[]):
(temp_fd, temp_path) = tempfile.mkstemp(suffix='.tar.xz', text=False)
logger.info("Start downloading result file for job %s: %s" % (job_url, temp_path))
- download_urllib(attachment_url, temp_path)
- tar_f = temp_path.replace(".xz", '')
- os.system("xz -d %s" % temp_path)
- extract_save_result(tar_f, result_file_path)
- os.unlink(tar_f)
+ ret_err = download_urllib(attachment_url, temp_path)
+ if ret_err:
+ logger.info("There is a problem with the size of the file: %s" % attachment_url)
+ continue
+ else:
+ tar_f = temp_path.replace(".xz", '')
+ ret = os.system("xz -d %s" % temp_path)
+ if ret == 0 :
+ extract_save_result(tar_f, result_file_path)
+ os.unlink(tar_f)
+ else:
+ logger.info("Failed to decompress %s with xz -d command for job: %s " % (temp_path, job_url))
def extract(result_zip_path, failed_testcases_all={}, metadata={}):