-
Notifications
You must be signed in to change notification settings - Fork 83
Add more Pulp Exceptions. #1186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aKlimau
wants to merge
1
commit into
pulp:main
Choose a base branch
from
aKlimau:add-pulp-exceptions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add more Pulp Exceptions. | ||
|
aKlimau marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| from gettext import gettext as _ | ||
|
|
||
| from pulpcore.plugin.exceptions import PulpException | ||
|
|
||
|
|
||
| class ProvenanceVerificationError(PulpException): | ||
| """ | ||
| Raised when provenance verification fails. | ||
| """ | ||
|
|
||
| error_code = "PYT0001" | ||
|
|
||
| def __init__(self, message): | ||
| super().__init__() | ||
| """ | ||
| :param message: Description of the provenance verification error | ||
| :type message: str | ||
| """ | ||
| self.message = message | ||
|
|
||
| def __str__(self): | ||
| return f"[{self.error_code}] " + _("Provenance verification failed: {message}").format( | ||
| message=self.message | ||
| ) | ||
|
|
||
|
|
||
| class AttestationVerificationError(PulpException): | ||
| """ | ||
| Raised when attestation verification fails. | ||
| """ | ||
|
|
||
| error_code = "PYT0002" | ||
|
|
||
| def __init__(self, message): | ||
| super().__init__() | ||
| """ | ||
| :param message: Description of the attestation verification error | ||
| :type message: str | ||
| """ | ||
| self.message = message | ||
|
|
||
| def __str__(self): | ||
| return f"[{self.error_code}] " + _("Attestation verification failed: {message}").format( | ||
| message=self.message | ||
| ) | ||
|
|
||
|
|
||
| class PackageSubstitutionError(PulpException): | ||
| """ | ||
| Raised when packages with the same filename but different checksums are being added. | ||
| """ | ||
|
|
||
| error_code = "PYT0003" | ||
|
|
||
| def __init__(self, duplicates): | ||
| super().__init__() | ||
| """ | ||
| :param duplicates: Description of duplicate packages | ||
| :type duplicates: str | ||
| """ | ||
| self.duplicates = duplicates | ||
|
|
||
| def __str__(self): | ||
| return f"[{self.error_code}] " + _( | ||
| "Found duplicate packages being added with the same filename but different " | ||
| "checksums. To allow this, set 'allow_package_substitution' to True on the " | ||
| "repository. Conflicting packages: {duplicates}" | ||
| ).format(duplicates=self.duplicates) | ||
|
|
||
|
|
||
| class MissingRelativePathError(PulpException): | ||
| """ | ||
| Raised when relative_path field is missing during package upload. | ||
| """ | ||
|
|
||
| error_code = "PYT0005" | ||
|
|
||
| def __str__(self): | ||
| return f"[{self.error_code}] " + _("This field is required: relative_path") | ||
|
|
||
|
|
||
| class InvalidPythonExtensionError(PulpException): | ||
| """ | ||
| Raised when a file has an invalid Python package extension. | ||
| """ | ||
|
|
||
| error_code = "PYT0006" | ||
|
|
||
| def __init__(self, filename): | ||
| super().__init__() | ||
| """ | ||
| :param filename: The filename with invalid extension | ||
| :type filename: str | ||
| """ | ||
| self.filename = filename | ||
|
|
||
| def __str__(self): | ||
| return f"[{self.error_code}] " + _( | ||
| "Extension on {filename} is not a valid python extension " | ||
| "(.whl, .exe, .egg, .tar.gz, .tar.bz2, .zip)" | ||
| ).format(filename=self.filename) | ||
|
|
||
|
|
||
| class InvalidProvenanceError(PulpException): | ||
| """ | ||
| Raised when uploaded provenance data is invalid. | ||
| """ | ||
|
|
||
| error_code = "PYT0007" | ||
|
|
||
| def __init__(self, message): | ||
| super().__init__() | ||
| """ | ||
| :param message: Description of the provenance validation error | ||
| :type message: str | ||
| """ | ||
| self.message = message | ||
|
|
||
| def __str__(self): | ||
| return f"[{self.error_code}] " + _( | ||
| "The uploaded provenance is not valid: {message}" | ||
| ).format(message=self.message) | ||
|
|
||
|
|
||
| class RemoteFetchError(PulpException): | ||
| """ | ||
| Raised when fetching metadata from all remotes fails. | ||
| """ | ||
|
|
||
| error_code = "PYT0008" | ||
|
|
||
| def __init__(self, url): | ||
| super().__init__() | ||
| self.url = url | ||
|
|
||
| def __str__(self): | ||
| return f"[{self.error_code}] " + _("Failed to fetch {url} from any remote.").format( | ||
| url=self.url | ||
| ) | ||
|
|
||
|
|
||
| class InvalidAttestationsError(PulpException): | ||
| """ | ||
| Raised when attestation data cannot be validated. | ||
| """ | ||
|
|
||
| error_code = "PYT0009" | ||
|
|
||
| def __init__(self, message): | ||
| super().__init__() | ||
| self.message = message | ||
|
|
||
| def __str__(self): | ||
| return f"[{self.error_code}] " + _("Invalid attestations: {message}").format( | ||
| message=self.message | ||
| ) | ||
|
|
||
|
|
||
| class BlocklistedPackageError(PulpException): | ||
| """ | ||
| Raised when packages matching a blocklist entry are added to a repository. | ||
| """ | ||
|
|
||
| error_code = "PYT0010" | ||
|
|
||
| def __init__(self, blocked): | ||
| super().__init__() | ||
| self.blocked = blocked | ||
|
|
||
| def __str__(self): | ||
| return f"[{self.error_code}] " + _( | ||
| "Blocklisted packages cannot be added to this repository: {blocked}" | ||
| ).format(blocked=", ".join(self.blocked)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.