%PDF- %PDF-
| Direktori : /proc/thread-self/root/proc/self/root/lib/python2.7/site-packages/salt/utils/ |
| Current File : //proc/thread-self/root/proc/self/root/lib/python2.7/site-packages/salt/utils/powershell.pyo |
�
���^c @@ sk d Z d d l m Z m Z m Z d d l Z d d l Z d d l Z e j e
� Z d � Z d � Z
d S( u�
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.
i ( t absolute_importt print_functiont unicode_literalsNc C@ s
| t � k S( u�
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')
( t get_modules( t name( ( s9 /usr/lib/python2.7/site-packages/salt/utils/powershell.pyt
module_exists s c C@ s� t � } d } g } t j j d t j j d � � } d j t j j d d
� � } t j j d d � } d
j | � d d j | � d j | � g } d j | � } t j j d | � } | j d � } x0 | D]( } t j j | � r� | j | � q� q� W| st
j d � | Sx� | D]� } t j j | � s8qn x� t
j j j | � D]� \ }
} } x� | D]� }
t j j |
� \ } } | j � | k rdt j j t j j |
� � } | | k r�| j � | j � k r�| 2| j | � q�qdqdWqNWqW| S( u�
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()
u .psd1u .psm1u .cdxmlu .xamlu .dllu HOMEu HOMEPATHu {0}\System32u WINDIRu
C:\Windowsu ProgramFilesu C:\Program Filesu# {0}/.local/share/powershell/Modulesu# /usr/local/share/powershell/Modulesu# {0}\WindowsPowerShell\v1.0\Modules\u {0}\WindowsPowerShell\Modulesu ;u PSModulePathu Default paths not found( u .psd1u .psm1u .cdxmlu .xamlu .dll( t listt ost environt gett formatt joint splitt patht existst appendt logt errort isdirt saltt utilst os_walkt splitextt lowert basenamet normpath( t rett valid_extensionst
root_pathst home_dirt
system_dirt
program_filest
default_pathst ps_module_patht itemt root_patht root_dirt sub_dirst
file_namest file_namet base_namet file_extensiont dir_name( ( s9 /usr/lib/python2.7/site-packages/salt/utils/powershell.pyR . s@ !
%
( t __doc__t
__future__R R R t loggingR t salt.utils.pathR t getLoggert __name__R R R ( ( ( s9 /usr/lib/python2.7/site-packages/salt/utils/powershell.pyt <module>
s