Improve mirror handling

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
This commit is contained in:
Hiroshi Miura
2019-11-24 21:56:41 +09:00
parent a678da038c
commit fbf413be50
4 changed files with 21 additions and 14 deletions

View File

@@ -52,21 +52,20 @@ class QtInstaller:
else:
self.logger = getLogger('aqt')
@staticmethod
def retrieve_archive(package, path=None, command=None):
def retrieve_archive(self, package, path=None, command=None):
archive = package.archive
url = package.url
print("-Downloading {}...".format(url))
self.logger.info("-Downloading {}...".format(url))
try:
r = requests.get(url, stream=True)
except requests.exceptions.ConnectionError as e:
print("Caught download error: %s" % e.args)
self.logger.warning("Caught download error: %s" % e.args)
return False
else:
with open(archive, 'wb') as fd:
for chunk in r.iter_content(chunk_size=8196):
fd.write(chunk)
print("-Extracting {}...".format(archive))
self.logger.info("-Extracting {}...".format(archive))
if sys.version_info > (3, 5):
if not py7zr.is_7zfile(archive):