mirror of
https://github.com/RedDeadDepresso/KKAFIO.git
synced 2025-12-23 18:00:02 +00:00
refactor: 7-zip subprocess
This commit is contained in:
@@ -50,7 +50,7 @@ class SettingInterface(ScrollArea):
|
|||||||
self.filenameCard = LineEditSettingCard(
|
self.filenameCard = LineEditSettingCard(
|
||||||
cfg.filename,
|
cfg.filename,
|
||||||
FIF.ZIP_FOLDER,
|
FIF.ZIP_FOLDER,
|
||||||
self.tr('Name for the backup zip file'),
|
self.tr('Name for the backup 7-zip file'),
|
||||||
None,
|
None,
|
||||||
parent=self.backupGroup
|
parent=self.backupGroup
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -127,16 +127,18 @@ class FileManager:
|
|||||||
command = f'"{path_to_7zip}" a -t7z "{archive_file}" {include_string} {exclude_string}'
|
command = f'"{path_to_7zip}" a -t7z "{archive_file}" {include_string} {exclude_string}'
|
||||||
|
|
||||||
# Call the command
|
# Call the command
|
||||||
process = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||||
|
|
||||||
# Print the output
|
# Print the output
|
||||||
for line in process.stdout.decode().split('\n'):
|
while process.poll() is None:
|
||||||
|
for line in process.stdout:
|
||||||
if line.strip():
|
if line.strip():
|
||||||
logger.info("7-Zip", line)
|
logger.info("7-Zip", line)
|
||||||
|
|
||||||
# Check the return code
|
# Check the return code
|
||||||
if process.returncode not in [0, 1]:
|
if process.returncode not in [0, 1]:
|
||||||
raise Exception()
|
logger.error("7-Zip", f"Exited with return code: {process.returncode}")
|
||||||
|
raise Exception(f"7-zip exited with return code: {process.returncode}")
|
||||||
|
|
||||||
def extract_archive(self, archive_path: Union[Path, str]):
|
def extract_archive(self, archive_path: Union[Path, str]):
|
||||||
from app.components.password_dialog import password_dialog
|
from app.components.password_dialog import password_dialog
|
||||||
|
|||||||
Reference in New Issue
Block a user