File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/powershell.cpython-310.pyc
Back
o ;j� � @ s: d Z ddlZddlZddlZe�e�Zdd� Zdd� Z dS )a� Common functions for working with powershell .. note:: The PSModulePath environment variable should be set to the default location for PowerShell modules. This applies to all OS'es that support powershell. If not set, then Salt will attempt to use some default paths. If Salt can't find your modules, ensure that the PSModulePath is set and pointing to all locations of your Powershell modules. � Nc C s | t � v S )a� Check if a module exists on the system. Use this utility instead of attempting to import the module with powershell. Using powershell to try to import the module is expensive. Args: name (str): The name of the module to check Returns: bool: True if present, otherwise returns False Example: .. code-block:: python import salt.utils.powershell exists = salt.utils.powershell.module_exists('ServerManager') )�get_modules)�name� r �I/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/powershell.py� module_exists s r c C sT t � } d}g }tj�dtj�d��}d�tj�dd��}tj�dd�}|� d �d |� d�|� d�g}d �|�}tj�d|�}|�d �}|D ] }tj�|�rR|� |� qE|s\t �d� | S |D ]I} tj�| �sgq^t jj�| �D ]8\} }}|D ]0} tj�| �\}}|�� |v r�tj�tj�| ��}|| vr�|�� |�� kr�|dd�= | � |� quqnq^| S )a� Get a list of the PowerShell modules which are potentially available to be imported. The intent is to mimic the functionality of ``Get-Module -ListAvailable | Select-Object -Expand Name``, without the delay of loading PowerShell to do so. Returns: list: A list of modules available to Powershell Example: .. code-block:: python import salt.utils.powershell modules = salt.utils.powershell.get_modules() )z.psd1z.psm1z.cdxmlz.xamlz.dll�HOME�HOMEPATHz{}\System32ZWINDIRz C:\WindowsZProgramFileszC:\Program Filesz /.local/share/powershell/Modulesz#/usr/local/share/powershell/Modulesz \WindowsPowerShell\v1.0\Modules\z\WindowsPowerShell\Modules�;ZPSModulePathzDefault paths not foundN)�list�os�environ�get�format�join�split�path�exists�append�log�error�isdir�salt�utilsZos_walk�splitext�lower�basename�normpath)�retZvalid_extensionsZ root_pathsZhome_dirZ system_dirZ program_filesZ default_pathsZps_module_path�itemZ root_path�root_dirZsub_dirsZ file_names� file_name� base_nameZfile_extensionZdir_namer r r r , sH � � ���r ) �__doc__�loggingr Zsalt.utils.pathr � getLogger�__name__r r r r r r r �<module> s
| ver. 1.4 |
Github
|
.
| PHP 8.2.30 | Generation time: 0 |
proxy
|
phpinfo
|
Settings