X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Finput_data_files.py;h=6abb3250e782ca964f93087d58d83b4d1b122221;hp=1923dad96585a5aa7be76d42850be06775d5ed90;hb=c623ad8042127fcb4bbd3c9ffb646f40371b7510;hpb=c0dd501b9c0a5e16c2d8f0e91e664cc9dcc04752 diff --git a/resources/tools/presentation/input_data_files.py b/resources/tools/presentation/input_data_files.py index 1923dad965..6abb3250e7 100644 --- a/resources/tools/presentation/input_data_files.py +++ b/resources/tools/presentation/input_data_files.py @@ -23,13 +23,12 @@ from os import rename, remove from os.path import join, getsize from shutil import move from zipfile import ZipFile, is_zipfile, BadZipfile - from httplib import responses from requests import get, codes, RequestException, Timeout, TooManyRedirects, \ HTTPError, ConnectionError from errors import PresentationError - +from utils import execute_command # Chunk size used for file download CHUNK_SIZE = 512 @@ -81,6 +80,14 @@ def download_data_files(spec): try: response = get(url, stream=True) code = response.status_code + + # temporary workaround, remove when output.log.xml is not needed + if code != codes["OK"] and \ + spec.input["file-name"].endswith(".gz"): + url = '.'.join(url.split('.')[:-1]) + ".log.gz" + response = get(url, stream=True) + code = response.status_code + if code != codes["OK"]: logging.warning( "Jenkins: {0}: {1}.".format(code, responses[code])) @@ -144,9 +151,7 @@ def download_data_files(spec): elif spec.input["file-name"].endswith(".gz"): rename(new_name, new_name[:-3]) - with open(new_name[:-3], 'r') as xml_file: - with gzip.open(new_name, 'wb') as gz_file: - gz_file.write(xml_file.read()) + execute_command("gzip --keep {0}".format(new_name[:-3])) new_name = new_name[:-3] status = "downloaded" logging.info("{0}: {1}".format(code, responses[code]))