]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Checking given timeout
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 18 Nov 2022 10:32:34 +0000 (11:32 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 18 Nov 2022 10:32:34 +0000 (11:32 +0100)
lib/pp_admintools/app/pdns.py

index f588fde73dd69d9bc5311cade2b8939a81a149d4..06429ae2e4ce3dc9f64ee30a69f0507908f53340 100644 (file)
@@ -43,7 +43,7 @@ from ..config.pdns import PdnsConfiguration
 
 from ..xlate import XLATOR
 
-__version__ = '0.9.9'
+__version__ = '0.9.10'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -279,7 +279,7 @@ class PpPDNSApplication(BaseMailApplication):
                 PdnsConfiguration.default_pdns_api_port),
         )
 
-        help_msg=_(
+        help_msg = _(
             "The timeout in seconds for the communication with the PowerDNS-API. "
             "Default: {} seconds.").format(PdnsConfiguration.default_pdns_timeout)
         pdns_group.add_argument(
@@ -375,6 +375,13 @@ class PpPDNSApplication(BaseMailApplication):
             self.api_port = self.args.api_port
 
         if self.args.timeout:
+            if self.args.timeout > MAX_TIMEOUT:
+                msg = _("Timeout of {t} seconds too big, at most {m} seconds are allowed.")
+                msg = msg.format(t=self.args.timeout, m=MAX_TIMEOUT)
+                self.exit(1, msg)
+            if self.args.timeout < 0:
+                msg = _("A tomeout may not be negative.")
+                self.exit(1, msg)
             self.cfg.pdns_timeout = self.args.timeout
 
         self.pdns = PowerDNSServer(