From 83c9e3c1865d1c7e121e54ef1ec9d4bb4a8dbe7d Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 13 Aug 2019 18:41:36 -0300 Subject: [PATCH] uninstall refactoring --- bauh/core/controller.py | 4 ++-- bauh/view/qt/thread.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bauh/core/controller.py b/bauh/core/controller.py index 498d1449..b96e869d 100755 --- a/bauh/core/controller.py +++ b/bauh/core/controller.py @@ -140,11 +140,11 @@ class GenericApplicationManager(ApplicationManager): if man: return man.update(app, root_password) - def uninstall(self, app: Application, root_password: str) -> SystemProcess: + def uninstall(self, app: Application, root_password: str, handler: ProcessHandler) -> bool: man = self._get_manager_for(app) if man: - return man.uninstall(app, root_password) + return man.uninstall(app, root_password, handler) def install(self, app: Application, root_password: str, handler: ProcessHandler) -> bool: man = self._get_manager_for(app) diff --git a/bauh/view/qt/thread.py b/bauh/view/qt/thread.py index e5f11eda..3b711b6e 100644 --- a/bauh/view/qt/thread.py +++ b/bauh/view/qt/thread.py @@ -95,7 +95,7 @@ class RefreshApps(QThread): self.signal.emit(self.manager.read_installed()) -class UninstallApp(AsyncAction): +class UninstallApp(AsyncAction, ProcessHandler): signal_finished = pyqtSignal(object) signal_output = pyqtSignal(str) @@ -108,8 +108,7 @@ class UninstallApp(AsyncAction): def run(self): if self.app: - process = self.manager.uninstall(self.app.model, self.root_password) - success = self.notify_subproc_outputs(process, self.signal_output) + success = self.manager.uninstall(self.app.model, self.root_password, self) if success: self.icon_cache.delete(self.app.model.base_data.icon_url) @@ -119,6 +118,13 @@ class UninstallApp(AsyncAction): self.app = None self.root_password = None + def handle(self, proc: SystemProcess) -> bool: + return self.notify_subproc_outputs(proc, self.signal_output) + + def notify(self, msg: str): + if msg: + self.signal_output.emit(msg) + class DowngradeApp(AsyncAction): signal_finished = pyqtSignal(bool)