Mass Update
* Util Module
* Provides: color class (for specialty stdout logging)
* Provides: constants classes for rpm, errors, and mock
* Provides: error classes for generic error handling and future fault
handler
* Provides: generic classes for generic, repeatable use cases
* Provides: rpmutil with rpm utilities that range from basic to
advanced metadata handling
* Add mock module
* Can generate a usable mock config based on input provided
* Can generate mock plugin configuration as provided
* cache related plugins are hardcoded as disabled
* Supports plugins: chroot scanning, embedding files, bind mounts
* Can generate basic dnf configs with repo information
* (Currently limited) Error handler
* Runs mock commands (such as build, buildsrpm, init, shell)
* Add modularity module (very limited, doesn't really do much)
* Add peridotpb example (does nothing, will likely be its own thing)
* Add MIT license
2023-06-14 07:39:36 +00:00
|
|
|
# -*-:python; coding:utf-8; -*-
|
|
|
|
# author: Louis Abel <label@rockylinux.org>
|
|
|
|
"""
|
|
|
|
Generic Error Classes
|
|
|
|
"""
|
|
|
|
|
|
|
|
# needed imports
|
|
|
|
from pv2.util.constants import ErrorConstants as errconst
|
|
|
|
|
|
|
|
# list every error class that's enabled
|
|
|
|
|
|
|
|
__all__ = [
|
|
|
|
'GenericError',
|
|
|
|
'ProvidedValueError',
|
|
|
|
'ExistsValueError',
|
|
|
|
'MissingValueError',
|
|
|
|
'ConfigurationError',
|
|
|
|
'FileNotFound',
|
|
|
|
'MockGenericError',
|
|
|
|
'MockUnexpectedError',
|
|
|
|
'MockInvalidConfError',
|
|
|
|
'MockInvalidArchError',
|
|
|
|
'MockDnfError',
|
|
|
|
'MockResultdirError',
|
|
|
|
'MockSignalReceivedError',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# todo: find a way to logically use fault_code
|
|
|
|
class GenericError(Exception):
|
|
|
|
"""
|
|
|
|
Custom exceptions entrypoint
|
|
|
|
"""
|
|
|
|
fault_code = errconst.ERR_GENERAL
|
|
|
|
from_fault = False
|
|
|
|
def __str__(self):
|
|
|
|
try:
|
|
|
|
return str(self.args[0]['args'][0])
|
|
|
|
# pylint: disable=broad-exception-caught
|
|
|
|
except Exception:
|
|
|
|
try:
|
|
|
|
return str(self.args[0])
|
|
|
|
# pylint: disable=broad-exception-caught
|
|
|
|
except Exception:
|
|
|
|
return str(self.__dict__)
|
|
|
|
|
|
|
|
# Starting at this point is every error class that pv2 will deal with.
|
|
|
|
class ProvidedValueError(GenericError):
|
|
|
|
"""
|
|
|
|
What it says on the tin
|
|
|
|
"""
|
|
|
|
fault_code = errconst.ERR_PROVIDED_VALUE
|
|
|
|
|
|
|
|
class ExistsValueError(GenericError):
|
|
|
|
"""
|
|
|
|
Value being requested already exists
|
|
|
|
"""
|
|
|
|
fault_code = errconst.ERR_VALUE_EXISTS
|
|
|
|
|
|
|
|
class MissingValueError(GenericError):
|
|
|
|
"""
|
|
|
|
Value being requested already exists
|
|
|
|
"""
|
|
|
|
fault_code = errconst.ERR_MISSING_VALUE
|
|
|
|
|
|
|
|
class ConfigurationError(GenericError):
|
|
|
|
"""
|
|
|
|
Value being requested already exists
|
|
|
|
"""
|
|
|
|
fault_code = errconst.ERR_CONFIGURATION
|
|
|
|
|
|
|
|
class FileNotFound(GenericError):
|
|
|
|
"""
|
|
|
|
Value being requested already exists
|
|
|
|
"""
|
|
|
|
fault_code = errconst.ERR_NOTFOUND
|
|
|
|
|
|
|
|
class MockGenericError(GenericError):
|
|
|
|
"""
|
|
|
|
Mock error exceptions
|
|
|
|
"""
|
|
|
|
fault_code = errconst.MOCK_ERR_GENERIC
|
|
|
|
|
|
|
|
class MockUnexpectedError(MockGenericError):
|
|
|
|
"""
|
|
|
|
Mock (or the environment) experienced an unexpected error.
|
|
|
|
"""
|
|
|
|
fault_code = errconst.MOCK_ERR_UNEXPECTED
|
|
|
|
|
|
|
|
class MockInvalidConfError(MockGenericError):
|
|
|
|
"""
|
|
|
|
Mock (or the environment) experienced an error with the conf.
|
|
|
|
"""
|
|
|
|
fault_code = errconst.MOCK_ERR_CONF_INVALID
|
|
|
|
|
|
|
|
class MockInvalidArchError(MockGenericError):
|
|
|
|
"""
|
|
|
|
Mock (or the environment) didn't like the arch
|
|
|
|
"""
|
|
|
|
fault_code = errconst.MOCK_ERR_ARCH_EXCLUDED
|
|
|
|
|
|
|
|
class MockDnfError(MockGenericError):
|
|
|
|
"""
|
|
|
|
Mock (or the environment) had some kind of dnf error
|
|
|
|
"""
|
|
|
|
fault_code = errconst.MOCK_ERR_DNF_ERROR
|
|
|
|
|
|
|
|
class MockResultdirError(MockGenericError):
|
|
|
|
"""
|
|
|
|
Mock (or the environment) had some kind of error in the resultdir
|
|
|
|
"""
|
|
|
|
fault_code = errconst.MOCK_ERR_RESULTDIR_GENERIC
|
|
|
|
|
|
|
|
class MockSignalReceivedError(MockGenericError):
|
|
|
|
"""
|
|
|
|
Mock had a SIG received
|
|
|
|
"""
|
|
|
|
fault_code = errconst.MOCK_ERR_BUILD_HUP
|
2023-06-28 00:20:44 +00:00
|
|
|
|
|
|
|
class GitCommitError(GenericError):
|
|
|
|
"""
|
|
|
|
There was an issue pushing to git
|
|
|
|
"""
|
|
|
|
fault_code = errconst.GIT_ERR_COMMIT
|
|
|
|
|
|
|
|
class GitPushError(GenericError):
|
|
|
|
"""
|
|
|
|
There was an issue pushing to git
|
|
|
|
"""
|
|
|
|
fault_code = errconst.GIT_ERR_PUSH
|
|
|
|
|
|
|
|
class GitInitError(GenericError):
|
|
|
|
"""
|
|
|
|
There was an issue pushing to git
|
|
|
|
"""
|
|
|
|
fault_code = errconst.GIT_ERR_INIT
|
|
|
|
|
|
|
|
class GitCheckoutError(GenericError):
|
|
|
|
"""
|
|
|
|
There was an issue pushing to git
|
|
|
|
"""
|
|
|
|
fault_code = errconst.GIT_ERR_CHECKOUT
|
|
|
|
|
|
|
|
class RpmOpenError(GenericError):
|
|
|
|
"""
|
|
|
|
There was an issue opening the RPM
|
|
|
|
"""
|
|
|
|
fault_code = errconst.RPM_ERR_OPEN
|
|
|
|
|
|
|
|
class RpmSigError(GenericError):
|
|
|
|
"""
|
|
|
|
There was an issue opening the RPM because the signature could not be
|
|
|
|
verified
|
|
|
|
"""
|
|
|
|
fault_code = errconst.RPM_ERR_SIG
|
|
|
|
|
|
|
|
class RpmInfoError(GenericError):
|
|
|
|
"""
|
|
|
|
There was an issue opening the RPM because the signature could not be
|
|
|
|
verified
|
|
|
|
"""
|
|
|
|
fault_code = errconst.RPM_ERR_INFO
|