コード例 #1
0
    def exception_handler(self, e):
        """Called if exception occours in methods with the
        @ExceptionHandler decorator.
        """
        close = True
        msg = str(e)
        logger.error('BASE EXCEPTION : %s ' % msg)
        err, errmsg = self._parse_error(msg)
        logger.debug('BASE err:  [%s] - msg: %s' % (err, errmsg))
        if err == 'LockedError':
            errmsg = 'DNF is locked by another process.\n' \
                '\ndnfdragora will exit'
            close = False
        elif err == 'NoReply':
            errmsg = 'DNF D-Bus backend is not responding.\n' \
                '\ndnfdragora will exit'
            close = False
        if errmsg == '':
            errmsg = msg
        dialogs.warningMsgBox({'title': _("Sorry"), "text": errmsg})
        logger.critical(errmsg)

        # try to exit the backends, ignore errors
        if close:
            try:
                self.release_root_backend(quit_dnfdaemon=True)
            except:
                pass

        yui.YDialog.deleteTopmostDialog()
        # next line seems to be a workaround to prevent the qt-app from crashing
        # see https://github.com/libyui/libyui-qt/issues/41
        yui.YUILoader.deleteUI()
        sys.exit(1)
コード例 #2
0
ファイル: basedragora.py プロジェクト: anaselli/dnfdragora
    def exception_handler(self, e):
        """Called if exception occours in methods with the
        @ExceptionHandler decorator.
        """
        close = True
        msg = str(e)
        logger.error('BASE EXCEPTION : %s ' % msg)
        err, errmsg = self._parse_error(msg)
        logger.debug('BASE err:  [%s] - msg: %s' % (err, errmsg))
        if err == 'LockedError':
            errmsg = 'DNF is locked by another process.\n' \
                '\ndnfdragora will exit'
            close = False
        elif err == 'NoReply':
            errmsg = 'DNF D-Bus backend is not responding.\n' \
                '\ndnfdragora will exit'
            close = False
        if errmsg == '':
            errmsg = msg
        dialogs.warningMsgBox({'title' : _("Sorry"), "text": errmsg})
        logger.critical(errmsg)

        # try to exit the backends, ignore errors
        if close:
            try:
                self.release_root_backend(quit_dnfdaemon=True)
            except:
                pass

        yui.YDialog.deleteTopmostDialog()
        # next line seems to be a workaround to prevent the qt-app from crashing
        # see https://github.com/libyui/libyui-qt/issues/41
        yui.YUILoader.deleteUI()
        sys.exit(1)
コード例 #3
0
ファイル: basedragora.py プロジェクト: yurchor/dnfdragora
 def reset_cache(self):
     logger.debug('Refresh system cache')
     self.set_working(True, True)
     self.infobar.info(_('Refreshing Repository Metadata'))
     rc = self._root_backend.ExpireCache()
     self.set_working(False)
     self.infobar.info("")
     if not rc:
         dialogs.warningMsgBox({'title' : _("Sorry"), "text": _('Could not refresh the DNF cache (root)')})
コード例 #4
0
    def __run_dialog(self, args, *kwargs):
        if self.__tray != None and self.__main_gui == None:
            time.sleep(0.5)
            try:
                self.__main_gui = ui.mainGui(args)
            except Exception as e:
                dialogs.warningMsgBox({'title' : _("Running dnfdragora failure"), "text": str(e), "richtext":True}) 
                yui.YDialog.deleteAllDialogs()
                time.sleep(0.5)
                self.__main_gui = None
                return
            self.__tray.icon = None
            self.__main_gui.handleevent()

            while self.__main_gui.loop_has_finished != True:
                time.sleep(1)
            yui.YDialog.deleteAllDialogs()
            time.sleep(1)
            self.__main_gui = None
            self.__get_updates()
コード例 #5
0
    def __run_dialog(self, args, *kwargs):
        if self.__tray != None and self.__main_gui == None and self.__tray.visible:
            if self.__hide_menu:
                self.__tray.visible = False
            time.sleep(0.5)
            try:
                self.__main_gui = ui.mainGui(args)
            except Exception as e:
                logger.error(
                    "Exception on running dnfdragora with args %s - %s",
                    str(args), str(e))
                dialogs.warningMsgBox({
                    'title': _("Running dnfdragora failure"),
                    "text": str(e),
                    "richtext": True
                })
                yui.YDialog.deleteAllDialogs()
                time.sleep(0.5)
                self.__main_gui = None
                return
            #self.__tray.icon = None
            self.__main_gui.handleevent()

            logger.debug("Closing dnfdragora")
            while self.__main_gui.loop_has_finished != True:
                time.sleep(1)
            logger.info("Closed dnfdragora")
            yui.YDialog.deleteAllDialogs()
            time.sleep(1)
            self.__main_gui = None
            logger.debug("Look for remaining updates")
            # Let's delay a bit the check, otherwise Lock will fail
            done = self.__reschedule_update_in(0.5)
            logger.debug("Scheduled %s", "done" if done else "skipped")
        else:
            if self.__main_gui:
                logger.warning(
                    "Cannot run dnfdragora because it is already running")
            else:
                logger.warning("Cannot run dnfdragora")
コード例 #6
0
ファイル: basedragora.py プロジェクト: yurchor/dnfdragora
    def get_root_backend(self):
        """Get the current root backend.

        if it is not setup yet, the create it
        if it is not locked, then lock it
        """
        if self._root_backend is None:
            self._root_backend = dnfdragora.dnf_backend.DnfRootBackend(self, self._use_comps)
        if self._root_locked is False:
            logger.debug('Lock the DNF root daemon')
            locked, msg = self._root_backend.setup()
            if locked:
                self._root_locked = True
                #if self._check_cache_expired('system'):
                #    self.reset_cache()
                self.backend.ExpireCache()
                logger.info("Locked the DNF root daemon")
            else:
                logger.critical("can't get root backend lock")
                if msg == 'not-authorized':  # user canceled the polkit dialog
                    errmsg = _(
                        'DNF root backend was not authorized.\n'
                        'dnfdragora will exit')
                # DNF is locked by another process
                elif msg == 'locked-by-other':
                    errmsg = _(
                        'DNF is locked by another process.\n\n'
                        'dnfdragora will exit')
                logger.critical(errmsg)
                dialogs.warningMsgBox({'title' : _("Sorry"), "text": errmsg})
                yui.YDialog.deleteTopmostDialog()
                # next line seems to be a workaround to prevent the qt-app from crashing
                # see https://github.com/libyui/libyui-qt/issues/41
                yui.YUILoader.deleteUI()
                sys.exit(1)
        return self._root_backend