Report Manager#
Summary
The ReportManager
is responsible for processing both the Excel spreadsheet and optional PDF reports.
- class ReportManager(config: ConfigManager, token_manager: TokenManager, api_client: ApiClient, excel_report: ExcelReport, pdf_report: PDFReport, ui_config: UIConfigManager, debug=False)[source]#
Handles the generation and management of patch reports within the patcher CLI tool.
This class coordinates various components such as configuration, token management, API interaction, and report generation (both Excel and PDF) to produce comprehensive reports on patch statuses.
Initializes the patcher class with the provided components.
- Parameters:
config (
ConfigManager
) – Manages the configuration settings, including credentials.token_manager (
TokenManager
) – Handles the authentication tokens required for API access..api_client (
ApiClient
) – Interacts with the Jamf API to retrieve data needed for reporting.excel_report (
ExcelReport
) – Generates Excel reports from collected patch data.pdf_report (
PDFReport
) – Generates PDF reports from the Excel files, adding visual elements..ui_config (
UIConfigManager
) – Manages the UI configuration for PDF report generation.debug (bool) – Enables debug mode if True, providing detailed logging.
- calculate_ios_on_latest(device_versions: List[Dict[str, str]], latest_versions: List[Dict[str, str]]) List[PatchTitle] | None [source]#
Analyzes the iOS version data to determine how many enrolled devices are on the latest version.
This method compares the operating system versions of managed devices with the latest versions provided by the SOFA feed, calculating how many devices are fully updated.
- Parameters:
- Returns:
A list of
PatchTitle
objects, each representing a summary of the patch status for an iOS version.- Return type:
Optional[List[PatchTitle]]
This method does not interact directly with the user but is crucial in the internal process of generating accurate reports that reflect the patch status across iOS devices.
- async process_reports(path: str | Path, pdf: bool, sort: str | None, omit: bool, ios: bool, date_format: str = '%B %d %Y') None [source]#
Asynchronously generates and saves patch reports, with options for customization.
This method is the core of the report generation process, orchestrating the collection of patch data, sorting, filtering, and ultimately saving the data to an Excel file. It can also generate a PDF report and include additional iOS device data.
- Parameters:
path (Union[str, Path]) – The directory where the reports will be saved. It must be a valid directory, not a file.
pdf (bool) – If True, generates PDF versions of the reports in addition to Excel.
sort (Optional[str]) – Specifies the column by which to sort the reports (e.g., ‘released’ or ‘completion_percent’).
omit (bool) – If True, omits patches that were released within the last 48 hours.
ios (bool) – If True, includes iOS device data in the reports.
date_format (str) – Specifies the date format for headers in the reports. Default is “%B %d %Y” (Month Day Year).
- Returns:
None
- Return type:
None
- Raises:
exceptions.DirectoryCreationError – If the provided path is a file or directories cannot be created.
exceptions.PolicyFetchError – If no policy IDs are retrieved.
exceptions.SummaryFetchError – If no patch summaries are retrieved.
exceptions.SortError – If sorting by an invalid column name.
exceptions.DeviceIDFetchError – If mobile device IDs cannot be retrieved.
exceptions.DeviceOSFetchError – If device OS versions cannot be retrieved.
exceptions.SofaFeedError – If there is an issue with retrieving data from the SOFA feed.
exceptions.ExportError – If there is an error exporting reports to Excel or PDF.
This function is not intended to be called directly by users, but rather is a key part of the CLI’s automated reporting process. It handles all the necessary steps from data collection to file generation, ensuring that reports are accurate, complete, and formatted according to the user’s preferences.