Interview Prep/Python for DevOps/Automation scripting & CLI design

Your CLI needs to show progress for a 20-minute operation, but it also runs in CI. What do you do?

BeginnerScenarioAutomation scripting & CLI design
Answer

Situation read → Progress bars are great in terminals and garbage in CI logs.

What I'd do →

  1. Use tqdm or rich.progress only when sys.stderr.isatty(); otherwise log a line every N items or every 30 seconds.
  2. Write progress to stderr, never stdout.
  3. Respect NO_COLOR and a --quiet flag.

Why → Carriage-return progress bars produce thousands of log lines in CI.

Interview tip → TTY detection is the one-line answer.

All Python for DevOps questions Roadmap: Python for automation

More on Automation scripting & CLI design