#!/usr/bin/env python3 # Copyright (c) 2026 Krzysztof Rudnicki. MIT licence. """Write a day of invented food and workout logs for the offline end-to-end run. The real logs are the operator's day, kept by diet_guard and screen_locker outside this repository; the e2e run must not read them, and could not count on what they hold. This writes one entry of each under today's Warsaw date -- the day the bot will ask for -- so the two scenarios have a known word to look for. python tool/e2e_logs.py --dir /tmp/logs """ from __future__ import annotations import argparse import json import sys from pathlib import Path from typing import Final from signal_bot.stats.periods import today FOOD_FILE: Final = "food_log.json" WORKOUT_FILE: Final = "workout_log.json" MEAL_TIME: Final = "T12:15:00+02:00" WORKOUT_TIME: Final = "T07:31:13+00:00" MEAL: Final[dict[str, object]] = { "desc": "carbonara", "grams": 350, "kcal": 550, "protein_g": 22, "carbs_g": 60, "fat_g": 24, "source": "manual", } WORKOUT: Final[dict[str, object]] = { "workout_data": { "type": "pc_workout_verified", "source": "StrongLifts workout B (113 min, all succeeded)", "duration_minutes": "112.7", }, } def write(directory: Path) -> None: """Both logs, one entry each, dated today.""" day = today() directory.mkdir(parents=True, exist_ok=True) food = {day: [{**MEAL, "time": day + MEAL_TIME}]} workout = {day: [{**WORKOUT, "timestamp": day + WORKOUT_TIME}]} (directory / FOOD_FILE).write_text(json.dumps(food, indent=2), encoding="utf-8") (directory / WORKOUT_FILE).write_text(json.dumps(workout, indent=2), encoding="utf-8") def main() -> int: """Write the logs asked for on the command line.""" parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--dir", required=True, type=Path, help="where to write the logs") arguments = parser.parse_args() write(arguments.dir) sys.stdout.write(f"== wrote synthetic food and workout logs to {arguments.dir}\n") return 0 if __name__ == "__main__": raise SystemExit(main())