]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Separating all exception classes in module cr_vmware_tpl.errors
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 22 Sep 2023 08:14:51 +0000 (10:14 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 22 Sep 2023 08:14:51 +0000 (10:14 +0200)
lib/cr_vmware_tpl/app.py
lib/cr_vmware_tpl/cobbler.py
lib/cr_vmware_tpl/config.py
lib/cr_vmware_tpl/errors.py [new file with mode: 0644]
lib/cr_vmware_tpl/handler.py

index 63dbd4e4d9ddff5b2ebc81f2e9be9c1986acfb97..50117c3ee8711aaafbd6267bdac575ff3548da31 100644 (file)
@@ -31,6 +31,8 @@ from fb_tools.errors import FbAppError, ExpectedHandlerError
 
 from .config import CrTplConfiguration
 
+from .errors import CrTplAppError
+
 from .handler import CrTplHandler
 
 from .xlate import __module_dir__ as __xlate_module_dir__
@@ -38,19 +40,13 @@ from .xlate import __base_dir__ as __xlate_base_dir__
 from .xlate import __mo_file__ as __xlate_mo_file__
 from .xlate import XLATOR, LOCALE_DIR, DOMAIN
 
-__version__ = '1.5.2'
+__version__ = '1.5.3'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
 ngettext = XLATOR.ngettext
 
 
-# =============================================================================
-class CrTplAppError(FbAppError):
-    """ Base exception class for all exceptions in this application."""
-    pass
-
-
 # =============================================================================
 class NrTemplatesOptionAction(argparse.Action):
 
index 3736e1d89d232c945b4394d253f906c8088dc348..72d03c93c078a1a2e8969cd72181bbb8bf4326da 100644 (file)
@@ -34,7 +34,6 @@ from six.moves import configparser
 # Own modules
 
 from fb_tools.common import pp, to_str, is_sequence, to_bool
-from fb_tools.errors import HandlerError, ExpectedHandlerError
 from fb_tools.handling_obj import CompletedProcess
 from fb_tools.handler import BaseHandler
 from fb_tools.xlate import format_list
@@ -43,9 +42,11 @@ from . import print_section_start, print_section_end
 
 from .config import CrTplConfiguration
 
+from .errors import CobblerError, ExpectedCobblerError
+
 from .xlate import XLATOR
 
-__version__ = '0.10.0'
+__version__ = '0.10.1'
 
 LOG = logging.getLogger(__name__)
 
@@ -53,16 +54,6 @@ _ = XLATOR.gettext
 ngettext = XLATOR.ngettext
 
 
-# =============================================================================
-class CobblerError(HandlerError):
-    """Exception class for unexpected exceptions."""
-    pass
-
-# =============================================================================
-class ExpectedCobblerError(ExpectedHandlerError, CobblerError):
-    """Exception class for predictible exceptions."""
-    pass
-
 # =============================================================================
 class Cobbler(BaseHandler):
     """
@@ -79,7 +70,7 @@ class Cobbler(BaseHandler):
         if not isinstance(cfg, CrTplConfiguration):
             msg = _("{w} is not an instance of {c}, but an instance of {i} instead.").format(
                 w='Parameter cfg', c='CrTplConfiguration', i=cfg.__class__.__name__)
-            raise HandlerError(msg)
+            raise CobblerError(msg)
 
         self.host = CrTplConfiguration.default_cobbler_host
         self.cobbler_bin = CrTplConfiguration.default_cobbler_bin
index 0d630a24d627e9fe4bd8f237727ebc74d0e4bac9..e799a576f4bfa97369c4e74f96dc01928a773ee3 100644 (file)
@@ -23,7 +23,7 @@ from pathlib import Path
 from fb_tools.common import is_sequence, pp, to_bool
 from fb_tools.obj import FbGenericBaseObject, FbBaseObject
 from fb_tools.collections import CIStringSet
-from fb_tools.multi_config import MultiConfigError, BaseMultiConfig
+from fb_tools.multi_config import BaseMultiConfig
 from fb_tools.multi_config import DEFAULT_ENCODING
 from fb_tools.xlate import format_list
 
@@ -31,9 +31,11 @@ from fb_vmware.config import VSPhereConfigInfo
 
 from . import DEFAULT_CONFIG_DIR, DEFAULT_DISTRO_ARCH, MAX_PORT_NUMBER
 
+from .errors import CrTplConfigError
+
 from .xlate import XLATOR
 
-__version__ = '2.3.0'
+__version__ = '2.3.1'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -50,14 +52,6 @@ DEFAULT_ADMIN_FILTER = (
 )
 
 
-# =============================================================================
-class CrTplConfigError(MultiConfigError):
-    """Base error class for all exceptions happened during
-    execution this configured application"""
-
-    pass
-
-
 # =============================================================================
 class LdapConnectionInfo(FbBaseObject):
     """Encapsulating all necessary data to connect to a LDAP server."""
diff --git a/lib/cr_vmware_tpl/errors.py b/lib/cr_vmware_tpl/errors.py
new file mode 100644 (file)
index 0000000..4b89fee
--- /dev/null
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+@summary: The module for special error classes in this package
+
+@author: Frank Brehm
+@contact: frank@brehm-online.com
+@copyright: © 2023 by Frank Brehm, Berlin
+"""
+from __future__ import absolute_import
+
+# Standard modules
+
+# Third party modules
+
+from fb_tools.errors import FbAppError
+from fb_tools.errors import FbHandlerError
+from fb_tools.errors import HandlerError, ExpectedHandlerError
+from fb_tools.multi_config import MultiConfigError
+
+# Own modules
+from .xlate import XLATOR
+
+__version__ = '0.1.0'
+
+_ = XLATOR.gettext
+
+
+MSG_NO_CLUSTER = _(
+    "Could not find a datastore of {size:0.1f} GiB size in "
+    "datastore cluster {c_name!r}.")
+
+
+# =============================================================================
+class CrTplAppError(FbAppError):
+    """ Base exception class for all exceptions in this application."""
+    pass
+
+
+# =============================================================================
+class CrTplConfigError(MultiConfigError):
+    """Base error class for all exceptions happened during
+    execution this configured application"""
+
+    pass
+
+
+# =============================================================================
+class CobblerError(HandlerError):
+    """Exception class for unexpected exceptions."""
+    pass
+
+
+# =============================================================================
+class ExpectedCobblerError(ExpectedHandlerError, CobblerError):
+    """Exception class for predictible exceptions."""
+    pass
+
+
+# =============================================================================
+class TempVmExistsError(ExpectedHandlerError):
+    """Special error class for the case, if the temporary VM is already existing."""
+
+    # -------------------------------------------------------------------------
+    def __init__(self, vm_name):
+
+        self.vm_name = vm_name
+
+    # -------------------------------------------------------------------------
+    def __str__(self):
+
+        msg = _("The temporary VM {!r} is already existing, cannot continue.").format(self.vm_name)
+        return msg
+
+
+# =============================================================================
+class NoDatastoreFoundError(ExpectedHandlerError):
+    """Special error class for the case, no appropriate datastore coud be found."""
+
+    # -------------------------------------------------------------------------
+    def __init__(self, data_size_gb, ds_cluster_name=None):
+
+        self.data_size_gb = data_size_gb
+        self.ds_cluster_name = ds_cluster_name
+
+    # -------------------------------------------------------------------------
+    def __str__(self):
+
+        if self.ds_cluster_name:
+            msg = MSG_NO_CLUSTER.format(size=self.data_size_gb, c_name=self.ds_cluster_name)
+        else:
+            msg = _("Could not find a datastore of {:0.1f} GiB size.").format(
+                self.data_size_gb)
+
+        return msg
+
+
+# =============================================================================
+
+if __name__ == "__main__":
+
+    pass
+
+# =============================================================================
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list
index 7d78ef7ae9633c173c5838f4b18cb31db628ec05..daf01571a319e6545ab8ea4df506bbb9b2b9d3a4 100644 (file)
@@ -52,9 +52,11 @@ from .config import CrTplConfiguration, DEFAULT_PORT_LDAP, DEFAULT_PORT_LDAPS
 
 from .cobbler import Cobbler
 
+from .errors import MSG_NO_CLUSTER, TempVmExistsError, NoDatastoreFoundError
+
 from .xlate import XLATOR
 
-__version__ = '2.3.3'
+__version__ = '2.3.4'
 
 LOG = logging.getLogger(__name__)
 TZ = pytz.timezone('Europe/Berlin')
@@ -62,49 +64,6 @@ TZ = pytz.timezone('Europe/Berlin')
 _ = XLATOR.gettext
 ngettext = XLATOR.ngettext
 
-MSG_NO_CLUSTER = _(
-    "Could not find a datastore of {size:0.1f} GiB size in "
-    "datastore cluster {c_name!r}.")
-
-
-# =============================================================================
-class TempVmExistsError(ExpectedHandlerError):
-    """Special error class for the case, if the temporary VM is already existing."""
-
-    # -------------------------------------------------------------------------
-    def __init__(self, vm_name):
-
-        self.vm_name = vm_name
-
-    # -------------------------------------------------------------------------
-    def __str__(self):
-
-        msg = _("The temporary VM {!r} is already existing, cannot continue.").format(self.vm_name)
-        return msg
-
-
-# =============================================================================
-class NoDatastoreFoundError(ExpectedHandlerError):
-    """Special error class for the case, no appropriate datastore coud be found."""
-
-    # -------------------------------------------------------------------------
-    def __init__(self, data_size_gb, ds_cluster_name=None):
-
-        self.data_size_gb = data_size_gb
-        self.ds_cluster_name = ds_cluster_name
-
-    # -------------------------------------------------------------------------
-    def __str__(self):
-
-        if self.ds_cluster_name:
-            msg = MSG_NO_CLUSTER.format(size=self.data_size_gb, c_name=self.ds_cluster_name)
-        else:
-            msg = _("Could not find a datastore of {:0.1f} GiB size.").format(
-                self.data_size_gb)
-
-        return msg
-
-
 # =============================================================================
 class CrTplHandler(BaseHandler):
     """