File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/mac_service.cpython-310.pyc
Back
o ;j�N � @ s> d Z ddlZddlZddlZddlZddlZddlZddlm Z ddl mZ dZddiZ e�e�Zdd d dd�Zd d� Zdd� Zdd� Zdd� Zd:dd�Zdd� Zdd� Zdd� Zd;dd�Zd<dd �Zd<d!d"�Zd<d#d$�Zd<d%d&�Zd<d'd(�Zd;d)d*�Z d+d,� Z!d-d.� Z"d<d/d0�Z#d=d2d3�Z$d<d4d5�Z%d<d6d7�Z&d<d8d9�Z'dS )>az The service module for macOS .. versionadded:: 2016.3.0 This module has support for services in the following locations. .. code-block:: bash /System/Library/LaunchDaemons/ /System/Library/LaunchAgents/ /Library/LaunchDaemons/ /Library/LaunchAgents/ # As of version "2019.2.0" support for user-specific services were added. /Users/foo/Library/LaunchAgents/ .. note:: As of the 2019.2.0 release, if a service is located in a ``LaunchAgent`` path and a ``runas`` user is NOT specified, the current console user will be used to properly interact with the service. .. note:: As of the 3002 release, if a service name of ``salt-minion`` is passed this module will convert it over to it's macOS equivalent name, in this case to ``com.saltstack.salt.minion``. This is true for ``salt-master`` ``salt-api``, and ``salt-syndic`` as well. � N)�CommandExecutionError)�Version�service�list_�listzcom.saltstack.salt.minionzcom.saltstack.salt.masterzcom.saltstack.salt.apizcom.saltstack.salt.syndic)zsalt-minionzsalt-masterzsalt-apizsalt-syndicc C sP t jj�� sdS t jj�d�sdS t jj�d�sdS ttd �td�k r&dS tS ) z' Only for macOS with launchctl )FzGFailed to load the mac_service module: Only available on macOS systems.� launchctl)FzMFailed to load the mac_service module: Required binary not found: "launchctl"Zplutil)FzJFailed to load the mac_service module: Required binary not found: "plutil"Z osreleasez10.11)FzDFailed to load the mac_service module: Requires macOS 10.11 or newer) �salt�utils�platformZ is_darwin�path�whichr Z __grains__�__virtualname__� r r �L/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/mac_service.py�__virtual__: s r c C sd | |v r|| S |� � D ]"}|d �� | kr| S tj�|d �\}}|�� | kr.| S qt� S )a+ Checks to see if the given service is in the given services. :param str name: Service label, file name, or full path :param dict services: The currently available services. :return: The service information for the service, otherwise an empty dictionary :rtype: dict � file_path� file_name)�values�lower�osr �splitext�dict)�name�servicesr �basename�extr r r �_name_in_services[ s �r c C s� t d � }t�| | ��� } t| |�}|r|S z td s"td| � ���W n ty, Y nw t�d�dkr;td| � ���t d dd�}t| |�}|sPtd| � ���|S )z� Get information about a service. If the service is not found, raise an error :param str name: Service label, file name, or full path :return: The service information for the service, otherwise an Error :rtype: dict �mac_utils.available_servicesZusing_cached_serviceszService not found: z service.stateZdeadT)Zrefresh)� __utils__�SALT_MAC_SERVICES�getr r �__context__r �KeyError)r r r r r r �_get_servicex s&