Commit d4e2016
fix: don't take a screenshot at import time (#23)
recorder.py computed monitor dimensions via utils.take_screenshot() at
module scope, so `import openadapt_capture` crashed in any headless
environment whose display reported a zero-size region. This took down
`openadapt version` and `openadapt doctor` (found via the new CLI smoke
tests in OpenAdaptAI/OpenAdapt). Move the computation into the video-
setup function that is its only consumer.
Adds tests/test_headless_import.py: a deterministic AST guard that no
package module calls a display API (take_screenshot/get_monitor_dims/
grab) at import scope. A subprocess import test is unreliable (only
reproduces on a genuinely headless display); this fails regardless of
environment.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent cd7ed78 commit d4e2016
2 files changed
Lines changed: 60 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | 145 | | |
149 | 146 | | |
150 | 147 | | |
| |||
546 | 543 | | |
547 | 544 | | |
548 | 545 | | |
| 546 | + | |
| 547 | + | |
549 | 548 | | |
550 | 549 | | |
551 | 550 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
0 commit comments