diff options
author | spisarski <s.pisarski@cablelabs.com> | 2017-05-25 08:46:40 -0600 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2017-05-25 08:46:40 -0600 |
commit | 5718894fcfb3e44dd08435cf71d2f1094425bed5 (patch) | |
tree | 49a3d582cb01bff697a648ee901372312d56bdb4 /snaps/file_utils.py | |
parent | 74386c6efb02cc352b0b090b7150813960ca1c95 (diff) |
Updated installation documents and fixed problems found during investigation.
The code changes are primarily required when the runtime environment is Windows.
JIRA: SNAPS-75
Change-Id: Ia2134861dd96e1d2c4b597f42fb348929e787a51
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/file_utils.py')
-rw-r--r-- | snaps/file_utils.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/snaps/file_utils.py b/snaps/file_utils.py index 7b93a6d..819c707 100644 --- a/snaps/file_utils.py +++ b/snaps/file_utils.py @@ -55,11 +55,16 @@ def download(url, dest_path, name=None): dest = dest_path + '/' + name logger.debug('Downloading file from - ' + url) # Override proxy settings to use localhost to download file - with open(dest, 'wb') as f: - logger.debug('Saving file to - ' + dest) - response = __get_url_response(url) - f.write(response.read()) - return f + f = None + try: + with open(dest, 'wb') as f: + logger.debug('Saving file to - ' + dest) + response = __get_url_response(url) + f.write(response.read()) + return f + finally: + if f: + f.close() def get_content_length(url): |