def apt_on_error(self, error): if isinstance(error, aptdaemon.errors.NotAuthorizedError): # Silently ignore auth failures return elif not isinstance(error, aptdaemon.errors.TransactionFailed): # Catch internal errors of the client error = aptdaemon.errors.TransactionFailed(ERROR_UNKNOWN, str(error)) dia = AptErrorDialog(error) dia.run() dia.hide()
def _on_finished(self, transaction, status, close, show_error): if close: self.hide() if status == EXIT_FAILED and show_error: Gdk.threads_enter() err_dia = AptErrorDialog(self._transaction.error, self) err_dia.run() err_dia.hide() Gdk.threads_leave() self.emit("finished")
def on_error(self, error): try: raise error except aptdaemon.errors.NotAuthorizedError: # Silently ignore auth failures return except aptdaemon.errors.TransactionFailed as error: pass except Exception as error: error = aptdaemon.errors.TransactionFailed(ERROR_UNKNOWN, str(error)) self.error_dlg = AptErrorDialog(error, None) self.error_dlg.set_title('Σφάλμα') self.error_dlg.run()
def _on_error(self, error): try: raise error except aptdaemon.errors.NotAuthorizedError: # Silently ignore auth failures return except aptdaemon.errors.TransactionFailed as error: pass except Exception as error: error = aptdaemon.errors.TransactionFailed(aptdaemon.enums.ERROR_UNKNOWN, str(error)) dia = AptErrorDialog(error) dia.run() dia.hide()
def _error_handler(self, error): try: raise error except NotAuthorizedError: # Silently ignore auth failures sys.exit(11) return except TransactionFailed: pass except Exception as error: error = TransactionFailed(ERROR_UNKNOWN, str(error)) dia = AptErrorDialog(error) dia.run() sys.exit(10)
def _error_handler(self, error): try: raise error except NotAuthorizedError: # Silently ignore auth failures sys.exit(11) return except TransactionFailed as error: pass except Exception as error: error = TransactionFailed(ERROR_UNKNOWN, str(error)) dia = AptErrorDialog(error) dia.run() sys.exit(10)
def _on_error(self, error): if self.apt_transaction.error_code == "error-not-authorized": # Silently ignore auth failures self.task.error_message = None # Should already be none, but this is a reminder return elif not isinstance(error, aptdaemon.errors.TransactionFailed): # Catch internal errors of the client error = aptdaemon.errors.TransactionFailed(aptdaemon.enums.ERROR_UNKNOWN, str(error)) if self.task.progress_state != self.task.PROGRESS_STATE_FAILED: self.task.progress_state = self.task.PROGRESS_STATE_FAILED self.task.error_message = self.apt_transaction.error_details dia = AptErrorDialog(error) dia.run() dia.hide() GObject.idle_add(self.task.error_cleanup_cb, self.task)
def _on_error(self, error): try: raise error except aptdaemon.errors.NotAuthorizedError: # Silently ignore auth failures return except aptdaemon.errors.TransactionFailed as error: pass except Exception as error: error = aptdaemon.errors.TransactionFailed( aptdaemon.enums.ERROR_UNKNOWN, str(error)) dia = AptErrorDialog(error) dia.run() dia.hide()
def _on_error(self, error): try: raise error except aptdaemon.errors.NotAuthorizedError: log.debug("aptdaemon.errors.NotAuthorizedError") # Silently ignore auth failures return except aptdaemon.errors.TransactionFailed as error: log.error("TransactionFailed: %s" % error) except Exception as error: log.error("TransactionFailed with unknown error: %s" % error) error = aptdaemon.errors.TransactionFailed(ERROR_UNKNOWN, str(error)) dia = AptErrorDialog(error) dia.run() dia.hide()
def _on_error(self, error): if self.apt_transaction.error_code == "error-not-authorized": # Silently ignore auth failures self.task.error_message = None # Should already be none, but this is a reminder return elif not isinstance(error, aptdaemon.errors.TransactionFailed): # Catch internal errors of the client error = aptdaemon.errors.TransactionFailed( aptdaemon.enums.ERROR_UNKNOWN, str(error)) if self.task.progress_state != self.task.PROGRESS_STATE_FAILED: self.task.progress_state = self.task.PROGRESS_STATE_FAILED self.task.error_message = self.apt_transaction.error_details dia = AptErrorDialog(error) dia.run() dia.hide() GObject.idle_add(self.task.error_cleanup_cb, self.task)
@post_ui def _on_error(self, error): try: raise error except aptdaemon.errors.NotAuthorizedError: log.debug("aptdaemon.errors.NotAuthorizedError") # Silently ignore auth failures return except aptdaemon.errors.TransactionFailed, error: log.error("TransactionFailed: %s" % error) except Exception, error: log.error("TransactionFailed with unknown error: %s" % error) error = aptdaemon.errors.TransactionFailed(ERROR_UNKNOWN, str(error)) dia = AptErrorDialog(error) dia.run() dia.hide() def update_cache(self, *args): return self.ac.update_cache(reply_handler=self._run_transaction, error_handler=self._on_error) @log_func(log) def install_packages(self, packages, *args): self.ac.install_packages(packages, reply_handler=self._simulate_trans, error_handler=self._on_error) @log_func(log) def remove_packages(self, packages, *args):
class MaintenanceDialog(object): """Retrieve main_dlg.""" def __init__(self, parent): self.pkgs = [] self.apt_client = aptdaemon.client.AptClient() self.builder = Gtk.Builder() self.builder.add_from_file('maintenance.ui') self.builder.connect_signals(self) self.main_dlg = self.builder.get_object('main_dlg') self.main_dlg_tview = self.builder.get_object('main_dlg_tview') self.main_dlg_tstore = self.builder.get_object('main_dlg_tstore') self.main_dlg_lbl_title = self.builder.get_object('main_dlg_lbl_title') self.main_dlg_lbl_space = self.builder.get_object('main_dlg_lbl_space') self.main_dlg_img_lbl = self.builder.get_object('main_dlg_img_lbl') self.main_dlg.set_transient_for(parent) self.main_dlg.set_default_response(Gtk.ResponseType.CANCEL) def populate_treeview(self): """AptDeamon Callbacks.""" tview_pkgs = [] for ppkg in self.pkgs: if ppkg.name.startswith('linux-image'): tview_pkgs.append(ppkg) desc = '<b>%s</b>\n<small>%s (%s)</small>' % ( ppkg.name, ppkg.desc, ppkg.sum) size = '%sB' % apt_pkg.size_to_str(ppkg.size) piter = self.main_dlg_tstore.append(None, [ppkg, None, desc, size, \ Gtk.IconSize.LARGE_TOOLBAR, None, None, False]) for cpkg in ppkg.childs: tview_pkgs.append(cpkg) desc = '<b>%s</b>\n<small>%s (%s)</small>' % ( cpkg.name, cpkg.desc, cpkg.sum) size = '%sB' % apt_pkg.size_to_str(cpkg.size) self.main_dlg_tstore.append(piter, [cpkg, None, desc, size, \ Gtk.IconSize.SMALL_TOOLBAR, None, None, False]) for ppkg in self.pkgs: if ppkg not in tview_pkgs: desc = '<b>%s</b>\n<small>%s (%s)</small>' % ( ppkg.name, ppkg.desc, ppkg.sum) size = '%sB' % apt_pkg.size_to_str(ppkg.size) piter = self.main_dlg_tstore.append(None, [ppkg, None, desc, size, \ Gtk.IconSize.LARGE_TOOLBAR, None, None, False]) def on_reply(self, trans): self.main_dlg.hide() trans.connect('finished', self.on_trans_finished) self.prog_dlg = AptProgressDialog(trans, None, True, False) self.prog_dlg.connect('response', self.on_prog_dlg_response) self.prog_dlg_cancel = self.prog_dlg.get_action_area().get_children( )[0] self.prog_dlg.get_action_area().remove(self.prog_dlg_cancel) self.prog_dlg.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE) self.prog_dlg.set_response_sensitive(Gtk.ResponseType.CLOSE, False) self.prog_dlg.run(False, False, True, lambda: True, self.on_error) def on_error(self, error): try: raise error except aptdaemon.errors.NotAuthorizedError: # Silently ignore auth failures return except aptdaemon.errors.TransactionFailed as error: pass except Exception as error: error = aptdaemon.errors.TransactionFailed(ERROR_UNKNOWN, str(error)) self.error_dlg = AptErrorDialog(error, None) self.error_dlg.set_title('Σφάλμα') self.error_dlg.run() def on_trans_finished(self, trans, status): self.prog_dlg.expander.terminal.show() self.prog_dlg.expander.set_sensitive(True) self.prog_dlg.set_response_sensitive(Gtk.ResponseType.CLOSE, True) def on_prog_dlg_response(self, prog_dlg, response): self.prog_dlg.destroy() self.main_dlg.destroy() def on_main_dlg_pkg_toggle_toggled(self, widget, path): """Callbacks.""" self.main_dlg_tstore[path][5] = not self.main_dlg_tstore[path][5] if not self.main_dlg_tstore[path][5]: self.pkgs.remove(self.main_dlg_tstore[path][0]) for iter in self.main_dlg_tstore[path].iterchildren(): self.pkgs.remove(iter[0]) iter[5] = False else: self.pkgs.append(self.main_dlg_tstore[path][0]) for iter in self.main_dlg_tstore[path].iterchildren(): self.pkgs.append(iter[0]) iter[5] = True if len(self.pkgs) != 0: self.main_dlg.set_response_sensitive(Gtk.ResponseType.OK, True) if len(self.pkgs) == 1: self.main_dlg_lbl_space.set_text( '%d πακέτο έχει επιλέγει, %sB χώρου στο δίσκο θα ελευθερωθούν.' \ %(len(self.pkgs), apt_pkg.size_to_str(sum(pkg.size for pkg in self.pkgs)))) else: self.main_dlg_lbl_space.set_text( '%d πακέτα έχουν επιλέγει, %sB χώρου στο δίσκο θα ελευθερωθούν.' \ %(len(self.pkgs), apt_pkg.size_to_str(sum(pkg.size for pkg in self.pkgs)))) else: self.main_dlg.set_response_sensitive(Gtk.ResponseType.OK, False) self.main_dlg_lbl_space.set_text( 'Δεν έχετε επιλέξει κάποιο πυρήνα προς αφαίρεση.')