Example #1
0
    def get(self, cname):
        # return list of mirrors
        errors = self._check_cname(cname)
        if errors:
            return response.unprocessable_entity(errors=errors)

        mirrors_cached = self.cache_get("mirrors")
        if mirrors_cached is None:
            return response.not_found("No cache for mirrors.")

        if cname is None:
            targets = mirrors_cached.values()
            targets_sorted = sorted(targets, key=lambda d: d["cname"])
            return response.with_targets(targets_sorted)
        else:
            if cname not in mirrors_cached.keys():
                return response.not_found("No such resource.")

            return response.with_target(mirrors_cached[cname])
Example #2
0
    def get(self, notice_id):
        errors = self._check_notice_id(notice_id)
        if errors:
            return response.unprocessable_entity(errors=errors)

        notices_cached = self.cache_get("notices")
        if notices_cached is None:
            return response.not_found("No cache for notices.")

        notices_activated = [n for n in notices_cached.values() if not n["is_muted"]]
        return response.with_targets(notices_activated)