Bring every pattern from Modules 1–4 together in a single production-quality tool: devops-report, a command-line program that queries the GitHub REST API, formats results as JSON or YAML, writes a report to disk or stdout using pathlib, and handles errors with meaningful exit codes and structured logging. Each step builds one integration layer — argparse, token loading, API calls, report assembly, formatting, and output routing — before the final step assembles everything into devops-report.py: a complete runnable CLI that integrates venv, argparse, logging, exit codes, pathlib, os.environ, requests, Bearer auth, json.dumps, yaml.dump, and python-dotenv.
Create the lesson-501 working directory, copy .env and .gitignore from lesson 404, and confirm that all three third-party packages the tool needs — requests, PyYAML, and python-dotenv — are installed and importable alongside the stdlib modules.
mkdir -p ~/devops-python/lesson-501cd ~/devops-python/lesson-501source ~/devops-python/lesson-101/devops-env/bin/activatecp ~/devops-python/lesson-404/.env ~/devops-python/lesson-501/.envcp ~/devops-python/lesson-404/.gitignore ~/devops-python/lesson-501/.gitignorepip install requests PyYAML python-dotenvpip show requests PyYAML python-dotenv | grep '^Name\|^Version'python3 -c "import requests, yaml, datetime, pathlib, json, logging, argparse; from dotenv import load_dotenv; print('All imports OK'); print(' requests', requests.__version__); print(' PyYAML', yaml.__version__)"All three packages were installed in earlier lessons (requests in 401, PyYAML in 302, python-dotenv in 303), so pip install will print 'Requirement already satisfied' for each.
Running the command again is idempotent and confirms the exact installed versions.
The import check at the end verifies that requests, PyYAML, python-dotenv, datetime, pathlib, json, logging, and argparse are all importable in the devops-env virtualenv — all eight are needed in devops-report.py.
Lesson 402 introduced GITHUB_TOKEN as the standard credential env var; lesson 404 inherits that .env from lesson 403 and then appends WEBHOOK_SECRET.
Copying .env from lesson 404 is therefore safe: it already contains GITHUB_TOKEN, and devops-report.py simply ignores WEBHOOK_SECRET.
Only GITHUB_TOKEN is used in this lesson.
pip install prints 'Requirement already satisfied' for requests, PyYAML, and python-dotenv. pip show lists Name and Version for all three — expect requests 2.x, PyYAML 6.x, python-dotenv 1.x.
The import check prints 'All imports OK' followed by the requests and PyYAML version numbers — no ImportError.