qgis_deployment_toolbelt.jobs.job_cleanup_manager module

QDT autocleaner to remove stale resources generated by previous deployments.

Author: Julien Moura (https://github.com/guts)

class qgis_deployment_toolbelt.jobs.job_cleanup_manager.CleanupManagerOptions(*, deletion_policy: Literal['force_delete', 'trash_only', 'trash_or_delete'] | None = None, dry_run: bool = False, scopes: list[Literal['plugins_cache', 'plugins_installed', 'profiles_deprecated', 'profiles_incompatible_qgis', 'shortcuts_orphans_manifest', 'shortcuts_orphans_mark']] = ['plugins_cache'])

Bases: JobOptions

Options of the cleanup-manager job.

_abc_impl = <_abc._abc_data object>
deletion_policy: Literal['force_delete', 'trash_only', 'trash_or_delete'] | None

deletion policy tp apply None = QDT_DELETION_POLICY environment variable

dry_run: bool

only log what would be removed, without deleting anything

model_config = {'extra': 'forbid', 'frozen': True, 'strict': True, 'validate_default': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

scopes: list[Literal['plugins_cache', 'plugins_installed', 'profiles_deprecated', 'profiles_incompatible_qgis', 'shortcuts_orphans_manifest', 'shortcuts_orphans_mark']]

kinds of stale resources to clean up

class qgis_deployment_toolbelt.jobs.job_cleanup_manager.JobCleanupManager(options: dict | None)

Bases: GenericJob

Job to remove stale resources left over by previous QDT deployments.

ID: str = 'cleanup-manager'
OPTIONS

alias of CleanupManagerOptions

__init__(options: dict | None) → None

Instantiate the class.

Parameters:

options (dict | None) – options set in the with key of the scenario step, see CleanupManagerOptions

_abc_impl = <_abc._abc_data object>
_referenced_plugin_ids() → set[str]

Union of plugin identifiers (id_with_version) referenced by every installed and downloaded profile currently known to QDT.

Returns:

set of plugin identifiers (as used in archive filenames and

installation folder names)

Return type:

set[str]

_referenced_plugin_installation_folders() → set[Path]

Union of plugin installation path referenced by every installed and downloaded profile currently known to QDT.

Returns:

plugin folder paths

Return type:

set[Path]

_remove_paths() → None

Remove files and folders listed in the self.report.removed.

cleanup_plugins_cache() → None

Remove plugin archives from the QDT plugins cache folder which are not referenced by any installed or downloaded profile anymore.

cleanup_plugins_installed() → None

Remove stale plugin folders from installed QGIS profiles.

Only plugins listed in QDT managed plugins manifests are considered for cleanup. Third-party plugins manually installed by users are ignored.

cleanup_profiles_deprecated() → None

Remove installed QGIS profiles flagged as deprecated in the downloaded repositories.

The downloaded repositories are the source of truth: deprecated profiles are not synchronized, so the flag never reaches the installed profile.json. A profile still provided as active by another repository is kept.

cleanup_profiles_incompatible_qgis() → None

Remove installed QGIS profiles whose qgisMinimumVersion or qgisMaximumVersion, as declared in the downloaded repositories, exclude the targeted QGIS version.

The downloaded repositories are the source of truth. Nothing is removed if the targeted QGIS version is unknown.

cleanup_shortcuts_orphans_manifest() → None

Remove shortcuts listed in the QDT managed shortcuts manifest whose profile is not installed anymore, including profiles selected for removal by the previous scopes.

cleanup_shortcuts_orphans_mark() → None

Remove shortcuts recognized from their description as created by QDT, in the user desktop and start menu folders, whose profile folder does not exist anymore, including profiles selected for removal by the previous scopes.

run() → CleanupReport

Execute job logic.

Returns:

summary of removed/failed resources

Return type:

CleanupReport