]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Removing bugs and flake8 errors.
authorFrank Brehm <frank@brehm-online.com>
Wed, 30 Mar 2022 06:37:29 +0000 (08:37 +0200)
committerFrank Brehm <frank@brehm-online.com>
Wed, 30 Mar 2022 06:37:29 +0000 (08:37 +0200)
lib/pp_admintools/argparse_actions.py
lib/pp_admintools/pdns_app.py
lib/pp_admintools/pdns_config.py

index f718efa08e18837e4e2fd5fa8de6110df415b05a..00ef3f16e34a059bd2782bd6af325e46dba13b19 100644 (file)
@@ -42,12 +42,13 @@ class PortOptionAction(argparse.Action):
         try:
             port = int(values)
         except (ValueError, TypeError) as e:
-            msg = _("Value {v!r} for a {what} port is invalid:").format(v=values, what=what)
+            msg = _("Value {v!r} for a {what} port is invalid:").format(v=values, what=self.what)
+            msg += ' ' + str(e)
             raise argparse.ArgumentError(self, msg)
 
         if port <= 0 or port > MAX_PORT_NUMBER:
             msg = _("Value {v!r} for a {what} port must be greater than 0 and less than {max}.")
-            msg = msg.format(v=values, what=what, max=(MAX_PORT_NUMBER + 1))
+            msg = msg.format(v=values, what=self.what, max=(MAX_PORT_NUMBER + 1))
             raise argparse.ArgumentError(self, msg)
 
         setattr(namespace, self.dest, port)
@@ -73,16 +74,18 @@ class TimeoutOptionAction(argparse.Action):
         try:
             timeout = int(values)
         except (ValueError, TypeError) as e:
-            msg = _("Value {v!r} for a timeout of {what} is invalid:").format(v=values, what=what)
+            msg = _("Value {v!r} for a timeout of {what} is invalid:").format(
+                v=values, what=self.what)
+            msg += ' ' + str(e)
             raise argparse.ArgumentError(self, msg)
 
-        if port <= 0 or port > MAX_TIMEOUT:
+        if timeout <= 0 or timeout > MAX_TIMEOUT:
             msg = _(
                 "Value {v!r} for a timeout of {what} must be greater than 0 and less than {max}.")
-            msg = msg.format(v=values, what=what, max=(MAX_TIMEOUT + 1))
+            msg = msg.format(v=values, what=self.what, max=(MAX_TIMEOUT + 1))
             raise argparse.ArgumentError(self, msg)
 
-        setattr(namespace, self.dest, port)
+        setattr(namespace, self.dest, timeout)
 
 
 # =============================================================================
index 236df5b20f4d95e4b50aa11af04a692c5c471b3b..d3573422e1147f077e49c3ee2d70cde03df69fe5 100644 (file)
@@ -12,7 +12,7 @@ from __future__ import absolute_import
 import logging
 import logging.config
 import re
-import copy
+import copy
 import os
 import ipaddress
 import socket
@@ -35,7 +35,8 @@ from .argparse_actions import PortOptionAction, TimeoutOptionAction
 
 from .mail_app import MailAppError, BaseMailApplication
 
-from .pdns_config import PdnsConfigError, PdnsConfiguration, LIBRARY_NAME
+from .pdns_config import PdnsConfiguration
+# from .pdns_config import PdnsConfigError, PdnsConfiguration
 
 from .xlate import XLATOR
 
@@ -95,7 +96,7 @@ class PpPDNSApplication(BaseMailApplication):
                         self.local_addresses.append(addr)
 
         if not self.cfg:
-            msg=_("Configuration not available.")
+            msg = _("Configuration not available.")
             raise PpPDNSAppError(msg)
 
         self.eval_instance(instance)
@@ -232,7 +233,7 @@ class PpPDNSApplication(BaseMailApplication):
 
         inst_group.add_argument(
             '-I', '--inst', '--instance',
-            metavar=_("INSTANCE"), choices=envs, dest="inst",
+            metavar=_("INSTANCE"), choices=insts, dest="inst",
             help=_(
                 "Select, which PowerDNS instance to use. Valid values: {v}, "
                 "default: {d!r}.").format(v=inst_list, d=self.instance),
index 8052d0bc96d2284e8d33d7a931017f841f9645a5..e12365dbf2d603d725e121777707ed9182f91f24 100644 (file)
@@ -143,7 +143,7 @@ class PdnsConfiguration(MailConfiguration):
         res['default_pdns_api_servername'] = self.default_pdns_api_servername
         res['default_pdns_timeout'] = self.default_pdns_timeout
         res['default_pdns_instance'] = self.default_pdns_instance
-        res{'valid_pdns_api_instances'] = self.valid_pdns_api_instances
+        res['valid_pdns_api_instances'] = self.valid_pdns_api_instances
 
         res['pdns_api_instances'] = {}
         for iname in self.pdns_api_instances.keys():