|
Packit Service |
21c75c |
# This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
21c75c |
# it under the terms of the GNU General Public License as published by
|
|
Packit Service |
21c75c |
# the Free Software Foundation; either version 2 of the License, or
|
|
Packit Service |
21c75c |
# (at your option) any later version.
|
|
Packit Service |
21c75c |
#
|
|
Packit Service |
21c75c |
# This program is distributed in the hope that it will be useful,
|
|
Packit Service |
21c75c |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
21c75c |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
21c75c |
# GNU Library General Public License for more details.
|
|
Packit Service |
21c75c |
#
|
|
Packit Service |
21c75c |
# You should have received a copy of the GNU General Public License
|
|
Packit Service |
21c75c |
# along with this program; if not, write to the Free Software
|
|
Packit Service |
21c75c |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
Packit Service |
21c75c |
# Copyright 2004 Duke University
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""
|
|
Packit Service |
21c75c |
Core DNF Errors.
|
|
Packit Service |
21c75c |
"""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
from __future__ import unicode_literals
|
|
Packit Service |
21c75c |
from dnf.i18n import ucd, _, P_
|
|
Packit Service |
21c75c |
import dnf.util
|
|
Packit Service |
21c75c |
import libdnf
|
|
Packit Service |
21c75c |
import warnings
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class DeprecationWarning(DeprecationWarning):
|
|
Packit Service |
21c75c |
# :api
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class Error(Exception):
|
|
Packit Service |
21c75c |
# :api
|
|
Packit Service |
21c75c |
"""Base Error. All other Errors thrown by DNF should inherit from this.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
:api
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""
|
|
Packit Service |
21c75c |
def __init__(self, value=None):
|
|
Packit Service |
21c75c |
super(Error, self).__init__()
|
|
Packit Service |
21c75c |
self.value = None if value is None else ucd(value)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def __str__(self):
|
|
Packit Service |
21c75c |
return "{}".format(self.value)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def __unicode__(self):
|
|
Packit Service |
21c75c |
return ucd(self.__str__())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class CompsError(Error):
|
|
Packit Service |
21c75c |
# :api
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class ConfigError(Error):
|
|
Packit Service |
21c75c |
def __init__(self, value=None, raw_error=None):
|
|
Packit Service |
21c75c |
super(ConfigError, self).__init__(value)
|
|
Packit Service |
21c75c |
self.raw_error = ucd(raw_error) if raw_error is not None else None
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class DatabaseError(Error):
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class DepsolveError(Error):
|
|
Packit Service |
21c75c |
# :api
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class DownloadError(Error):
|
|
Packit Service |
21c75c |
# :api
|
|
Packit Service |
21c75c |
def __init__(self, errmap):
|
|
Packit Service |
21c75c |
super(DownloadError, self).__init__()
|
|
Packit Service |
21c75c |
self.errmap = errmap
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@staticmethod
|
|
Packit Service |
21c75c |
def errmap2str(errmap):
|
|
Packit Service |
21c75c |
errstrings = []
|
|
Packit Service |
21c75c |
for key in errmap:
|
|
Packit Service |
21c75c |
for error in errmap[key]:
|
|
Packit Service |
21c75c |
msg = '%s: %s' % (key, error) if key else '%s' % error
|
|
Packit Service |
21c75c |
errstrings.append(msg)
|
|
Packit Service |
21c75c |
return '\n'.join(errstrings)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def __str__(self):
|
|
Packit Service |
21c75c |
return self.errmap2str(self.errmap)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class LockError(Error):
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class MarkingError(Error):
|
|
Packit Service |
21c75c |
# :api
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def __init__(self, value=None, pkg_spec=None):
|
|
Packit Service |
21c75c |
"""Initialize the marking error instance."""
|
|
Packit Service |
21c75c |
super(MarkingError, self).__init__(value)
|
|
Packit Service |
21c75c |
self.pkg_spec = None if pkg_spec is None else ucd(pkg_spec)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def __str__(self):
|
|
Packit Service |
21c75c |
string = super(MarkingError, self).__str__()
|
|
Packit Service |
21c75c |
if self.pkg_spec:
|
|
Packit Service |
21c75c |
string += ': ' + self.pkg_spec
|
|
Packit Service |
21c75c |
return string
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class MarkingErrors(Error):
|
|
Packit Service |
21c75c |
# :api
|
|
Packit Service |
21c75c |
def __init__(self, no_match_group_specs=(), error_group_specs=(), no_match_pkg_specs=(),
|
|
Packit Service |
21c75c |
error_pkg_specs=(), module_depsolv_errors=()):
|
|
Packit Service |
21c75c |
"""Initialize the marking error instance."""
|
|
Packit Service |
21c75c |
msg = _("Problems in request:")
|
|
Packit Service |
21c75c |
if (no_match_pkg_specs):
|
|
Packit Service |
21c75c |
msg += "\n" + _("missing packages: ") + ", ".join(no_match_pkg_specs)
|
|
Packit Service |
21c75c |
if (error_pkg_specs):
|
|
Packit Service |
21c75c |
msg += "\n" + _("broken packages: ") + ", ".join(error_pkg_specs)
|
|
Packit Service |
21c75c |
if (no_match_group_specs):
|
|
Packit Service |
21c75c |
msg += "\n" + _("missing groups or modules: ") + ", ".join(no_match_group_specs)
|
|
Packit Service |
21c75c |
if (error_group_specs):
|
|
Packit Service |
21c75c |
msg += "\n" + _("broken groups or modules: ") + ", ".join(error_group_specs)
|
|
Packit Service |
21c75c |
if (module_depsolv_errors):
|
|
Packit Service |
21c75c |
msg_mod = dnf.util._format_resolve_problems(module_depsolv_errors[0])
|
|
Packit Service |
21c75c |
if module_depsolv_errors[1] == \
|
|
Packit Service |
21c75c |
libdnf.module.ModulePackageContainer.ModuleErrorType_ERROR_IN_DEFAULTS:
|
|
Packit Service |
21c75c |
msg += "\n" + "\n".join([P_('Modular dependency problem with Defaults:',
|
|
Packit Service |
21c75c |
'Modular dependency problems with Defaults:',
|
|
Packit Service |
21c75c |
len(module_depsolv_errors)),
|
|
Packit Service |
21c75c |
msg_mod])
|
|
Packit Service |
21c75c |
else:
|
|
Packit Service |
21c75c |
msg += "\n" + "\n".join([P_('Modular dependency problem:',
|
|
Packit Service |
21c75c |
'Modular dependency problems:',
|
|
Packit Service |
21c75c |
len(module_depsolv_errors)),
|
|
Packit Service |
21c75c |
msg_mod])
|
|
Packit Service |
21c75c |
super(MarkingErrors, self).__init__(msg)
|
|
Packit Service |
21c75c |
self.no_match_group_specs = no_match_group_specs
|
|
Packit Service |
21c75c |
self.error_group_specs = error_group_specs
|
|
Packit Service |
21c75c |
self.no_match_pkg_specs = no_match_pkg_specs
|
|
Packit Service |
21c75c |
self.error_pkg_specs = error_pkg_specs
|
|
Packit Service |
21c75c |
self.module_depsolv_errors = module_depsolv_errors
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@property
|
|
Packit Service |
21c75c |
def module_debsolv_errors(self):
|
|
Packit Service |
21c75c |
msg = "Attribute module_debsolv_errors is deprecated. Use module_depsolv_errors " \
|
|
Packit Service |
21c75c |
"attribute instead."
|
|
Packit Service |
21c75c |
warnings.warn(msg, DeprecationWarning, stacklevel=2)
|
|
Packit Service |
21c75c |
return self.module_depsolv_errors
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class MetadataError(Error):
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class MiscError(Error):
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class PackagesNotAvailableError(MarkingError):
|
|
Packit Service |
21c75c |
def __init__(self, value=None, pkg_spec=None, packages=None):
|
|
Packit Service |
21c75c |
super(PackagesNotAvailableError, self).__init__(value, pkg_spec)
|
|
Packit Service |
21c75c |
self.packages = packages or []
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class PackageNotFoundError(MarkingError):
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class PackagesNotInstalledError(MarkingError):
|
|
Packit Service |
21c75c |
def __init__(self, value=None, pkg_spec=None, packages=None):
|
|
Packit Service |
21c75c |
super(PackagesNotInstalledError, self).__init__(value, pkg_spec)
|
|
Packit Service |
21c75c |
self.packages = packages or []
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class ProcessLockError(LockError):
|
|
Packit Service |
21c75c |
def __init__(self, value, pid):
|
|
Packit Service |
21c75c |
super(ProcessLockError, self).__init__(value)
|
|
Packit Service |
21c75c |
self.pid = pid
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def __reduce__(self):
|
|
Packit Service |
21c75c |
"""Pickling support."""
|
|
Packit Service |
21c75c |
return (ProcessLockError, (self.value, self.pid))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class RepoError(Error):
|
|
Packit Service |
21c75c |
# :api
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class ThreadLockError(LockError):
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class TransactionCheckError(Error):
|
|
Packit Service |
21c75c |
pass
|