webchanges.command module
Take actions from command line arguments.
- class webchanges.command.UrlwatchCommand(urlwatcher)
Bases:
objectThe class that runs the program after initialization and CLI arguments parsing.
- Parameters:
urlwatcher (Urlwatch)
- jobs_from_joblist()
Generates the jobs to process from the joblist entered in the CLI.
- Return type:
Iterator[JobBase]
- static show_features()
Prints the “features”, i.e. a list of job types, filters and reporters.
- Returns:
- Return type:
int
- list_jobs(regex)
Lists the job and their respective _index_number.
- Returns:
None.
- Parameters:
regex (bool | str)
- Return type:
None
- test_job(job_id)
Tests the running of a single job outputting the filtered text to –test-reporter (default is stdout).
If job_id is True, don’t run any jobs but load config, jobs and hook files to trigger any syntax errors.
- Parameters:
job_id (bool | str | int) – The job_id or True.
- Returns:
None.
- Raises:
Exception – The Exception when raised by a job. loading of hooks files, etc.
- Return type:
None
- prepare_jobs()
Runs jobs that have no history to populate the snapshot database when they’re newly added.
- Return type:
None
- test_differ(arg_test_differ)
Runs diffs for a job on all the saved snapshots.
Outputs the result to stdout or the reporter selected with –test-reporter.
- Parameters:
arg_test_differ (list[str]) – Either the job_id or a list containing [job_id, max_diffs]
- Returns:
1 if error, 0 if successful.
- Return type:
int
- dump_history(job_id)
Displays the historical data stored in the snapshot database for a job.
- Parameters:
job_id (str) – The Job ID.
- Returns:
An argument to be used in sys.exit.
- Return type:
int
- list_error_jobs()
- Return type:
int
- rollback_database(timespec)
Issues a warning, calls rollback() and prints out the result.
- Parameters:
timestamp – A timespec that if numeric is interpreted as a Unix timestamp otherwise it’s passed to dateutil.parser (if datetime is installed) or datetime.fromisoformat to be converted into a date.
timespec (str)
- Returns:
A sys.exit code (0 for succcess, 1 for failure)
- Return type:
int
- delete_snapshot(job_id)
- Parameters:
job_id (str | int)
- Return type:
int
- modify_urls()
- Return type:
int
- check_telegram_chats()
- Return type:
None
- check_test_reporter(job_state=None, label='test', report=None)
Tests a reporter by creating pseudo-jobs of new, changed, unchanged, and error outcomes (‘verb’).
Note: The report will only show new, unchanged and error content if enabled in the respective display keys of the configuration file.
- run_jobs_to_test_reporter()
Run the joblist and route the resulting report to a single reporter only.
Triggered by
--test-reporter <name>combined with a positional joblist. Acts as a one-shot override of the configured reporters: jobs are fetched, filtered, and diffed against the snapshot DB, but no new snapshots are persisted (read-only). Only the named reporter receives the report.- Returns:
Exit code (0 on success, 1 if the reporter name is not recognised).
- Return type:
int
- check_smtp_login()
- Return type:
None
- check_xmpp_login()
- Return type:
None
- static playwright_install_chrome()
Replicates playwright.___main__.main() function, which is called by the playwright executable, in order to install the browser executable.
- Returns:
Playwright’s executable return code.
- Return type:
int
- handle_actions()
Handles the actions for command line arguments and exits.
- Return type:
None
- run()
The main run logic.
- Return type:
None