|
1 | 1 | import asyncio |
2 | 2 | import logging |
3 | 3 | from functools import partial |
4 | | -from gettext import gettext as _ |
5 | 4 | from urllib.parse import urljoin |
6 | 5 |
|
7 | 6 | from aiohttp import ClientError, ClientResponseError |
|
12 | 11 | from packaging.requirements import Requirement |
13 | 12 | from pypi_attestations import Provenance |
14 | 13 | from pypi_simple import IndexPage |
15 | | -from rest_framework import serializers |
16 | 14 |
|
17 | 15 | from pulpcore.plugin.download import HttpDownloader |
| 16 | +from pulpcore.plugin.exceptions import SyncError |
18 | 17 | from pulpcore.plugin.models import Artifact, ProgressReport, Remote, Repository |
19 | 18 | from pulpcore.plugin.stages import ( |
20 | 19 | DeclarativeArtifact, |
|
23 | 22 | Stage, |
24 | 23 | ) |
25 | 24 |
|
| 25 | +from pulp_python.app.exceptions import UnsupportedProtocolError |
26 | 26 | from pulp_python.app.models import ( |
27 | 27 | PackageProvenance, |
28 | 28 | PythonPackageContent, |
@@ -52,7 +52,7 @@ def sync(remote_pk, repository_pk, mirror): |
52 | 52 | repository = Repository.objects.get(pk=repository_pk) |
53 | 53 |
|
54 | 54 | if not remote.url: |
55 | | - raise serializers.ValidationError(detail=_("A remote must have a url attribute to sync.")) |
| 55 | + raise SyncError("A remote must have a url attribute to sync.") |
56 | 56 |
|
57 | 57 | first_stage = PythonBanderStage(remote) |
58 | 58 | DeclarativeVersion(first_stage, repository, mirror).create() |
@@ -115,7 +115,8 @@ async def run(self): |
115 | 115 | url = self.remote.url.rstrip("/") |
116 | 116 | downloader = self.remote.get_downloader(url=url) |
117 | 117 | if not isinstance(downloader, HttpDownloader): |
118 | | - raise ValueError("Only HTTP(S) is supported for python syncing") |
| 118 | + protocol = type(downloader).__name__ |
| 119 | + raise UnsupportedProtocolError(protocol) |
119 | 120 |
|
120 | 121 | async with Master(url, allow_non_https=True) as master: |
121 | 122 | # Replace the session with the remote's downloader session |
|
0 commit comments