Kaynağa Gözat

fix: improve formatting and error handling in Squid configuration validation

Manuel 9 ay önce
ebeveyn
işleme
f361c53b76
1 değiştirilmiş dosya ile 19 ekleme ve 5 silme
  1. 19 5
      services/squid/squid_config_splitter.py

+ 19 - 5
services/squid/squid_config_splitter.py

@@ -414,7 +414,9 @@ class SquidConfigSplitter:
                 "'squid' not found on system. Trying Docker fallback "
                 "'squid' not found on system. Trying Docker fallback "
                 "('docker exec squid_proxy squid -k parse')..."
                 "('docker exec squid_proxy squid -k parse')..."
             )
             )
-            res = _run_command(["docker", "exec", "squid_proxy", "squid", "-k", "parse"])
+            res = _run_command(
+                ["docker", "exec", "squid_proxy", "squid", "-k", "parse"]
+            )
 
 
             if not res["ran"]:
             if not res["ran"]:
                 error_msg = (
                 error_msg = (
@@ -429,13 +431,25 @@ class SquidConfigSplitter:
         if res.get("timeout"):
         if res.get("timeout"):
             error_msg = f"Squid configuration validation timed out after 30 seconds.\n{res['output']}"
             error_msg = f"Squid configuration validation timed out after 30 seconds.\n{res['output']}"
             logger.error(error_msg)
             logger.error(error_msg)
-            return {"success": False, "error_message": error_msg, "output": res["output"]}
+            return {
+                "success": False,
+                "error_message": error_msg,
+                "output": res["output"],
+            }
 
 
         if res["returncode"] == 0:
         if res["returncode"] == 0:
-            logger.info(f"Squid configuration is valid.\nCommand output:\n{res['output']}")
-            return {"success": True, "output": res["output"], "return_code": res["returncode"]}
+            logger.info(
+                f"Squid configuration is valid.\nCommand output:\n{res['output']}"
+            )
+            return {
+                "success": True,
+                "output": res["output"],
+                "return_code": res["returncode"],
+            }
 
 
-        error_msg = f"Validation failed with return code {res['returncode']}\n{res['output']}"
+        error_msg = (
+            f"Validation failed with return code {res['returncode']}\n{res['output']}"
+        )
         logger.error(f"Squid configuration validation failed:\n{error_msg}")
         logger.error(f"Squid configuration validation failed:\n{error_msg}")
         return {
         return {
             "success": False,
             "success": False,