my eye

Auto-configure pa11y to use correct chrome binary

Committed 0a9d60

--- a/webint_cache/__init__.py
+++ b/webint_cache/__init__.py

 def run_pa11y(domain):
     """Run pa11y for the domain."""
     site_path = sites_path / domain
+
+    bindir = pathlib.Path("/usr/bin")
+    if (bindir / "google-chrome").exists():
+        binname = "google-chrome"
+    elif (bindir / "chromium").exists():
+        binname = "chromium"
+    else:
+        return
+
+    config = pathlib.Path.home() / ".pa11y.json"
+    if not config.exists():
+        with config.open("w") as fp:
+            fp.write(
+                f"""{{
+                  "chromeLaunchConfig": {{
+                    "executablePath": "/usr/bin/{binname}",
+                    "ignoreHTTPSErrors": false
+                  }}
+                }}"""
+            )
+
     logging.debug("running pa11y..")
     web.dump(
         web.load(
                 [
                     "pa11y",
                     domain,
+                    "--config",
+                    "/home/admin/.pa11y.json",
                     "--reporter",
                     "json",
                     "--screen-capture",