rattail.problems.handlers

Problem Report Handlers

class rattail.problems.handlers.ProblemReportHandler(config, dry_run=False, progress=None)[source]

Base class and default implementation for problem report handlers.

get_all_problem_reports()[source]

Returns a simple list of all ProblemReport subclasses which are “available” according to config.

get_global_email_context(**kwargs)[source]

This method can be used to add extra context for all email templates.

get_problem_report(system_key, problem_key, **kwargs)[source]

Return a specific problem report, identified by the system/problem key pair.

Parameters:
  • system_key – System key, part of the identifier.

  • problem_key – Problem key, part of the identifier.

Returns:

A specific ProblemReport class, if a match was found, otherwise None.

get_problem_reports(systems=None, problems=None)[source]

Return a list of all problem reports which match the given criteria.

Parameters:
  • systems – Optional list of “system keys” which a problem report must match, in order to be included in return value.

  • problems – Optional list of “problem keys” which a problem report must match, in order to be included in return value.

Returns:

List of problem reports; may be an empty list.

get_report_email_context(report, problems, **kwargs)[source]

This method can be used to add extra context for a specific report’s email template.

get_system_title(system_key)[source]

Should return a “display title” for the given system.

is_enabled(report)[source]

Returns boolean indicating if the given problem report is enabled.

normalize_problem_report(report, include_schedule=False, include_recipients=False, **kwargs)[source]

Return a normalized data dictionary for the given problem report.

Parameters:
  • include_schedule – If true, data dict will include the enabled field, as well as the day0 thru day6 flag fields.

  • include_recipients – If true, data dict will include the email_recipients field, which is a list of email addresses.

organize_problem_reports(reports)[source]

Returns a nested dict with the given problem reports.

render_time(time, from_utc=True)[source]

Render the given timestamp, localizing if necessary.

run_problem_report(problem_report, fix=False, send=True, force=False, **kwargs)[source]

Run the given problem report, if it is enabled and scheduled to run for the current day.

Parameters:

force – If true, the report will run regardless of whether it is enabled at all / for the current day. If false (the default) then the report’s enabled flags will determine whether we should actually run it now.

run_problem_reports(reports, fix=False, force=False, **kwargs)[source]

Run the given set of problem reports.

Parameters:

fix – This flag will be passed as-is to run_problem_report().

send_problem_report(report, problems)[source]

Send out an email with details of the given problem report.

should_run_for_day(report, day)[source]

Returns boolean indicating if the given problem report should be ran for the given weekday.

Parameters:

day – Integer corresponding to a particular weekday. Uses the same conventions as Python itself, i.e. Monday is represented as zero (0).

supported_systems()[source]

Returns list of keys for all systems which are supported by any of the available problem reports, according to config.

rattail.problems.handlers.get_problem_report_handler(config, **kwargs)[source]

Create and return the configured ProblemReportHandler instance.