You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

24 lines
814 B

"""EasyEngine download core classes."""
import urllib.request
import urllib.error
class EEDownload():
"""Method to download using urllib"""
def __init__():
pass
def download(url, filename):
try:
urllib.request.urlretrieve(url, filename)
return True
except urllib.error.URLError as e:
print("Unable to donwload file, [{err}]".format(err=str(e.reason)))
return False
except urllib.error.HTTPError as e:
print("Package download failed. [{err}]".format(err=str(e.reason)))
return False
except urllib.error.ContentTooShortError as e:
print("Package download failed. The amount of the downloaded data"
"is less than the expected amount")
return False