Signing key checks
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import tomllib
|
||||
import mimetypes
|
||||
|
||||
addr: str = "127.0.0.1"
|
||||
port: int = 5000
|
||||
@@ -39,6 +38,7 @@ def _load_toml(path: Path) -> dict:
|
||||
|
||||
def _read_signing_key_from_path(path_value) -> str | None:
|
||||
p = Path(path_value)
|
||||
|
||||
if not p.exists():
|
||||
_fatal(f"signing_key_path {p} does not exist")
|
||||
try:
|
||||
@@ -52,10 +52,6 @@ def _validate_cat_path(cat_path: str) -> Path:
|
||||
if not p.exists():
|
||||
_fatal(f"Cat photo at {p} does not exist")
|
||||
|
||||
mtype, _ = mimetypes.guess_type(str(p))
|
||||
if mtype is None or not mtype.startswith("image/"):
|
||||
_warn(f"Cat file {p} does not look like an image (mimetype={mtype})")
|
||||
|
||||
return p
|
||||
|
||||
|
||||
@@ -86,12 +82,16 @@ def _apply_config(cfg: dict) -> None:
|
||||
signing_key = str(cfg["signing_key"]).strip()
|
||||
elif "signing_key_path" in cfg:
|
||||
sk = _read_signing_key_from_path(cfg["signing_key_path"])
|
||||
|
||||
if sk:
|
||||
signing_key = sk
|
||||
else:
|
||||
_fatal(f"{cfg["signing_key_path"]} does not have a signing key.")
|
||||
|
||||
else:
|
||||
_fatal(
|
||||
"`signing_key` is not in configuration. "
|
||||
"A signing key can be generated using `cmd/generate_key.py`."
|
||||
"A signing key is not present in the configuration. "
|
||||
"A key can be generated using `python3 -m vona.utils.makekey`."
|
||||
)
|
||||
|
||||
if "cat" in cfg:
|
||||
|
||||
Reference in New Issue
Block a user