Source code for ucsschool.importer.exceptions

#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Univention UCS@school
# Copyright 2016-2021 Univention GmbH
#
# https://www.univention.de/
#
# All rights reserved.
#
# The source code of this program is made available
# under the terms of the GNU Affero General Public License version 3
# (GNU AGPL V3) as published by the Free Software Foundation.
#
# Binary versions of this program provided by Univention to you as
# well as other copyrighted, protected or trademarked materials like
# Logos, graphics, fonts, specific documentations and configurations,
# cryptographic keys etc. are subject to a license agreement between
# you and Univention and not subject to the GNU AGPL V3.
#
# In the case you use this program under the terms of the GNU AGPL V3,
# the program is provided in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <http://www.gnu.org/licenses/>.

"""
All exceptions raised by code in ucsschool.importer.
"""


[docs]class UcsSchoolImportError(Exception): is_fatal = False # If is_countable is set to False, the exception is displayed to # the user, but is not included in the evaluation of tolerate_errors. is_countable = True def __init__(self, *args, **kwargs): self.entry_count = kwargs.pop("entry_count", 0) self.input = kwargs.pop("input", None) self.import_user = kwargs.pop("import_user", None) super(UcsSchoolImportError, self).__init__(*args, **kwargs)
[docs]class UcsSchoolImportFatalError(UcsSchoolImportError): is_fatal = True
[docs]class UcsSchoolImportSkipImportRecord(UcsSchoolImportError): is_countable = False
[docs]class BadPassword(UcsSchoolImportError): pass
[docs]class BadValueStored(UcsSchoolImportFatalError): pass
[docs]class ConfigurationError(UcsSchoolImportFatalError): pass
[docs]class CreationError(UcsSchoolImportError): pass
[docs]class DeletionError(UcsSchoolImportError): pass
[docs]class FormatError(UcsSchoolImportError): def __init__(self, msg, scheme, data, *args, **kwargs): super(FormatError, self).__init__(msg, *args, **kwargs) self.scheme = scheme self.data = data
[docs]class EmptyFormatResultError(FormatError): pass
[docs]class EmptyMandatoryAttribute(UcsSchoolImportError): def __init__(self, msg, attr_name, *args, **kwargs): super(EmptyMandatoryAttribute, self).__init__(msg, *args, **kwargs) self.attr_name = attr_name
[docs]class InitialisationError(UcsSchoolImportFatalError): def __init__(self, msg, log_traceback=True, *args, **kwargs): super(InitialisationError, self).__init__(msg, *args, **kwargs) self.log_traceback = log_traceback
[docs]class InvalidBirthday(UcsSchoolImportError): pass
[docs]class InvalidClassName(UcsSchoolImportError): pass
[docs]class InvalidEmail(UcsSchoolImportError): pass
[docs]class InvalidSchoolClasses(UcsSchoolImportError): pass
[docs]class InvalidSchools(UcsSchoolImportError): pass
[docs]class LDAPWriteAccessDenied(UcsSchoolImportFatalError): def __init__(self, msg=None, *args, **kwargs): msg = msg or "Tried to write using a read only connection (during a dry-run?)." super(LDAPWriteAccessDenied, self).__init__(msg, *args, **kwargs)
[docs]class MissingMandatoryAttribute(UcsSchoolImportError): def __init__(self, msg, mandatory_attributes, *args, **kwargs): super(MissingMandatoryAttribute, self).__init__(msg, *args, **kwargs) self.mandatory_attributes = mandatory_attributes
[docs]class MissingMailDomain(UcsSchoolImportError): pass
[docs]class MissingSchoolName(UcsSchoolImportError): pass
[docs]class MissingUid(UcsSchoolImportError): pass
[docs]class ModificationError(UcsSchoolImportError): pass
[docs]class MoveError(UcsSchoolImportError): pass
[docs]class NameKeyExists(UcsSchoolImportFatalError): pass
[docs]class NoRole(UcsSchoolImportError): pass
[docs]class NotSupportedError(UcsSchoolImportError): pass
[docs]class NoUsernameAtAll(UcsSchoolImportFatalError): pass
[docs]class NoValueStored(UcsSchoolImportFatalError): pass
[docs]class ReadOnlyConfiguration(UcsSchoolImportFatalError): def __init__(self, *args, **kwargs): super(ReadOnlyConfiguration, self).__init__( "Changing the configuration is not allowed.", *args, **kwargs )
[docs]class TooManyErrors(UcsSchoolImportFatalError): def __init__(self, msg, errors, *args, **kwargs): super(TooManyErrors, self).__init__(msg, *args, **kwargs) self.errors = errors
[docs]class UDMError(UcsSchoolImportError): pass
[docs]class UDMValueError(UDMError): pass
[docs]class UnknownAction(UcsSchoolImportError): pass
[docs]class UnknownDisabledSetting(UcsSchoolImportError): pass
[docs]class UnknownProperty(UcsSchoolImportError): pass
[docs]class UnknownRole(UcsSchoolImportError): pass
[docs]class UnknownSchoolName(UcsSchoolImportError): pass
[docs]class UniqueIdError(UcsSchoolImportError): pass
[docs]class UsernameToLong(UcsSchoolImportError): pass
[docs]class UserValidationError(UcsSchoolImportError): """ Wraps ucsschool.lib.models.attributes.ValidationError """ def __init__(self, msg, validation_error, *args, **kwargs): super(UserValidationError, self).__init__(msg, *args, **kwargs) self.validation_error = validation_error def __str__(self): return "{} {!r}".format(self, self.validation_error)
[docs]class WrongUserType(UcsSchoolImportError): """Wraps ucsschool.lib.models.base.WrongObjectType""" def __init__(self, msg, *args, **kwargs): super(WrongUserType, self).__init__(msg, *args, **kwargs)