- return False
-
- logging.info(" Downloading the file '{0}' to '{1}' ...".
- format(url, file_name))
-
- file_handle = open(file_name, "wb")
- for chunk in response.iter_content(chunk_size=CHUNK_SIZE):
- if chunk:
- file_handle.write(chunk)
- file_handle.close()
+ url = url.replace("_info", "")
+ log.append(("INFO", " Connecting to '{0}' ...".format(url)))
+ response = get(url, stream=True)
+ code = response.status_code
+ log.append(("INFO", " {0}: {1}".format(code, responses[code])))
+ if code != codes["OK"]:
+ return False, file_name
+ file_name = file_name.replace("_info", "")
+
+ log.append(("INFO", " Downloading the file '{0}' to '{1}' ...".
+ format(url, file_name)))
+
+ with open(file_name, "wb") as file_handle:
+ for chunk in response.iter_content(chunk_size=CHUNK_SIZE):
+ if chunk:
+ file_handle.write(chunk)