Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/loader.py
Show All 23 Lines | from typing import ( | ||||
TypeVar, | TypeVar, | ||||
) | ) | ||||
import attr | import attr | ||||
import sentry_sdk | import sentry_sdk | ||||
from swh.core.config import load_from_envvar | from swh.core.config import load_from_envvar | ||||
from swh.core.tarball import uncompress | from swh.core.tarball import uncompress | ||||
from swh.loader.exception import NotFound | |||||
from swh.loader.package.utils import download | from swh.loader.package.utils import download | ||||
from swh.model import from_disk | from swh.model import from_disk | ||||
from swh.model.collections import ImmutableDict | from swh.model.collections import ImmutableDict | ||||
from swh.model.hashutil import hash_to_hex | from swh.model.hashutil import hash_to_hex | ||||
from swh.model.identifiers import SWHID | from swh.model.identifiers import SWHID | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
MetadataAuthority, | MetadataAuthority, | ||||
MetadataAuthorityType, | MetadataAuthorityType, | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | def _check_configuration(self): | ||||
""" | """ | ||||
if "storage" not in self.config: | if "storage" not in self.config: | ||||
raise ValueError("Misconfiguration, at least the storage key should be set") | raise ValueError("Misconfiguration, at least the storage key should be set") | ||||
def get_versions(self) -> Sequence[str]: | def get_versions(self) -> Sequence[str]: | ||||
"""Return the list of all published package versions. | """Return the list of all published package versions. | ||||
Raises: | |||||
`class:swh.loader.exception.NotFound` error when failing to read the | |||||
published package versions. | |||||
Returns: | Returns: | ||||
Sequence of published versions | Sequence of published versions | ||||
""" | """ | ||||
return [] | return [] | ||||
def get_package_info(self, version: str) -> Iterator[Tuple[str, TPackageInfo]]: | def get_package_info(self, version: str) -> Iterator[Tuple[str, TPackageInfo]]: | ||||
"""Given a release version of a package, retrieve the associated | """Given a release version of a package, retrieve the associated | ||||
▲ Show 20 Lines • Show All 240 Lines • ▼ Show 20 Lines | def load(self) -> Dict: | ||||
logger.exception("Failed to get previous state for %s", self.url) | logger.exception("Failed to get previous state for %s", self.url) | ||||
sentry_sdk.capture_exception(e) | sentry_sdk.capture_exception(e) | ||||
status_visit = "failed" | status_visit = "failed" | ||||
status_load = "failed" | status_load = "failed" | ||||
return finalize_visit() | return finalize_visit() | ||||
load_exceptions: List[Exception] = [] | load_exceptions: List[Exception] = [] | ||||
for version in self.get_versions(): # for each | try: | ||||
versions = self.get_versions() | |||||
except NotFound: | |||||
status_visit = "not_found" | |||||
status_load = "failed" | |||||
return finalize_visit() | |||||
except Exception: | |||||
status_visit = "failed" | |||||
status_load = "failed" | |||||
vlorentz: Why just ValueError? | |||||
return finalize_visit() | |||||
for version in versions: | |||||
logger.debug("version: %s", version) | logger.debug("version: %s", version) | ||||
tmp_revisions[version] = [] | tmp_revisions[version] = [] | ||||
# `p_` stands for `package_` | # `p_` stands for `package_` | ||||
for branch_name, p_info in self.get_package_info(version): | for branch_name, p_info in self.get_package_info(version): | ||||
logger.debug("package_info: %s", p_info) | logger.debug("package_info: %s", p_info) | ||||
revision_id = self.resolve_revision_from(known_artifacts, p_info) | revision_id = self.resolve_revision_from(known_artifacts, p_info) | ||||
if revision_id is None: | if revision_id is None: | ||||
try: | try: | ||||
▲ Show 20 Lines • Show All 379 Lines • Show Last 20 Lines |
Why just ValueError?