Move modules from fluxer_admin_alerts/ to the repository root, switch to absolute imports, fix PROJECT_ROOT resolution, and update README commands and notifier paths.
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import logging
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from config import PROJECT_ROOT, ConfigError, load_settings
|
|
from runner import run
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
parser = argparse.ArgumentParser(
|
|
prog="fluxer-admin-alerts",
|
|
description="Check the Fluxer Admin API and send alerts for items that need attention.",
|
|
)
|
|
parser.add_argument(
|
|
"--config",
|
|
type=Path,
|
|
default=PROJECT_ROOT / "config.toml",
|
|
help="path to the config file (default: config.toml in the project folder)",
|
|
)
|
|
parser.add_argument(
|
|
"--dry-run",
|
|
action="store_true",
|
|
help="show what would be sent without sending anything or saving state",
|
|
)
|
|
parser.add_argument("-v", "--verbose", action="store_true", help="enable debug logging")
|
|
args = parser.parse_args(argv)
|
|
|
|
logging.basicConfig(
|
|
level=logging.DEBUG if args.verbose else logging.INFO,
|
|
format="%(asctime)s %(levelname)s %(message)s",
|
|
)
|
|
|
|
try:
|
|
settings = load_settings(args.config)
|
|
except ConfigError as exc:
|
|
logging.error("%s", exc)
|
|
return 2
|
|
|
|
return run(settings, dry_run=args.dry_run)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|