mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-18 13:14:37 +03:00
add fd.flush() to writing files
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
This commit is contained in:
@@ -30,10 +30,15 @@ from logging import getLogger
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
import py7zr
|
import py7zr
|
||||||
|
|
||||||
from aqt.archives import QtPackage
|
from aqt.archives import QtPackage
|
||||||
from aqt.helper import altlink
|
from aqt.helper import altlink
|
||||||
|
|
||||||
|
|
||||||
|
class ExtractionError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class QtInstaller:
|
class QtInstaller:
|
||||||
"""
|
"""
|
||||||
Installer class to download packages and extract it.
|
Installer class to download packages and extract it.
|
||||||
@@ -68,8 +73,9 @@ class QtInstaller:
|
|||||||
with open(archive, 'wb') as fd:
|
with open(archive, 'wb') as fd:
|
||||||
for chunk in r.iter_content(chunk_size=8196):
|
for chunk in r.iter_content(chunk_size=8196):
|
||||||
fd.write(chunk)
|
fd.write(chunk)
|
||||||
fd.seek(0)
|
fd.flush()
|
||||||
if self.command is None:
|
if self.command is None:
|
||||||
|
with open(archive, 'rb') as fd:
|
||||||
self.extract_archive(fd)
|
self.extract_archive(fd)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exc = sys.exc_info()
|
exc = sys.exc_info()
|
||||||
@@ -82,13 +88,9 @@ class QtInstaller:
|
|||||||
self.logger.info("Finish installation of {} in {}".format(archive, time.process_time()))
|
self.logger.info("Finish installation of {} in {}".format(archive, time.process_time()))
|
||||||
|
|
||||||
def extract_archive(self, archive):
|
def extract_archive(self, archive):
|
||||||
try:
|
szf = py7zr.SevenZipFile(archive)
|
||||||
szf = py7zr.SevenZipFile(archive)
|
szf.extractall(path=self.base_dir)
|
||||||
szf.extractall(path=self.base_dir)
|
szf.close()
|
||||||
except Exception as e:
|
|
||||||
exc = sys.exc_info()
|
|
||||||
self.logger.error("Extraction error: %s" % exc[1])
|
|
||||||
raise e
|
|
||||||
|
|
||||||
def extract_archive_ext(self, archive):
|
def extract_archive_ext(self, archive):
|
||||||
if self.base_dir is not None:
|
if self.base_dir is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user