Exemple #1
0
    def _get_resource(self, url):
        try:
            r = get_session("hgmo").get(url)
        except requests.exceptions.RetryError as e:
            raise PushNotFound(f"{e} error when getting {url}", **self.context)

        if r.status_code == 404:
            raise PushNotFound(f"{r.status_code} response from {url}", **self.context)

        r.raise_for_status()
        return r.json()
Exemple #2
0
    def _get_resource(cls, url, context=None):
        context = context or getattr(cls, "context", {})
        context.setdefault("branch", "unknown branch")
        context.setdefault("rev", "unknown")

        try:
            r = get_session().get(url)
        except requests.exceptions.RetryError as e:
            raise PushNotFound(f"{e} error when getting {url}", **context)

        if not r.ok:
            raise PushNotFound(f"{r.status_code} response from {url}",
                               **context)

        return r.json()
Exemple #3
0
    def _get_resource(self, url):
        r = get_session("hgmo").get(url)

        if r.status_code == 404:
            raise PushNotFound(**self.context)

        r.raise_for_status()
        return r.json()
Exemple #4
0
    def load_json_push(branch: str, push_id: int) -> HgPush:
        if push_id not in HgRev.JSON_PUSHES_CACHE:
            url = HgRev.JSON_PUSHES_TEMPLATE.format(
                push_id_start=push_id - 1,
                push_id_end=push_id,
                branch=f"integration/{branch}"
                if branch == "autoland" else branch,
            )
            HgRev._get_and_cache_pushes(branch, url)

        if push_id not in HgRev.JSON_PUSHES_CACHE:
            raise PushNotFound(f"push id {push_id} does not exist",
                               rev="unknown",
                               branch=branch)
        return HgRev.JSON_PUSHES_CACHE[push_id]
Exemple #5
0
    def create_push(self, push_id):
        result = self._hgmo.json_pushes(push_id_start=push_id - 1,
                                        push_id_end=push_id)
        if str(push_id) not in result:
            raise PushNotFound(f"push id {push_id} does not exist",
                               rev=self.rev,
                               branch=self.branch)

        result = result[str(push_id)]
        push = Push(result["changesets"][::-1], branch=self.branch)
        # avoids the need to query hgmo to find this info
        push._id = push_id
        push._date = result["date"]

        return push