Python for DevOps
You're viewing a free preview. Sign in free to read every script.
Why this exists Scripts run unattended: from cron, from a pipeline, from a deployment job. When something goes wrong at 3 a.m., there are exactly three things that tell you what happened: the log , the exit code , and…
Python for DevOps: Exceptions, Custom Errors, logging and Meaningful Exit Codes
Make a script that fails well: catch the narrowest exception you can handle, define your own error classes with a cause, use try/except/else/finally correctly, log instead of print, and turn each kind of failure into a distinct exit code that CI and cron can act on.
Sign in free to read this script, along with the rest of the library.
Sign in free