qgis_deployment_toolbelt.jobs.job_shortcuts module

Manage application shortcuts on end-user machine.

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

class qgis_deployment_toolbelt.jobs.job_shortcuts.JobShortcutsManager(options: dict)

Bases: GenericJob

Job to create or remove shortcuts on end-user machine.

ID: str = 'shortcuts-manager'
OPTIONS_SCHEMA: dict = {'action': {'condition': 'in', 'default': 'create_or_restore', 'possible_values': ('create', 'create_or_restore', 'remove'), 'required': False, 'type': <class 'str'>}, 'include': {'condition': None, 'default': None, 'possible_values': None, 'required': False, 'sub_options': {'additional_arguments': {'condition': None, 'default': None, 'possible_values': None, 'required': False, 'type': <class 'str'>}, 'desktop': {'condition': None, 'default': False, 'possible_values': None, 'required': False, 'type': <class 'bool'>}, 'icon': {'condition': None, 'default': None, 'possible_values': None, 'required': False, 'type': <class 'str'>}, 'label': {'condition': None, 'default': 'QGIS', 'possible_values': None, 'required': False, 'type': <class 'str'>}, 'profile': {'condition': None, 'default': None, 'possible_values': None, 'required': True, 'type': <class 'str'>}, 'start_menu': {'condition': None, 'default': True, 'possible_values': None, 'required': False, 'type': <class 'bool'>}}, 'type': (<class 'list'>, <class 'str'>)}}
SHORTCUTS_CREATED: list = []
SHORTCUTS_REMOVED: list = []
__init__(options: dict) None

Instantiate the class.

Parameters:

options (dict) – profiles source (remote, can be a local network) and

destination (local).

get_arguments_ready(profile: str, in_arguments: str | None = None) list[str]

Prepare arguments for the executable shortcut.

Parameters:
  • profile (str) – profile’s name

  • in_arguments (str, optional) – argument as defined in the scenario file. Defaults to None.

Returns:

tuple of strings separated by spaces

Return type:

list[str]

get_icon_path(profile: QdtProfile, icon_filename: str) Path | None

Get icon path to use with the shortcut. Looking for:

  1. checks if an icon key has been specified in the profile.json file and

    if it exists

  2. checks if an icon has been specified into scenario and if it exists

    within profile folder (in QGIS)

  3. checks if an icon has been specified into scenario and if it exists under

    a subfolder starting from the toolbelt (and handling pathlib OSError)

Parameters:
  • profile (QdtProfile) – QGIS profile object

  • icon_filename (str) – icon path as mentioned into the scenario file

Returns:

icon path as Path if str or Path, else None

Return type:

Path

get_matching_profile_from_name(li_profiles: list[QdtProfile], profile_name: str) QdtProfile

Get a profile from list of profiles using a profile’s name to match.

Parameters:
  • li_profiles (list[QdtProfile]) – list of profile to look into

  • profile_name (str) – profile name

Returns:

matching profile object

Return type:

QdtProfile

run() None

Execute job logic.