示例#1
0
    def _connect_to_problems_bus(self):
        # I can't find any description of raised exceptions
        self._bus = dbus.SystemBus(private=True, mainloop=self._mainloop)

        try:
            self._proxy = self._bus.get_object(BUS_NAME, BUS_PATH)
        except dbus.exceptions.DBusException as ex:
            raise errors.UnavailableSource(
                self, False,
                _("Can't connect to DBus system bus '{0}' path '{1}': {2}").
                format(BUS_NAME, BUS_PATH, ex))

        try:
            self._interface = dbus.Interface(self._proxy, BUS_IFACE)
        except dbus.exceptions.DBusException as ex:
            raise errors.UnavailableSource(
                self, False,
                _("Can't get interface '{0}' on path '{1}' in bus '{2}': {3}").
                format(BUS_IFACE, BUS_PATH, BUS_NAME, ex))
示例#2
0
    def on_dbus_exception(self, problem_id, ex):
        """If the authentication fails, a foreign problems source become
        temporary unavailable because we expect that the failure was caused by
        dismissing of the authentication dialog and all problems provided by
        this kind of source require authentication (none of them is available
        now). So, it means that a view can try to query the temporary
        unavailable source later.
        """

        if ex.get_dbus_name() == "org.freedesktop.problems.AuthFailure":
            logging.debug("User dismissed D-Bus authentication")
            raise errors.UnavailableSource(self._source, True)

        if ex.get_dbus_name() == "org.freedesktop.problems.InvalidProblemDir":
            self._source._remove_from_cache(problem_id)
            raise errors.InvalidProblem(problem_id, ex)