%PDF- %PDF-
| Direktori : /proc/self/root/proc/3522530/root/usr/lib/python2.7/site-packages/salt/modules/ |
| Current File : //proc/self/root/proc/3522530/root/usr/lib/python2.7/site-packages/salt/modules/win_wusa.pyc |
�
���^c @@ s� d Z d d l m Z m Z d d l Z d d l Z d d l Z d d l m Z e j
e � Z d Z
d � Z d d � Z d � Z e d � Z e d
� Z d � Z d S( u�
Microsoft Update files management via wusa.exe
:maintainer: Thomas Lemarchand
:platform: Windows
:depends: PowerShell
.. versionadded:: 2018.3.4
i ( t absolute_importt unicode_literalsN( t CommandExecutionErroru wusac C@ sM t j j j � s t d f St d d d d t � } | d sI t d f St S( u
Load only on Windows
u! Only available on Windows systemsu cmd.shell_infot shellu
powershellt list_modulesu installedu PowerShell not available( t saltt utilst platformt
is_windowst Falset __salt__t __virtualname__( t powershell_info( ( s9 /usr/lib/python2.7/site-packages/salt/modules/win_wusa.pyt __virtual__ s
c C@ sE d | j � k r$ d j | � } n t j d | � t d | d d d | �} d | k rf | d =n | j d d
� r� | d j � d } t | d | �� n d
| k s� | d
d k r� t d j | � d | �� n | d d
k r� d | d <n y# t j j
j | d d t �} Wn# t
k
r@t d d | �� n X| S( u}
Execute the desired powershell command and ensure that it returns data
in JSON format and load that into python
u convertto-jsonu {0} | ConvertTo-Jsonu PowerShell: %su cmd.run_allR u
powershellt cwdu pidu stderru i t infou retcodeu Issue executing PowerShell {0}u stdoutu {}t strictu No JSON results from PowerShell( t lowert formatt logt debugR
t gett
splitlinesR R R t jsont loadsR t
ValueError( t cmdR t rett error( ( s9 /usr/lib/python2.7/site-packages/salt/modules/win_wusa.pyt _pshell_json) s(
#
c C@ s, t d d d j | � d d d t � d k S( u
Check if a specific KB is installed.
Args:
name (str):
The name of the KB to check
Returns:
bool: ``True`` if installed, otherwise ``False``
CLI Example:
.. code-block:: bash
salt '*' wusa.is_installed KB123456
u cmd.retcodeR u Get-HotFix -Id {0}R u
powershellt ignore_retcodei ( R
R t True( t name( ( s9 /usr/lib/python2.7/site-packages/salt/modules/win_wusa.pyt is_installedL s c C@ s� d | d g } | r% | j d � n
| j d � t d | d t �} t j j | � } i d j | � d 6d d
6} | | k r� t | | � � n | r� t d j | � � � n t S( u�
Install a KB from a .msu file.
Args:
path (str):
The full path to the msu file to install
restart (bool):
``True`` to force a restart if required by the installation. Adds
the ``/forcerestart`` switch to the ``wusa.exe`` command. ``False``
will add the ``/norestart`` switch instead. Default is ``False``
Returns:
bool: ``True`` if successful, otherwise ``False``
Raise:
CommandExecutionError: If the package is already installed or an error
is encountered
CLI Example:
.. code-block:: bash
salt '*' wusa.install C:/temp/KB123456.msu
u wusa.exeu /quietu
/forcerestartu
/norestartu cmd.retcodeR u {0} is already installedi $ u
Unknown erroriW u Unknown error: {0}( t appendR
R t ost patht basenameR R ( R$ t restartR t ret_codet file_namet errors( ( s9 /usr/lib/python2.7/site-packages/salt/modules/win_wusa.pyt installc s
c C@ s/ d d d g } t j j t j j | � � d } t j j | � rS | j | � n5 | j d j | j � j d � r~ | d n | � � | r� | j d � n
| j d � t d
| d t
�} i d j | � d
6d j | � d 6d d 6} | | k r
t | | � � n | r+t d j | � � � n t
S( u�
Uninstall a specific KB.
Args:
path (str):
The full path to the msu file to uninstall. This can also be just
the name of the KB to uninstall
restart (bool):
``True`` to force a restart if required by the installation. Adds
the ``/forcerestart`` switch to the ``wusa.exe`` command. ``False``
will add the ``/norestart`` switch instead. Default is ``False``
Returns:
bool: ``True`` if successful, otherwise ``False``
Raises:
CommandExecutionError: If an error is encountered
CLI Example:
.. code-block:: bash
salt '*' wusa.uninstall KB123456
# or
salt '*' wusa.uninstall C:/temp/KB123456.msu
u wusa.exeu
/uninstallu /quieti u /kb:{0}u kbi u
/forcerestartu
/norestartu cmd.retcodeR u {0} does not support uninstalli $�u {0} not installedi $ u* Unknown error. Try specifying an .msu fileiW u Unknown error: {0}( R# R$ t splitextR% t existsR"