Restructure project to flat layout and update run instructions

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.
This commit is contained in:
Clarth 2026-11-13 20:26:05 -05:00
parent 8bd5da1b9d
commit dc831b430b
12 changed files with 19 additions and 25 deletions

View file

@ -40,12 +40,6 @@ cp config.example.toml config.toml
Then edit `.env` and `config.toml` (see below).
To run the tests:
```sh
python -m unittest discover -s tests
```
## Configure
There are two config files. Both are ignored by git, so your values stay on your machine.
@ -89,13 +83,13 @@ Give the key only what it needs. Remove a source from `config.toml` and drop its
Check what would be sent, without sending anything or saving state:
```sh
.venv/bin/python -m fluxer_admin_alerts --dry-run
.venv/bin/python __main__.py --dry-run
```
Run for real:
```sh
.venv/bin/python -m fluxer_admin_alerts
.venv/bin/python __main__.py
```
Use `-v` for debug logging. Exit code `0` means success, `1` means at least one source or notifier failed, and `2` means the config is wrong.
@ -105,7 +99,7 @@ Use `-v` for debug logging. Exit code `0` means success, `1` means at least one
Edit your crontab with `crontab -e` and add a line to run every hour:
```cron
0 * * * * cd /path/to/fluxer-admin-alerts && .venv/bin/python -m fluxer_admin_alerts >> alerts.log 2>&1
0 * * * * cd /path/to/fluxer-admin-alerts && .venv/bin/python __main__.py >> alerts.log 2>&1
```
Replace `/path/to/fluxer-admin-alerts` with the folder you cloned into. `alerts.log` is ignored by git.
@ -120,7 +114,7 @@ Replace `/path/to/fluxer-admin-alerts` with the folder you cloned into. `alerts.
## Adding a notifier
Notifiers live in `fluxer_admin_alerts/notifiers/`. A notifier subclasses `Notifier`, implements `send(messages)`, raises `NotifierError` on failure, and is registered in `notifiers/__init__.py`. Then add its name to `KNOWN_NOTIFIERS` in `config.py` and read any settings it needs from `.env`.
Notifiers live in `notifiers/`. A notifier subclasses `Notifier`, implements `send(messages)`, raises `NotifierError` on failure, and is registered in `notifiers/__init__.py`. Then add its name to `KNOWN_NOTIFIERS` in `config.py` and read any settings it needs from `.env`.
## License

View file

@ -5,8 +5,8 @@ import logging
import sys
from pathlib import Path
from .config import PROJECT_ROOT, ConfigError, load_settings
from .runner import run
from config import PROJECT_ROOT, ConfigError, load_settings
from runner import run
def main(argv: list[str] | None = None) -> int:

View file

@ -8,7 +8,7 @@ from pathlib import Path
from dotenv import load_dotenv
PROJECT_ROOT = Path(__file__).resolve().parent.parent
PROJECT_ROOT = Path(__file__).resolve().parent
KNOWN_NOTIFIERS = ("fluxer",)

View file

@ -3,8 +3,8 @@ from __future__ import annotations
from dataclasses import dataclass, field, replace
from datetime import datetime, timedelta
from .sources import Item
from .state import AlertRecord
from sources import Item
from state import AlertRecord
@dataclass(frozen=True)

View file

@ -4,7 +4,7 @@ from typing import Any
import requests
from . import __version__
__version__ = "0.1.0"
USER_AGENT = f"fluxer-admin-alerts/{__version__}"

View file

@ -1,6 +1,6 @@
from __future__ import annotations
from ..config import Settings
from config import Settings
from .base import Message, Notifier, NotifierError
from .fluxer import FluxerWebhookNotifier

View file

@ -3,12 +3,12 @@ from __future__ import annotations
import logging
from datetime import datetime, timezone
from .config import Settings
from .engine import Notice, decide
from .fluxer_api import FluxerAPI, FluxerAPIError
from .notifiers import NotifierError, Message, build_notifiers
from .sources import SOURCES, Item
from .state import StateStore
from config import Settings
from engine import Notice, decide
from fluxer_api import FluxerAPI, FluxerAPIError
from notifiers import NotifierError, Message, build_notifiers
from sources import SOURCES, Item
from state import StateStore
log = logging.getLogger(__name__)

View file

@ -5,8 +5,8 @@ from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from typing import Any
from .config import SourceSettings
from .fluxer_api import FluxerAPI
from config import SourceSettings
from fluxer_api import FluxerAPI
PAGE_SIZE = 200
MAX_PAGES = 50