From 51f1e8549bacc2fd144aea29e5b477f408534b06 Mon Sep 17 00:00:00 2001 From: Bengt Thuree Date: Thu, 15 Nov 2018 20:46:41 +1100 Subject: [PATCH] Use new internal _request_post_file function Refactor deploy_nexus_zip to use new internal function _request_post_file Change-Id: I42c1d7f1fae299680fb20483e0f14e62b85c5885 Signed-off-by: Bengt Thuree --- lftools/deploy.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/lftools/deploy.py b/lftools/deploy.py index d64d7596..a83f6f63 100644 --- a/lftools/deploy.py +++ b/lftools/deploy.py @@ -334,21 +334,9 @@ def deploy_nexus_zip(nexus_url, nexus_repo, nexus_path, zip_file): nexus_path) log.debug('Uploading {} to {}'.format(zip_file, url)) - upload_file = open(zip_file, 'rb') - - files = {'file': upload_file} - resp = requests.post(url, files=files) + resp = _request_post_file(url, zip_file) log.debug('{}: {}'.format(resp.status_code, resp.text)) - if resp.status_code == 400: - raise requests.HTTPError("Repository is read only: {}".format(nexus_repo)) - elif resp.status_code == 404: - raise requests.HTTPError("Did not find repository with ID: {}".format(nexus_repo)) - - if not str(resp.status_code).startswith('20'): - raise requests.HTTPError("Failed to upload to Nexus with status code: {}.\n{}\n{}".format( - resp.status_code, resp.text, zipfile.ZipFile(zip_file).infolist())) - def nexus_stage_repo_create(nexus_url, staging_profile_id): """Create a Nexus staging repo. -- 2.16.6