From cceb885e889c558e58d49439855118d92662313a Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 30 Mar 2022 08:37:29 +0200 Subject: [PATCH] Removing bugs and flake8 errors. --- lib/pp_admintools/argparse_actions.py | 15 +++++++++------ lib/pp_admintools/pdns_app.py | 9 +++++---- lib/pp_admintools/pdns_config.py | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/pp_admintools/argparse_actions.py b/lib/pp_admintools/argparse_actions.py index f718efa..00ef3f1 100644 --- a/lib/pp_admintools/argparse_actions.py +++ b/lib/pp_admintools/argparse_actions.py @@ -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) # ============================================================================= diff --git a/lib/pp_admintools/pdns_app.py b/lib/pp_admintools/pdns_app.py index 236df5b..d357342 100644 --- a/lib/pp_admintools/pdns_app.py +++ b/lib/pp_admintools/pdns_app.py @@ -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), diff --git a/lib/pp_admintools/pdns_config.py b/lib/pp_admintools/pdns_config.py index 8052d0b..e12365d 100644 --- a/lib/pp_admintools/pdns_config.py +++ b/lib/pp_admintools/pdns_config.py @@ -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(): -- 2.39.5