mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 15:34:15 +02:00
[appimage] improvement -> new custom action 'Update database'
This commit is contained in:
@@ -485,6 +485,9 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
return []
|
||||
|
||||
def execute_custom_action(self, action: CustomSoftwareAction, pkg: SoftwarePackage, root_password: str, watcher: ProcessWatcher):
|
||||
if action.requires_internet and not self.context.is_internet_available():
|
||||
raise NoInternetException()
|
||||
|
||||
man = action.manager if action.manager else self._get_manager_for(pkg)
|
||||
|
||||
if man:
|
||||
|
||||
@@ -1004,6 +1004,8 @@ class CustomAction(AsyncAction):
|
||||
self.i18n = i18n
|
||||
|
||||
def run(self):
|
||||
res = {'success': False, 'pkg': self.pkg, 'action': self.custom_action, 'error': None, 'error_type': MessageType.ERROR}
|
||||
|
||||
if self.custom_action.backup:
|
||||
proceed, _ = self.request_backup(app_config=read_config(),
|
||||
action_key=None,
|
||||
@@ -1011,22 +1013,24 @@ class CustomAction(AsyncAction):
|
||||
root_password=self.root_pwd,
|
||||
pkg=self.pkg)
|
||||
if not proceed:
|
||||
self.notify_finished({'success': False, 'pkg': self.pkg, 'action': self.custom_action})
|
||||
self.notify_finished(res)
|
||||
self.pkg = None
|
||||
self.custom_action = None
|
||||
self.root_pwd = None
|
||||
return
|
||||
|
||||
try:
|
||||
success = self.manager.execute_custom_action(action=self.custom_action,
|
||||
pkg=self.pkg.model if self.pkg else None,
|
||||
root_password=self.root_pwd,
|
||||
watcher=self)
|
||||
res['success'] = self.manager.execute_custom_action(action=self.custom_action,
|
||||
pkg=self.pkg.model if self.pkg else None,
|
||||
root_password=self.root_pwd,
|
||||
watcher=self)
|
||||
except (requests.exceptions.ConnectionError, NoInternetException):
|
||||
success = False
|
||||
res['success'] = False
|
||||
res['error'] = 'internet.required'
|
||||
res['error_type'] = MessageType.WARNING
|
||||
self.signal_output.emit(self.i18n['internet.required'])
|
||||
|
||||
self.notify_finished({'success': success, 'pkg': self.pkg, 'action': self.custom_action})
|
||||
self.notify_finished(res)
|
||||
self.pkg = None
|
||||
self.custom_action = None
|
||||
self.root_pwd = None
|
||||
|
||||
@@ -1433,6 +1433,11 @@ class ManageWindow(QWidget):
|
||||
self.comp_manager.restore_state(ACTION_CUSTOM_ACTION)
|
||||
self._show_console_errors()
|
||||
|
||||
if res['error']:
|
||||
dialog.show_message(title=self.i18n['warning' if res['error_type'] == MessageType.WARNING else 'error'].capitalize(),
|
||||
body=self.i18n[res['error']],
|
||||
type_=res['error_type'])
|
||||
|
||||
def _show_console_checkbox_if_output(self):
|
||||
if self.textarea_details.toPlainText():
|
||||
self.comp_manager.set_component_visible(CHECK_DETAILS, True)
|
||||
|
||||
Reference in New Issue
Block a user