Files
POPS/app/filamentdb.py
Martin Hohenberg 17097061c3 Log filament usage to FilamentDB when starting a job
- filamentdb.get_ams_slots(): parses /ams/ HTML to extract slot, material,
  color, weight_remaining_g, roll_id for each loaded AMS slot
- filamentdb.find_matching_ams_roll(): filters by material+color (case-insensitive),
  picks the roll with least filament remaining
- filamentdb.log_print_on_roll(): POSTs to /rolls/{id}/prints
- start_job: after setting job to printing, looks up AMS, computes weight
  (math.ceil of estimate), logs against matching roll, writes result to job log
- Verified parser against live AMS: PLA Black → slot 3 (30g) over slot 1 (1000g)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-18 22:59:33 +02:00

4.7 KiB