tools.helpers.run.user(args, ["rm", path])
# Download the file
- logging.log(loglevel, "Download " + url)
+ logging.log(loglevel, "Downloading " + url)
try:
with urllib.request.urlopen(url) as response:
with open(path, "wb") as handle:
if headers is None:
headers = {}
- req = urllib.request.Request(url, headers=headers)
try:
+ req = urllib.request.Request(url, headers=headers)
with urllib.request.urlopen(req) as response:
return 200, response.read()
+ # Handle malformed URL
+ except ValueError as e:
+ return -1, ""
# Handle 404
except urllib.error.HTTPError as e:
return e.code, ""
+ except urllib.error.URLError as e:
+ return -2, ""