demo/pwrap.py (129 lines) and demo/cwrap.py (124 lines) share ~95% identical code:
- Same API key loading logic (lines 12-20)
- Same yuyu loading logic
- Same name1/name2 loading logic
- Same init value loading logic
- Same polling/retry loop structure
- Same bare except: error handling
The only difference is the HTTP endpoint URL (/pm/ vs /ctl/) and which variable is input vs output. These should be refactored into a single shared module with the endpoint as a parameter.