%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/win_psget.pyc

�
���^c@@sdZddlmZmZmZddlZddlZddlZddl	Zddl
ZddlmZej
e�ZdZd�Zddd�Zd	�Zed
�Zed�Zddddd�Zddd
�Zd�Zdd�Zd�ZdS(u�
Module for managing PowerShell through PowerShellGet (PSGet)

:depends:
    - PowerShell 5.0
    - PSGet

Support for PowerShell
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrorupsgetcC@s�tjjj�s)tjd�tdfStdd�}|dsZtjd�tdfStjjj	|ddd�r�tjd	�td
fSt
S(u8
    Set the system module of the kernel is Windows
    u/Module PSGet: Only available on Windows systemsucmd.shell_infou
powershellu	installedu!Module PSGet: Requires PowerShelluversionu<u5.0u,Module PSGet: Requires PowerShell 5 or neweru-Module PSGet: Requires PowerShell 5 or newer.(tsalttutilstplatformt
is_windowstlogtdebugtFalset__salt__tversionstcomparet__virtualname__(tpowershell_info((s:/usr/lib/python2.7/site-packages/salt/modules/win_psget.pyt__virtual__s






icC@s�d|j�kr'dj||�}ntjd|�td|ddd|dt�}d	|kro|d	=nd
|ks�|d
dkr�tdj|�d
|��ny#tjj	j
|ddt�}Wn#tk
r�tdd
|��nX|S(u}
    Execute the desired powershell command and ensure that it returns data
    in json format and load that into python
    uconvertto-jsonu{0} | ConvertTo-Json -Depth {1}uDSC: %sucmd.run_alltshellu
powershelltcwdtpython_shellupiduretcodeiuIssue executing powershell {0}tinfoustdouttstrictuNo JSON results from powershell(
tlowertformatRR	RtTrueRRRtjsontloadsR
t
ValueError(tcmdRt
json_depthtresultstret((s:/usr/lib/python2.7/site-packages/salt/modules/win_psget.pyt_pshell5s"
#
cC@sd}t|�}|S(u�
    Make sure that nuget-anycpu.exe is installed.
    This will download the official nuget-anycpu.exe from the internet.

    CLI Example:

    .. code-block:: bash

        salt 'win01' psget.bootstrap
    u/Get-PackageProvider -Name NuGet -ForceBootstrap(R (RR((s:/usr/lib/python2.7/site-packages/salt/modules/win_psget.pyt	bootstrapNscC@skd}t|�}g}|r'i}nx=|D]5}|rR|d||d<q.n|j|d�q.W|S(u:
    List available modules in registered Powershell module repositories.

    :param desc: If ``True``, the verbose description will be returned.
    :type  desc: ``bool``

    CLI Example:

    .. code-block:: bash

        salt 'win01' psget.avail_modules
        salt 'win01' psget.avail_modules desc=True
    uFind-ModuleuDescriptionuName(R tappend(tdescRtmodulestnamestmodule((s:/usr/lib/python2.7/site-packages/salt/modules/win_psget.pyt
avail_modules^s	
cC@s�d}t|�}t|t�rig}|rTi}tj|�||d<|}|S|j|d�|Sg}|r~i}nx9|D]1}|r�|||d<q�n|j|d�q�W|S(u)
    List currently installed PSGet Modules on the system.

    :param desc: If ``True``, the verbose description will be returned.
    :type  desc: ``bool``

    CLI Example:

    .. code-block:: bash

        salt 'win01' psget.list_modules
        salt 'win01' psget.list_modules desc=True
    uGet-InstalledModuleuName(R t
isinstancetdicttcopytdeepcopyR"(R#RR$Rtmodules_retR%R&((s:/usr/lib/python2.7/site-packages/salt/modules/win_psget.pytlist_modulesys(	
c
C@s�d|fg}|d	k	r1|jd|f�n|d	k	rS|jd|f�n|d	k	ru|jd|f�n|d	k	r�|jd|f�nd}x*|D]"\}}|dj||�7}q�Wdj|�}	t|	�|t�kS(
u�
    Install a Powershell module from powershell gallery on the system.

    :param name: Name of a Powershell module
    :type  name: ``str``

    :param minimum_version: The maximum version to install, e.g. 1.23.2
    :type  minimum_version: ``str``

    :param required_version: Install a specific version
    :type  required_version: ``str``

    :param scope: The scope to install the module to, e.g. CurrentUser, Computer
    :type  scope: ``str``

    :param repository: The friendly name of a private repository, e.g. MyREpo
    :type  repository: ``str``

    CLI Example:

    .. code-block:: bash

        salt 'win01' psget.install PowerPlan
    uNameuMinimumVersionuRequiredVersionuScopeu
Repositoryuu	-{0} {1} uInstall-Module {0} -ForceN(tNoneR"RR R-(
tnametminimum_versiontrequired_versiontscopet
repositorytflagstparamstflagtvalueR((s:/usr/lib/python2.7/site-packages/salt/modules/win_psget.pytinstall�s
cC@s�d|fg}|dk	r1|jd|f�n|dk	rS|jd|f�nd}x*|D]"\}}|dj||�7}q`Wdj|�}t|�|t�kS(u�
    Update a PowerShell module to a specific version, or the newest

    :param name: Name of a Powershell module
    :type  name: ``str``

    :param maximum_version: The maximum version to install, e.g. 1.23.2
    :type  maximum_version: ``str``

    :param required_version: Install a specific version
    :type  required_version: ``str``

    CLI Example:

    .. code-block:: bash

        salt 'win01' psget.update PowerPlan
    uNameuMaximumVersionuRequiredVersionuu	-{0} {1} uUpdate-Module {0} -ForceN(R.R"RR R-(R/tmaximum_versionR1R4R5R6R7R((s:/usr/lib/python2.7/site-packages/salt/modules/win_psget.pytupdate�s
cC@s(dj|�}t|�}|t�kS(u�
    Remove a Powershell DSC module from the system.

    :param  name: Name of a Powershell DSC module
    :type   name: ``str``

    CLI Example:

    .. code-block:: bash

        salt 'win01' psget.remove PowerPlan
    uUninstall-Module "{0}"(RR R-(R/Rtno_ret((s:/usr/lib/python2.7/site-packages/salt/modules/win_psget.pytremove�sc	C@s�d|fg}|jd|f�|dk	rD|jd|f�nd}x*|D]"\}}|dj||�7}qQWdj|�}t|�}|t�kS(u�
    Register a PSGet repository on the local machine

    :param name: The name for the repository
    :type  name: ``str``

    :param location: The URI for the repository
    :type  location: ``str``

    :param installation_policy: The installation policy
        for packages, e.g. Trusted, Untrusted
    :type  installation_policy: ``str``

    CLI Example:

    .. code-block:: bash

        salt 'win01' psget.register_repository MyRepo https://myrepo.mycompany.com/packages
    uNameuSourceLocationuInstallationPolicyuu	-{0} {1} uRegister-PSRepository {0}N(R"R.RR R-(	R/tlocationtinstallation_policyR4R5R6R7RR;((s:/usr/lib/python2.7/site-packages/salt/modules/win_psget.pytregister_repositoryscC@s(dj|�}t|�}|t�kS(u�
    Get the details of a local PSGet repository

    :param  name: Name of the repository
    :type   name: ``str``

    CLI Example:

    .. code-block:: bash

        salt 'win01' psget.get_repository MyRepo
    uGet-PSRepository "{0}"(RR R-(R/RR;((s:/usr/lib/python2.7/site-packages/salt/modules/win_psget.pytget_repository#s(t__doc__t
__future__RRRR*tloggingtsalt.utils.jsonRtsalt.utils.platformtsalt.utils.versionstsalt.exceptionsRt	getLoggert__name__RRRR.R R!R
R'R-R8R:R<R?R@(((s:/usr/lib/python2.7/site-packages/salt/modules/win_psget.pyt<module>
s(		$	,#	#

Zerion Mini Shell 1.0