DownloadJobLogFiles V2

download_job_log_files_v2(public_api_client, file_path, local_zip_file)
Expand source code
download_job_log_files_v2(public_api_client, file_path, local_zip_file):
"""
Description
-----------
To download the job log file in .zip format by presigned urls.
Args
----
public_api_client: QDC api client object.
file_path: file path to download returned by get_job_log_files API.
local_zip_file: local path where to download the file.
Returns
-------
True: if download is success
None: In case of failure.
Usages
------
qdc_api.download_job_log_files_v2(public_api_client, "file path to download returned by get_job_log_files API", "c:\\temp\\file.zip")
"""
download_job_logs_response = get_jobs_presigned_downloadlogs.sync_detailed(client=get_client_with_headers_added(public_api_client),
path=file_path)
print(f"get presigned download url: {download_job_logs_response.parsed.url}")
try:
print(f"start downloading: {file_path} to {local_zip_file}")
download_job_log_response = requests.get(download_job_logs_response.parsed.url)
with open(local_zip_file, 'wb') as f:
f.write(download_job_log_response.content)
print(f"success to download: {file_path} to {local_zip_file}")
except Exception as e:
error_message = f"error during downloading: {file_path} to {local_zip_file}: {e}"
print(error_message)
raise Exception(error_message)

Description

To download the job log file in .zip format by presigned urls.

Arguments

  • public_api_client: QDC api client object.
  • file_path: file path to download returned by get_job_log_files API.
  • local_zip_file: local path where to download the file.

Returns

  • True: if download is success
  • None: In case of failure.

Usages

qdc_api.download_job_log_files_v2(public_api_client, "file path to download returned by get_job_log_files API", "c:\\temp\\file.zip")