mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-06 22:54:16 +02:00
refactoring downgrade | fix history
This commit is contained in:
@@ -120,11 +120,11 @@ class GenericApplicationManager(ApplicationManager):
|
||||
|
||||
return installed
|
||||
|
||||
def downgrade_app(self, app: Application, root_password: str) -> SystemProcess:
|
||||
def downgrade_app(self, app: Application, root_password: str, handler: ProcessHandler) -> bool:
|
||||
man = self._get_manager_for(app)
|
||||
|
||||
if man and app.can_be_downgraded():
|
||||
return man.downgrade_app(app, root_password)
|
||||
return man.downgrade_app(app, root_password, handler)
|
||||
else:
|
||||
raise Exception("downgrade is not possible for {}".format(app.__class__.__name__))
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@ popup.root.title=Requires root privileges
|
||||
popup.root.password=Password
|
||||
popup.root.bad_password.title=Error
|
||||
popup.root.bad_password.body=Wrong password
|
||||
popup.downgrade.impossible.title=Error
|
||||
popup.downgrade.impossible.body=Impossible to downgrade: the app is in its first version
|
||||
popup.history.title=History
|
||||
popup.history.selected.tooltip=Current version
|
||||
popup.button.yes=Yes
|
||||
|
||||
@@ -34,8 +34,6 @@ popup.root.title=Requiere privilegios de root
|
||||
popup.root.password=Contraseña
|
||||
popup.root.bad_password.title=Error
|
||||
popup.root.bad_password.body=Contraseña incorrecta
|
||||
popup.downgrade.impossible.title=Error
|
||||
popup.downgrade.impossible.body=Imposible revertir la versión: el aplicativo está en su primera versión
|
||||
popup.history.title=Historia
|
||||
popup.history.selected.tooltip=Versión actual
|
||||
popup.button.yes=Sí
|
||||
|
||||
@@ -34,8 +34,6 @@ popup.root.title=Requer privilégios de root
|
||||
popup.root.password=Senha
|
||||
popup.root.bad_password.title=Erro
|
||||
popup.root.bad_password.body=Senha incorreta
|
||||
popup.downgrade.impossible.title=Erro
|
||||
popup.downgrade.impossible.body=Impossível reverter a versão: o aplicativo está na sua primeira versão
|
||||
popup.history.title=Histórico
|
||||
popup.history.selected.tooltip=Versão atual
|
||||
popup.button.yes=Sim
|
||||
|
||||
@@ -25,7 +25,7 @@ class HistoryDialog(QDialog):
|
||||
|
||||
table_history.setColumnCount(len(app['history'][0]))
|
||||
table_history.setRowCount(len(app['history']))
|
||||
table_history.setHorizontalHeaderLabels([locale_keys['flatpak.info.' + key].capitalize() for key in sorted(app['history'][0].keys())])
|
||||
table_history.setHorizontalHeaderLabels([locale_keys.get(app['model'].get_type() + '.info.' + key, key).capitalize() for key in sorted(app['history'][0].keys())])
|
||||
|
||||
for row, commit in enumerate(app['history']):
|
||||
|
||||
|
||||
@@ -52,8 +52,11 @@ class AsyncAction(QThread, ProcessHandler):
|
||||
proc.subproc.communicate()
|
||||
return proc.subproc.returncode is None or proc.subproc.returncode == 0
|
||||
|
||||
def show_error(self, title: str, body: str):
|
||||
dialog.show_error(title, body)
|
||||
|
||||
class UpdateSelectedApps(AsyncAction, ProcessHandler):
|
||||
|
||||
class UpdateSelectedApps(AsyncAction):
|
||||
|
||||
signal_finished = pyqtSignal(bool, int)
|
||||
signal_status = pyqtSignal(str)
|
||||
@@ -101,7 +104,7 @@ class RefreshApps(QThread):
|
||||
self.signal.emit(self.manager.read_installed())
|
||||
|
||||
|
||||
class UninstallApp(AsyncAction, ProcessHandler):
|
||||
class UninstallApp(AsyncAction):
|
||||
signal_finished = pyqtSignal(object)
|
||||
signal_output = pyqtSignal(str)
|
||||
|
||||
@@ -145,16 +148,9 @@ class DowngradeApp(AsyncAction):
|
||||
|
||||
def run(self):
|
||||
if self.app:
|
||||
|
||||
success = False
|
||||
try:
|
||||
process = self.manager.downgrade_app(self.app.model, self.root_password)
|
||||
|
||||
if process is None:
|
||||
dialog.show_error(title=self.locale_keys['popup.downgrade.impossible.title'],
|
||||
body=self.locale_keys['popup.downgrade.impossible.body'])
|
||||
else:
|
||||
success = self.notify_subproc_outputs(process, self.signal_output)
|
||||
success = self.manager.downgrade_app(self.app.model, self.root_password, self)
|
||||
except (requests.exceptions.ConnectionError, NoInternetException):
|
||||
success = False
|
||||
self.signal_output.emit(self.locale_keys['internet.required'])
|
||||
@@ -163,6 +159,13 @@ class DowngradeApp(AsyncAction):
|
||||
self.root_password = None
|
||||
self.signal_finished.emit(success)
|
||||
|
||||
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 GetAppInfo(QThread):
|
||||
signal_finished = pyqtSignal(dict)
|
||||
|
||||
Reference in New Issue
Block a user