mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-04 19:58:26 +02:00
made universal_newlines parameter in _run_popen optional
This commit is contained in:
parent
4cb2aa7379
commit
d456430714
2 changed files with 7 additions and 6 deletions
|
@ -92,7 +92,7 @@ def _run_dict(tools_path: Path | str, *args) -> dict:
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
def _run_popen(tools_path: Path | str, *args) -> subprocess.Popen:
|
def _run_popen(tools_path: Path | str, *args, universal_newlines=False) -> subprocess.Popen:
|
||||||
"""
|
"""
|
||||||
Run a command and return the process
|
Run a command and return the process
|
||||||
:param args: command arguments
|
:param args: command arguments
|
||||||
|
@ -103,6 +103,6 @@ def _run_popen(tools_path: Path | str, *args) -> subprocess.Popen:
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||||
bufsize=1,
|
bufsize=1 if universal_newlines else None,
|
||||||
universal_newlines=True,
|
universal_newlines=universal_newlines,
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,13 +19,13 @@ def _tools_run(*args) -> bytes:
|
||||||
return _run(tools_path, *args)
|
return _run(tools_path, *args)
|
||||||
|
|
||||||
|
|
||||||
def _tools_run_popen(*args) -> subprocess.Popen:
|
def _tools_run_popen(*args, **kwargs) -> subprocess.Popen:
|
||||||
"""
|
"""
|
||||||
Return a command with wit and return the output
|
Return a command with wit and return the output
|
||||||
:param args: command arguments
|
:param args: command arguments
|
||||||
:return: the output of the command
|
:return: the output of the command
|
||||||
"""
|
"""
|
||||||
return _run_popen(tools_path, *args)
|
return _run_popen(tools_path, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@better_wt_error(tools_path)
|
@better_wt_error(tools_path)
|
||||||
|
@ -155,7 +155,8 @@ class WITPath:
|
||||||
shutil.copytree(self._get_fst_root(), dest)
|
shutil.copytree(self._get_fst_root(), dest)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
process = _tools_run_popen("EXTRACT", self.path, "-d", dest, "--progress")
|
process = _tools_run_popen("EXTRACT", self.path, "-d", dest, "--progress", universal_newlines=True)
|
||||||
|
# universal_newlines is required to correctly read text line by line
|
||||||
|
|
||||||
while process.poll() is None:
|
while process.poll() is None:
|
||||||
m = re.match(r'\s*(?P<percentage>\d*)%(?:.*?ETA (?P<estimation>\d*:\d*))?\s*', process.stdout.readline())
|
m = re.match(r'\s*(?P<percentage>\d*)%(?:.*?ETA (?P<estimation>\d*:\d*))?\s*', process.stdout.readline())
|
||||||
|
|
Loading…
Reference in a new issue