Add structured logging, config validation, thread-safe cache, and Selenium improvements#198
Open
natiixnt wants to merge 2 commits into
Open
Conversation
…enium improvements - Replace status.py print/termcolor with Python logging module backed by RotatingFileHandler (5MB, 3 backups) writing to .mp/mpv2.log, while keeping colored console output for backwards compatibility - Add validate_config() with schema-based checking: required keys, types, email sub-structure, imagemagick_path existence, stt_provider values. Runs at startup in main.py and reports all issues before proceeding - Make cache.py thread-safe: all reads use fcntl.LOCK_SH, all writes use atomic temp-file + os.replace() with fcntl.LOCK_EX to prevent corruption when multiple CRON jobs run concurrently - Replace hardcoded time.sleep() waits in YouTube upload_video() with WebDriverWait + explicit expected_conditions for element presence/clickability - Add screenshot capture on upload failure for debugging - Replace stray print(colored()) calls in YouTube.py and Outreach.py with proper status functions (info/error/success) - Add 33 tests covering config validation, atomic cache writes, file locking, and structured logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
status.pyprint/termcolor output with Python'sloggingmodule. Logs rotate at 5MB with 3 backups in.mp/mpv2.log. Console output remains colored for backwards compatibility. Exposesget_logger()for modules that need direct logger access.validate_config()function with schema-based checking -- verifies required keys exist, types match, email sub-structure is complete,imagemagick_pathexists on disk, andstt_provideris a known value. Runs automatically at startup inmain.pyand prints all issues as warnings so users can fix their config before hitting cryptic errors later.fcntl.LOCK_SH(shared locks), all writes use atomic temp-file +os.replace()withfcntl.LOCK_EX(exclusive locks). This prevents cache corruption when multiple CRON jobs run concurrently against the same.mp/*.jsonfiles.time.sleep()waits in YouTubeupload_video()withWebDriverWait+ explicitexpected_conditions(presence/clickability). Adds automatic screenshot capture on upload failure for debugging. Adds helper methods_wait_and_find()and_wait_and_click().print(colored(...))calls inYouTube.pyandOutreach.pywith properinfo()/error()/success()functions.Test plan
python -m pytest tests/ -v)python src/main.pyto verify config validation prints warnings for missing/invalid values.mp/mpv2.logis created after first run