Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/tuleap/lister.py
# Copyright (C) 2021 The Software Heritage developers | # Copyright (C) 2021 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import logging | import logging | ||||
from typing import Any, Dict, Iterator, List, Optional | from typing import Any, Dict, Iterator, List, Optional | ||||
from urllib.parse import urljoin | from urllib.parse import urljoin | ||||
import iso8601 | import iso8601 | ||||
import requests | import requests | ||||
from tenacity.before_sleep import before_sleep_log | from tenacity.before_sleep import before_sleep_log | ||||
from urllib3.util import parse_url | |||||
from swh.lister.utils import throttling_retry | from swh.lister.utils import throttling_retry | ||||
from swh.scheduler.interface import SchedulerInterface | from swh.scheduler.interface import SchedulerInterface | ||||
from swh.scheduler.model import ListedOrigin | from swh.scheduler.model import ListedOrigin | ||||
from .. import USER_AGENT | from .. import USER_AGENT | ||||
from ..pattern import CredentialsType, StatelessLister | from ..pattern import CredentialsType, StatelessLister | ||||
Show All 24 Lines | class TuleapLister(StatelessLister[RepoPage]): | ||||
def __init__( | def __init__( | ||||
self, | self, | ||||
scheduler: SchedulerInterface, | scheduler: SchedulerInterface, | ||||
url: str, | url: str, | ||||
instance: Optional[str] = None, | instance: Optional[str] = None, | ||||
credentials: CredentialsType = None, | credentials: CredentialsType = None, | ||||
): | ): | ||||
if instance is None: | |||||
instance = parse_url(url).host | |||||
super().__init__( | super().__init__( | ||||
scheduler=scheduler, credentials=credentials, url=url, instance=instance, | scheduler=scheduler, credentials=credentials, url=url, instance=instance, | ||||
) | ) | ||||
self.session = requests.Session() | self.session = requests.Session() | ||||
self.session.headers.update( | self.session.headers.update( | ||||
{"Accept": "application/json", "User-Agent": USER_AGENT,} | {"Accept": "application/json", "User-Agent": USER_AGENT,} | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |