Update revprx_lnks.py
Browse files- revprx_lnks.py +8 -7
revprx_lnks.py
CHANGED
|
@@ -79,9 +79,7 @@ def unpack_archive(archive_path: str | Path, dest_path: str | Path, rm_archive:
|
|
| 79 |
raise RuntimeError(f'архив {archive_path} не найден.')
|
| 80 |
|
| 81 |
determine_format = determine_archive_format(archive_path)
|
| 82 |
-
|
| 83 |
-
print(determine_format, str(archive_path))
|
| 84 |
-
|
| 85 |
try:
|
| 86 |
if determine_format == '7z' or archive_path.suffix == '.7z':
|
| 87 |
run(f'7z -bso0 -bd -slp -y x {str(archive_path)} -o{str(dest_path)}')
|
|
@@ -109,7 +107,7 @@ def unpack_archive(archive_path: str | Path, dest_path: str | Path, rm_archive:
|
|
| 109 |
f'формат архива {archive_path.suffix} не определен, нужно задать формат в "determine_format".')
|
| 110 |
|
| 111 |
|
| 112 |
-
def run(command: str, cwd: str | Path | None = None) -> dict:
|
| 113 |
process = Popen(command, shell=True, cwd=cwd, stdout=PIPE, stderr=STDOUT)
|
| 114 |
encodings = ['iso-8859-5', 'windows-1251', 'iso-8859-1', 'cp866', 'koi8-r', 'mac_cyrillic']
|
| 115 |
is_progress_bar_pattern = r'\d+%|\d+/\d+'
|
|
@@ -135,11 +133,14 @@ def run(command: str, cwd: str | Path | None = None) -> dict:
|
|
| 135 |
|
| 136 |
if search(is_progress_bar_pattern, line_decoded):
|
| 137 |
last_progress_bar = line_decoded
|
| 138 |
-
|
|
|
|
| 139 |
else:
|
| 140 |
final_output.append(line_decoded)
|
| 141 |
-
|
| 142 |
-
|
|
|
|
|
|
|
| 143 |
|
| 144 |
process_output()
|
| 145 |
process.wait()
|
|
|
|
| 79 |
raise RuntimeError(f'архив {archive_path} не найден.')
|
| 80 |
|
| 81 |
determine_format = determine_archive_format(archive_path)
|
| 82 |
+
|
|
|
|
|
|
|
| 83 |
try:
|
| 84 |
if determine_format == '7z' or archive_path.suffix == '.7z':
|
| 85 |
run(f'7z -bso0 -bd -slp -y x {str(archive_path)} -o{str(dest_path)}')
|
|
|
|
| 107 |
f'формат архива {archive_path.suffix} не определен, нужно задать формат в "determine_format".')
|
| 108 |
|
| 109 |
|
| 110 |
+
def run(command: str, cwd: str | Path | None = None, live_output: bool = False) -> dict:
|
| 111 |
process = Popen(command, shell=True, cwd=cwd, stdout=PIPE, stderr=STDOUT)
|
| 112 |
encodings = ['iso-8859-5', 'windows-1251', 'iso-8859-1', 'cp866', 'koi8-r', 'mac_cyrillic']
|
| 113 |
is_progress_bar_pattern = r'\d+%|\d+/\d+'
|
|
|
|
| 133 |
|
| 134 |
if search(is_progress_bar_pattern, line_decoded):
|
| 135 |
last_progress_bar = line_decoded
|
| 136 |
+
if live_output:
|
| 137 |
+
stdout.write('\r' + line_decoded)
|
| 138 |
else:
|
| 139 |
final_output.append(line_decoded)
|
| 140 |
+
if live_output:
|
| 141 |
+
stdout.write('\n' + line_decoded)
|
| 142 |
+
|
| 143 |
+
if live_output: stdout.flush()
|
| 144 |
|
| 145 |
process_output()
|
| 146 |
process.wait()
|