gau1991
10 years ago
1 changed files with 24 additions and 0 deletions
@ -0,0 +1,24 @@ |
|||
"""EasyEngine download core classes.""" |
|||
import urllib.request |
|||
import urllib.error |
|||
|
|||
|
|||
class EEDownload(): |
|||
"""Method to download using urllib""" |
|||
def __init__(self): |
|||
pass |
|||
|
|||
def download(self, 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 |
Loading…
Reference in new issue