diff --git a/src/libutilities.py b/src/libutilities.py index 5aac51d..933a433 100644 --- a/src/libutilities.py +++ b/src/libutilities.py @@ -37,7 +37,7 @@ def backup(self, folder, password): #Enable encryption if password is given if password is None: - self.process = subprocess.Popen(["idevicebackup2", "backup", folder], stdout=subprocess.PIPE, bufsize=1, universal_newlines=True) + self.process = subprocess.Popen(["idevicebackup2", "backup", folder], stdout=subprocess.PIPE) return self.process @@ -47,7 +47,7 @@ def backup(self, folder, password): self.encrypt_process = subprocess.Popen(["idevicebackup2", "encryption", "on", password, folder]) self.encrypt_process.wait() - self.process = subprocess.Popen(["idevicebackup2", "backup", folder], stdout=subprocess.PIPE, bufsize=1, universal_newlines=True) + self.process = subprocess.Popen(["idevicebackup2", "backup", folder], stdout=subprocess.PIPE) return self.process @@ -55,14 +55,14 @@ def restore(self, folder, password): if password is None: - self.process = subprocess.Popen(["idevicebackup2", "restore", folder], stdout=subprocess.PIPE, bufsize=1, universal_newlines=True) + self.process = subprocess.Popen(["idevicebackup2", "restore", folder], stdout=subprocess.PIPE) return self.process else: print("Restoring encrypted backup...") - self.process = subprocess.Popen(["idevicebackup2", "restore", "--password", password, folder], stdout=subprocess.PIPE, bufsize=1, universal_newlines=True) + self.process = subprocess.Popen(["idevicebackup2", "restore", "--password", password, folder], stdout=subprocess.PIPE) return self.process diff --git a/src/ui/operations.py b/src/ui/operations.py index 5e32f4e..37aacaf 100644 --- a/src/ui/operations.py +++ b/src/ui/operations.py @@ -1,4 +1,4 @@ -import flet as ft +import flet as ft, time from libutilities import Action class Operation(ft.UserControl): @@ -21,9 +21,9 @@ def build(self): ft.Column( [self.lib_output], horizontal_alignment="center", expand=True, auto_scroll=True, scroll="auto", - width=400 + width=600 ), - ], width=400 + ], width=600 ), content_padding=30, modal=True, actions=[self.close_button, self.cancel_button] @@ -35,17 +35,23 @@ def backup(self, folder, pwd): self.result_dialog.open = True self.result_dialog.title = ft.Text("Backing Up", text_align="center") - self.lib_output.value = "...\n" + self.lib_output.value = "Running backup...\n" self.update() process = self.action.backup(folder, pwd) + + while True: - for line in process.stdout: - print(line, end="") + #Benefits smoother scrolling of lib_output texfield + time.sleep(0.5) + line = process.stdout.readline().decode() + + print(line, end='') self.lib_output.value += line self.update() - process.wait() + if process.poll() is not None and line == '': + break self.close_button.disabled = False self.cancel_button.disabled = True @@ -57,17 +63,23 @@ def restore(self, folder, pwd): self.result_dialog.open = True self.result_dialog.title = ft.Text("Restoring", text_align="center") - self.lib_output.value = "...\n" + self.lib_output.value = "Running restore...\n" self.update() process = self.action.restore(folder, pwd) - for line in process.stdout: - print(line, end="") + while True: + + #Benefits smoother scrolling of lib_output texfield + time.sleep(0.5) + line = process.stdout.readline().decode() + + print(line, end='') self.lib_output.value += line self.update() - process.wait() + if process.poll() is not None and line == '': + break self.close_button.disabled = False self.cancel_button.disabled = True