add fd.flush() to writing files

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
This commit is contained in:
Hiroshi Miura
2020-02-26 10:05:32 +09:00
parent 42078a2834
commit ebead77b65

View File

@@ -30,10 +30,15 @@ from logging import getLogger
import requests
import py7zr
from aqt.archives import QtPackage
from aqt.helper import altlink
class ExtractionError(Exception):
pass
class QtInstaller:
"""
Installer class to download packages and extract it.
@@ -68,8 +73,9 @@ class QtInstaller:
with open(archive, 'wb') as fd:
for chunk in r.iter_content(chunk_size=8196):
fd.write(chunk)
fd.seek(0)
if self.command is None:
fd.flush()
if self.command is None:
with open(archive, 'rb') as fd:
self.extract_archive(fd)
except Exception as e:
exc = sys.exc_info()
@@ -82,13 +88,9 @@ class QtInstaller:
self.logger.info("Finish installation of {} in {}".format(archive, time.process_time()))
def extract_archive(self, archive):
try:
szf = py7zr.SevenZipFile(archive)
szf.extractall(path=self.base_dir)
except Exception as e:
exc = sys.exc_info()
self.logger.error("Extraction error: %s" % exc[1])
raise e
szf = py7zr.SevenZipFile(archive)
szf.extractall(path=self.base_dir)
szf.close()
def extract_archive_ext(self, archive):
if self.base_dir is not None: