]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Adding query for executing yes or no in bin/mirror-ldap-instance
authorFrank Brehm <frank@brehm-online.com>
Thu, 20 Oct 2022 15:38:07 +0000 (17:38 +0200)
committerFrank Brehm <frank@brehm-online.com>
Thu, 20 Oct 2022 15:38:07 +0000 (17:38 +0200)
lib/pp_admintools/app/__init__.py
lib/pp_admintools/app/mirror_ldap.py
lib/pp_admintools/app/remove_ldap_user.py

index 68c128d2110e5e7d4de1acbc89251f7185b8c302..19da0561ab106fcbb6c29f62ba730fe5669f7f19 100644 (file)
@@ -26,7 +26,7 @@ LOG = logging.getLogger(__name__)
 _ = XLATOR.gettext
 ngettext = XLATOR.ngettext
 
-__version__ = '0.5.0'
+__version__ = '0.5.1'
 
 
 # =============================================================================
@@ -59,11 +59,6 @@ class BaseDPXApplication(FbConfigApplication):
             argparse_epilog=None, argparse_prefix_chars='-', env_prefix=None,
             config_dir=DEFAULT_CONFIG_DIR):
 
-        self.init_yes_no_lists()
-
-        self._yes = False
-        self._prompt_timeout = self.default_prompt_timeout
-
         super(BaseDPXApplication, self).__init__(
             appname=appname, verbose=verbose, version=version, base_dir=base_dir,
             description=description, cfg_class=cfg_class, initialized=False,
index 1b3c8595a3e3b306eebf4a1e4774fe01502455a6..58ef7f19beb637acdfb572c2b92ad7bc326f9256 100644 (file)
@@ -24,6 +24,7 @@ from functools import cmp_to_key
 from fb_tools.common import pp
 # from fb_tools.collections import FrozenCIStringSet, CIStringSet, CIDict
 from fb_tools.collections import CIDict, CIStringSet
+from fb_tools.errors import AbortAppError, TimeoutOnPromptError
 
 from ..xlate import XLATOR
 
@@ -34,7 +35,7 @@ from .ldap import BaseLdapApplication
 from ..argparse_actions import NonNegativeItegerOptionAction
 from ..argparse_actions import LimitedFloatOptionAction
 
-__version__ = '0.4.0'
+__version__ = '0.4.1'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -206,10 +207,23 @@ class MirrorLdapApplication(BaseLdapApplication):
     # -------------------------------------------------------------------------
     def _run(self):
 
+        src_url = self.cfg.ldap_connection[self.src_instance].url
+        tgt_url = self.cfg.ldap_connection[self.tgt_instance].url
+        msg = _(
+            "Start mirroring  LDAP instance {src!r} ({src_url}) to instance {tgt!r} ({tgt_url}) "
+            "[{yes}/{no}]?").format(
+            src=self.src_instance, src_url=src_url, tgt=self.tgt_instance, tgt_url=tgt_url,
+            yes=self.colored(_('yes'), 'RED'), no=self.colored(_('No'), 'GREEN')) + ' '
+
+        self.empty_line()
+        answer =  self.ask_for_yes_or_no(msg)
+        if not answer:
+            self.empty_line()
+            LOG.error(_("Interrupted on demand."))
+            self.exit(3)
+
         if not self.quiet and not self.force:
             self.empty_line()
-            src_url = self.cfg.ldap_connection[self.src_instance].url
-            tgt_url = self.cfg.ldap_connection[self.tgt_instance].url
             msg = _(
                 "Start mirroring LDAP instance {src!r} ({src_url}) to instance {tgt!r} "
                 "({tgt_url}) ...").format(
index 23adbbc991d13520dfdf2f4b0ad46338f33327f3..f89b610af64a845f5e6f94ea3d3df8586a75f75e 100644 (file)
@@ -24,7 +24,7 @@ from ..xlate import XLATOR
 from .ldap import LdapAppError, FatalLDAPError
 from .ldap import BaseLdapApplication
 
-__version__ = '0.5.5'
+__version__ = '0.5.7'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -277,17 +277,7 @@ class RemoveLdapUserApplication(BaseLdapApplication):
             msg = _("Remove [{yes}/{no}]?")
         msg = msg.format(
             yes=self.colored(_('yes'), 'RED'), no=self.colored(_('No'), 'GREEN')) + ' '
-        try:
-            return self.ask_for_yes_or_no(msg)
-        except (TimeoutOnPromptError, AbortAppError) as e:
-            if self.deactivate:
-                msg = _("Abort deactivating by {cls}: {e}")
-            else:
-                msg = _("Abort removing by {cls}: {e}")
-            LOG.error(msg.format(cls=e.__class__.__name__, e=e))
-            return False
-
-        return True
+        return self.ask_for_yes_or_no(msg)
 
     # -------------------------------------------------------------------------
     def eval_user_dns(self, user):