"""
@author: Frank Brehm
@contact: frank.brehm@pixelpark.com
-@copyright: © 2018 by Frank Brehm, Berlin
+@copyright: © 2021 by Frank Brehm, Berlin
@summary: The module for the application object with support
for configuration files.
"""
from configparser import Error as ConfigParseError
# Own modules
+from fb_tools.app import BaseApplication
+from fb_tools.common import pp, to_bool, RE_DOT_AT_END
+
from .global_version import __version__ as __global_version__
from .errors import PpAppError
-from .common import pp, to_bool, RE_DOT_AT_END
-
from .merge import merge_structure
from .mailaddress import MailAddress
-from .app import PpApplication
-
-__version__ = '0.7.1'
+__version__ = '0.8.0'
LOG = logging.getLogger(__name__)
VALID_MAIL_METHODS = ('smtp', 'sendmail')
# =============================================================================
-class PpConfigApplication(PpApplication):
+class PpConfigApplication(BaseApplication):
"""
Class for configured application objects.
"""
# Standard modules
import errno
+# own modules
+from fb_tools.errors import FbError, FbAppError
-__version__ = '0.4.1'
+
+__version__ = '0.5.0'
# =============================================================================
-class PpError(Exception):
+class PpError(FbError):
"""
Base error class for all other self defined exceptions.
"""
# =============================================================================
-class PpAppError(PpError):
+class PpAppError(FbAppError):
pass
-# =============================================================================
-class InvalidMailAddressError(PpError):
- """Class for a exception in case of a malformed mail address."""
-
- # -------------------------------------------------------------------------
- def __init__(self, address, msg=None):
-
- self.address = address
- self.msg = msg
-
- # -------------------------------------------------------------------------
- def __str__(self):
-
- msg = "Wrong mail address {a!r} ({c})".format(
- a=self.address, c=self.address.__class__.__name__)
- if self.msg:
- msg += ': ' + self.msg
- else:
- msg += '.'
- return msg
-
-
-# =============================================================================
-class FunctionNotImplementedError(PpError, NotImplementedError):
- """
- Error class for not implemented functions.
- """
-
- # -------------------------------------------------------------------------
- def __init__(self, function_name, class_name):
- """
- Constructor.
-
- @param function_name: the name of the not implemented function
- @type function_name: str
- @param class_name: the name of the class of the function
- @type class_name: str
-
- """
-
- self.function_name = function_name
- if not function_name:
- self.function_name = '__unkown_function__'
-
- self.class_name = class_name
- if not class_name:
- self.class_name = '__unkown_class__'
-
- # -------------------------------------------------------------------------
- def __str__(self):
- """
- Typecasting into a string for error output.
- """
-
- msg = "Function {func}() has to be overridden in class {cls!r}."
- return msg.format(func=self.function_name, cls=self.class_name)
-
-# =============================================================================
-class IoTimeoutError(PpError, IOError):
- """
- Special error class indicating a timout error on a read/write operation
- """
-
- # -------------------------------------------------------------------------
- def __init__(self, strerror, timeout, filename=None):
- """
- Constructor.
-
- @param strerror: the error message about the operation
- @type strerror: str
- @param timeout: the timout in seconds leading to the error
- @type timeout: float
- @param filename: the filename leading to the error
- @type filename: str
-
- """
-
- t_o = None
- try:
- t_o = float(timeout)
- except ValueError:
- pass
- self.timeout = t_o
-
- if t_o is not None:
- strerror += " (timeout after {:0.1f} secs)".format(t_o)
-
- if filename is None:
- super(IoTimeoutError, self).__init__(errno.ETIMEDOUT, strerror)
- else:
- super(IoTimeoutError, self).__init__(
- errno.ETIMEDOUT, strerror, filename)
-
-# =============================================================================
-class ReadTimeoutError(IoTimeoutError):
- """
- Special error class indicating a timout error on reading of a file.
- """
-
- # -------------------------------------------------------------------------
- def __init__(self, timeout, filename):
- """
- Constructor.
-
- @param timeout: the timout in seconds leading to the error
- @type timeout: float
- @param filename: the filename leading to the error
- @type filename: str
-
- """
-
- strerror = "Timeout error on reading"
- super(ReadTimeoutError, self).__init__(strerror, timeout, filename)
-
-
-# =============================================================================
-class WriteTimeoutError(IoTimeoutError):
- """
- Special error class indicating a timout error on a writing into a file.
- """
-
- # -------------------------------------------------------------------------
- def __init__(self, timeout, filename):
- """
- Constructor.
-
- @param timeout: the timout in seconds leading to the error
- @type timeout: float
- @param filename: the filename leading to the error
- @type filename: str
-
- """
-
- strerror = "Timeout error on writing"
- super(WriteTimeoutError, self).__init__(strerror, timeout, filename)
-
-# =============================================================================
-class CouldntOccupyLockfileError(PpError):
- """
- Special error class indicating, that a lockfile couldn't coccupied
- after a defined time.
- """
-
- # -----------------------------------------------------
- def __init__(self, lockfile, duration, tries):
- """
- Constructor.
-
- @param lockfile: the lockfile, which could't be occupied.
- @type lockfile: str
- @param duration: The duration in seconds, which has lead to this situation
- @type duration: float
- @param tries: the number of tries creating the lockfile
- @type tries: int
-
- """
-
- self.lockfile = str(lockfile)
- self.duration = float(duration)
- self.tries = int(tries)
-
- # -----------------------------------------------------
- def __str__(self):
-
- return "Couldn't occupy lockfile {!r} in {:0.1f} seconds with {} tries.".format(
- self.lockfile, self.duration, self.tries)
-
-
# =============================================================================
if __name__ == "__main__":
"""
@author: Frank Brehm
@contact: frank.brehm@pixelpark.com
-@copyright: © 2018 by Frank Brehm, Berlin
+@copyright: © 2021 by Frank Brehm, Berlin
@summary: The module for the mk-home application object.
"""
from __future__ import absolute_import
# from ldap3.core.exceptions import LDAPKeyError
# Own modules
-from .common import pp
+from fb_tools.common import pp
from .ldap_app import PpLdapAppError, PpLdapApplication
-__version__ = '0.5.1'
+__version__ = '0.6.0'
LOG = logging.getLogger(__name__)
default_dn_counter = 'uid=uidNumber,ou=ldapTool,ou=Applications,o=Pixelpark,o=isp'
# -------------------------------------------------------------------------
- def __init__(self, appname=None, version=__version__):
+ def __init__(self, appname=None, base_dir=None, version=__version__):
self.initial_uid = self.default_initial_uid
self.chroot_homedir = self.default_chroot_homedir
super(PpMkHomeApp, self).__init__(
appname=appname, version=version, description=description,
- cfg_stems='mk-home'
+ base_dir=base_dir, cfg_stems='mk-home'
)
self.initialized = True