File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/mac_softwareupdate.cpython-310.pyc
Back
o ;j: � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddl m Z mZ dZdd� Z d)dd �Zd)d d�Zdd � Zdd� Zdd� Zdd� Zdd� Zd*dd�Zdd� Zdd� Zdd� Zdd � Zd*d!d"�Zd#d$� Zd%d&� Zd'd(� ZdS )+z2 Support for the softwareupdate command on MacOS. � N)�CommandExecutionError�SaltInvocationError�softwareupdatec C s t jj�� sdS tS )z Only for MacOS )FzRThe softwareupdate module could not be loaded: module only works on MacOS systems.)�salt�utils�platformZ is_darwin�__virtualname__� r r �S/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/mac_softwareupdate.py�__virtual__ s r Fc s� ddg}t jj�|�}td d dkstd d dkr!t�d�}nt�d �}g � t jj�| �r6� � d d� � t jj�|�rD� � dd� � t jj�|�rR� � d d� � � fdd�|� |�D �S )z Utility function to get all available update packages. Sample return date: { 'updatename': '1.2.3-45', ... } r �--listZosrelease_infor � � � z�(?m)^\s*[*-] Label: (?P<name>[^ ].*)[\r\n].*Version: (?P<version>[^,]*), Size: (?P<size>[^,]*),\s*(?P<recommended>Recommended: YES,)?\s*(?P<action>Action: (?:restart|shut down),)?z�(?m)^\s+[*-] (?P<name>.*)[\r\n].*\((?P<version>[^ \)]*)[^\r\n\[]*(?P<recommended>\[recommended\])?\s?(?P<action>\[(?:restart|shut down)\])?c S s | � d�S )N�recommended��group��mr r r �<lambda>\ s z _get_available.<locals>.<lambda>c S � d| � d�pdv S )N�restart�action� r r r r r r _ � c S r )Nz shut downr r r r r r r r c r c s4 i | ]� t � fd d��D ��r� �d�� �d��qS )c 3 s � | ]}|� �V qd S )Nr )�.0�fr r r � <genexpr>i s � z,_get_available.<locals>.<dictcomp>.<genexpr>�name�version)�allr )r �Z conditionsr r � <dictcomp>f s ��z"_get_available.<locals>.<dictcomp>)r r � mac_utils�execute_return_resultZ __grains__�re�compile�dataZis_true�append�finditer)r r � shut_down�cmd�out�rexpr r! r �_get_available s. ���� �r. c C s t | ||�S )aL List all available updates. :param bool recommended: Show only recommended updates. :param bool restart: Show only updates that require a restart. :return: Returns a dictionary containing the updates :rtype: dict CLI Example: .. code-block:: bash salt '*' softwareupdate.list_available �r. )r r r* r r r �list_availablem s r0 c C s2 | � dd�d }dd|g}tjj�|� |t� v S )a- Ignore a specific program update. When an update is ignored the '-' and version number at the end will be omitted, so "SecUpd2014-001-1.0" becomes "SecUpd2014-001". It will be removed automatically if present. An update is successfully ignored when it no longer shows up after list_updates. :param name: The name of the update to add to the ignore list. :ptype: str :return: True if successful, False if not :rtype: bool CLI Example: .. code-block:: bash salt '*' softwareupdate.ignore <update-name> �-r r r �--ignore)�rsplitr r r# �execute_return_success�list_ignored)r Z to_ignorer+ r r r �ignore� s r6 c C s* g d�} t jj�| �}t�d�}|�|�S )aE List all updates that have been ignored. Ignored updates are shown without the '-' and version number at the end, this is how the softwareupdate command works. :return: The list of ignored updates :rtype: list CLI Example: .. code-block:: bash salt '*' softwareupdate.list_ignored )r r r2 z'(?m)^ ["]?([^,|\s].*[^"|\n|,])[,|"]?)r r r# r$ r% r&