question 216 Modules & Packages · medium
Why does the nightly report run twice?
This file is the nightly module. The scheduler imports it and calls run_report("orders.csv") at 02:00, and the log shows the report twice, both saying 0 delivered orders, 0.00 total. A test that imports the module from another folder crashes with FileNotFoundError. Fix both problems; running the file by hand should still print the report once. (The scheduler's job is just import nightly, then nightly.run_report("orders.csv").)
Function
run_report(path): prints "<n> delivered orders, <total, 2 decimals> total" and returns nFile
orders.csv with columns order_id,status,total; statuses are lower caseRun as a scriptprints the report for
orders.csv onceImportedprints nothing and reads no file
Examples
callrun_report('orders.csv')returns2
Expected output1 line
- 12 delivered orders, 84.07 total