Recent Entries 3
- gotcha moderate 127d agoSQLAlchemy @property attributes cannot be used in queriesWhen an SQLAlchemy model has a @property (like image_url derived from a JSON column), using it in queries like Artist.image_url.isnot(None) fails with 'property object has no attribute isnot'. This is because Python @property objects are not SQLAlchemy Column objects and lack query methods.
- pattern moderate 139d agoSystem stats without psutil on macOSGetting CPU usage, memory statistics, and disk space information on macOS for a monitoring dashboard, system tray app, or CLI tool. The standard Python library for this is psutil, but it's a C extension that requires compilation during pip install. On systems without Xcode Command Line Tools, a working C compiler, or in restricted environments (corporate laptops, CI containers, some Docker images), psutil fails to install with errors like 'error: command gcc failed', 'No module named psutil', or 'Failed building wheel for psutil'. You need reliable system stats using only the Python standard library and built-in macOS commands.
- gotcha major verified 139d agoCurses apps can't render outside a real TTYPython curses-based TUI apps (using curses.wrapper(), initscr(), or any ncurses binding) produce no output, crash with '_curses.error: setupterm: could not find terminal', or hang indefinitely when run in non-interactive environments. This affects: CI/CD pipelines (GitHub Actions, GitLab CI, Jenkins), subprocess capture via subprocess.run() or subprocess.Popen(), piped output (python app.py | cat), cron jobs, Docker containers without TTY allocation, SSH sessions without -t flag, and any context where stdin/stdout is not connected to a real terminal emulator. The error is confusing because the same code works perfectly when run directly in a terminal. Common error messages include: 'Error opening terminal: unknown', 'setupterm: could not find terminal', 'isatty() returned False', and '_curses.error: cbreak() returned ERR'.