+def download_and_unzip_data_file(spec, job, build, pid):
+ """Download and unzip a source file.
+
+ :param spec: Specification read form the specification file.
+ :param job: Name of the Jenkins job.
+ :param build: Information about the build.
+ :param pid: PID of the process executing this method.
+ :type spec: Specification
+ :type job: str
+ :type build: dict
+ :type pid: int
+ :returns: True if the download was successful, otherwise False.
+ :rtype: bool
+ """
+
+ success = False
+
+ file_name = spec.input[u"file-name"]
+ new_name = join(
+ spec.environment[u"paths"][u"DIR[WORKING,DATA]"],
+ f"{job}{SEPARATOR}{build[u'build']}{SEPARATOR}{file_name}"
+ )
+ arch = bool(spec.configuration.get(u"archive-inputs", True))
+ downloaded_name = u""
+
+ # Try to download .gz from s3_storage
+ for path in spec.input[u'download-path']:
+ url = u"{0}/{1}".format(
+ spec.environment[u'urls'][u'URL[S3_STORAGE,LOG]'],
+ path.format(job=job, build=build[u'build'], filename=file_name)
+ )
+ logging.info(f"Trying to download {url}")
+ success, downloaded_name = _download_file(
+ url, new_name, arch=arch, verify=False, repeat=3
+ )
+ if success:
+ break
+
+ if not success:
+ # Try to download .gz from logs.fd.io
+ for path in spec.input[u'download-path']:
+ url = u"{0}/{1}".format(
+ spec.environment[u'urls'][u'URL[NEXUS,LOG]'],
+ path.format(job=job, build=build[u'build'], filename=file_name)
+ )
+ logging.info(f"Trying to download {url}")
+ success, downloaded_name = _download_file(
+ url, new_name, arch=arch, verify=True, repeat=3
+ )
+ if success:
+ break
+
+ if not success:
+ # Try to download .gz or .zip from docs.fd.io
+ file_name = (spec.input[u"file-name"], spec.input[u"zip-file-name"])
+ release = re.search(REGEX_RELEASE, job).group(2)
+ for idx, rls in enumerate((release, u"master", )):
+ try:
+ rls = f"rls{int(rls)}"
+ except ValueError:
+ # It is master