コード例 #1
0
    def on_dbus_exception(self, problem_id, ex):
        """Process AuthFailure error in same way as InvalidProblemDir because
        this sort of problem source provides all kinds of problems. The user
        problems which should be always accessible and the foreign problems
        which may be inaccessible when a user cancels the authentication
        dialogue. So, an AuthFailure error in this context means that a one
        of many problems is unavailable (something like an invalid problem).
        """

        if ex.get_dbus_name() in [
                "org.freedesktop.problems.AuthFailure",
                "org.freedesktop.problems.InvalidProblemDir"
        ]:
            self._source._remove_from_cache(problem_id)
            raise errors.InvalidProblem(problem_id, 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)
コード例 #3
0
    def get_items(self, problem_id, *args):
        if not args:
            return {}

        dd = report.dd_opendir(problem_id, report.DD_OPEN_READONLY)
        if not dd:
            raise errors.InvalidProblem(
                problem_id, "Can't open directory: '{0}'".format(problem_id))

        items = {}
        for field_name in args:
            value = dd.load_text(
                field_name, report.DD_FAIL_QUIETLY_ENOENT
                | report.DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE)
            if value:
                items[field_name] = value

        dd.close()

        return items