# Path: katprep/management/base.py
# class BaseConnector(metaclass=ABCMeta):
#     """
#     Basic management connector that connects on creation.
#     """
# 
#     def __init__(self, username, password, **kwargs):
#         self._username = username
#         self._password = password
#         self._session = None
#         self._connect()
# 
#     @abstractmethod
#     def _connect(self):
#         pass
# 
# Path: katprep/exceptions.py
# class APILevelNotSupportedException(Exception):
#     """
#     Dummy class for unsupported API levels
# 
#     .. class:: APILevelNotSupportedException
#     """
# 
# class InvalidCredentialsException(Exception):
#     """
#     Dummy class for invalid credentials
# 
#     .. class:: InvalidCredentialsException
#     """
# 
# class SessionException(Exception):
#     """
#     Dummy class for session errors
# 
#     .. class:: SessionException
#     """


import logging
from .base import BaseConnector
from ..exceptions import (APILevelNotSupportedException, InvalidCredentialsException,
                         SessionException)
    from xmlrpc.server import SimpleXMLRPCServer as Server
    from xmlrpc.client import Fault
    from xmlrpclib import Server, Fault
                raise InvalidCredentialsException(
                    "Wrong credentials supplied: '%s'", err.faultString
                )
            else:
                raise SessionException(
                    "Generic remote communication error: '%s'", err.faultString
                )



    def validate_api_support(self):
        """
        Checks whether the API version on the Spacewalk server is supported.
        Using older versions than 11.1 is not recommended. In this case, an
        exception will be thrown.
        """
        try:
            #check whether API is supported
            api_level = self._session.api.getVersion()
            if float(api_level) < self.API_MIN:
                raise APILevelNotSupportedException(
                    "Your API version ({0}) does not support the required calls. "
                    "You'll need API version ({1}) or higher!".format(
                        api_level, self.API_MIN
                    )
                )
            else:
                self.LOGGER.info("Supported API version (" + api_level + ") found.")
        except ValueError as err:
            self.LOGGER.error(err)

# Path: katprep/management/base.py
# class BaseConnector(metaclass=ABCMeta):
#     """
#     Basic management connector that connects on creation.
#     """
# 
#     def __init__(self, username, password, **kwargs):
#         self._username = username
#         self._password = password
#         self._session = None
#         self._connect()
# 
#     @abstractmethod
#     def _connect(self):
#         pass
# 
# Path: katprep/exceptions.py
# class APILevelNotSupportedException(Exception):
#     """
#     Dummy class for unsupported API levels
# 
#     .. class:: APILevelNotSupportedException
#     """
# 
# class InvalidCredentialsException(Exception):
#     """
#     Dummy class for invalid credentials
# 
#     .. class:: InvalidCredentialsException
#     """
# 
# class SessionException(Exception):
#     """
#     Dummy class for session errors
# 
#     .. class:: SessionException
#     """


# Path: katprep/management/spacewalk.py
import logging
from .base import BaseConnector
from ..exceptions import (APILevelNotSupportedException, InvalidCredentialsException,
                         SessionException)
    from xmlrpc.server import SimpleXMLRPCServer as Server
    from xmlrpc.client import Fault
    from xmlrpclib import Server, Fault

                raise InvalidCredentialsException(
                    "Wrong credentials supplied: '%s'", err.faultString
                )
            else:
                raise SessionException(
                    "Generic remote communication error: '%s'", err.faultString
                )



    def validate_api_support(self):
        """
        Checks whether the API version on the Spacewalk server is supported.
        Using older versions than 11.1 is not recommended. In this case, an
        exception will be thrown.
        """
        try:
            #check whether API is supported
            api_level = self._session.api.getVersion()
            if float(api_level) < self.API_MIN:
                raise APILevelNotSupportedException(
                    "Your API version ({0}) does not support the required calls. "
                    "You'll need API version ({1}) or higher!".format(
                        api_level, self.API_MIN
                    )
                )
            else:
                self.LOGGER.info("Supported API version (" + api_level + ") found.")
        except ValueError as err:
            self.LOGGER.error(err)

            raise APILevelNotSupportedException("Unable to verify API version")