]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add Dig interface
authorMichal Nowak <mnowak@isc.org>
Fri, 7 Feb 2025 10:26:04 +0000 (11:26 +0100)
committerMichal Nowak <mnowak@isc.org>
Mon, 17 Feb 2025 19:16:03 +0000 (19:16 +0000)
bin/tests/system/isctest/run.py

index eed356bbb5d0bb2d3415e791fa9489ba26b85fa9..dd9dcb5515bce0ec929ef07419d65c4cf206d512 100644 (file)
@@ -98,6 +98,18 @@ def _run_script(
         isctest.log.debug("  exited with %d", returncode)
 
 
+class Dig:
+    def __init__(self, base_params: str = ""):
+        self.base_params = base_params
+
+    def __call__(self, params: str) -> str:
+        """Run the dig command with the given parameters and return the decoded output."""
+        return cmd(
+            [os.environ.get("DIG")] + f"{self.base_params} {params}".split(),
+            log_stdout=True,
+        ).stdout.decode("utf-8")
+
+
 def shell(script: str, args: Optional[List[str]] = None) -> None:
     """Run a given script with system's shell interpreter."""
     _run_script(os.environ["SHELL"], script, args)