Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/nixguix/lister.py
Show All 19 Lines | |||||
from enum import Enum | from enum import Enum | ||||
import logging | import logging | ||||
from pathlib import Path | from pathlib import Path | ||||
import random | import random | ||||
from typing import Any, Dict, Iterator, List, Optional, Tuple, Union | from typing import Any, Dict, Iterator, List, Optional, Tuple, Union | ||||
from urllib.parse import urlparse | from urllib.parse import urlparse | ||||
import requests | import requests | ||||
from requests.exceptions import InvalidSchema, SSLError | from requests.exceptions import ConnectionError, InvalidSchema, SSLError | ||||
from swh.core.github.utils import GitHubSession | from swh.core.github.utils import GitHubSession | ||||
from swh.core.tarball import MIMETYPE_TO_ARCHIVE_FORMAT | from swh.core.tarball import MIMETYPE_TO_ARCHIVE_FORMAT | ||||
from swh.lister import TARBALL_EXTENSIONS | from swh.lister import TARBALL_EXTENSIONS | ||||
from swh.lister.pattern import CredentialsType, StatelessLister | from swh.lister.pattern import CredentialsType, StatelessLister | ||||
from swh.scheduler.model import ListedOrigin | from swh.scheduler.model import ListedOrigin | ||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | except IndexError: | ||||
) | ) | ||||
logger.warning( | logger.warning( | ||||
"Cannot detect extension for <%s>. Fallback to http head query", | "Cannot detect extension for <%s>. Fallback to http head query", | ||||
url, | url, | ||||
) | ) | ||||
try: | try: | ||||
response = request.head(url) | response = request.head(url) | ||||
except (InvalidSchema, SSLError): | except (InvalidSchema, SSLError, ConnectionError): | ||||
raise ArtifactNatureUndetected( | raise ArtifactNatureUndetected( | ||||
f"Cannot determine artifact type from url <{url}>" | f"Cannot determine artifact type from url <{url}>" | ||||
) | ) | ||||
if not response.ok or response.status_code == 404: | if not response.ok or response.status_code == 404: | ||||
raise ArtifactNatureUndetected( | raise ArtifactNatureUndetected( | ||||
f"Cannot determine artifact type from url <{url}>" | f"Cannot determine artifact type from url <{url}>" | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 232 Lines • Show Last 20 Lines |