Anons79 Mini Shell

Directory : /proc/self/root/lib/python2.7/site-packages/ansible/plugins/shell/
Upload File :
Current File : //proc/self/root/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pyo

�
�Udac@`s�ddlmZmZmZeZdZddlZddlZddl	Z	ddl
Z
ddlZddlj
jZddlZddlmZddlmZmZddlmZddd	d
dgZdd
�Zdefd��YZdS(i(tabsolute_importtdivisiontprint_functions_
name: powershell
plugin_type: shell
version_added: historical
short_description: Windows PowerShell
description:
- The only option when using 'winrm' or 'psrp' as a connection plugin.
- Can also be used when using 'ssh' as a connection plugin and the C(DefaultShell) has been configured to PowerShell.
extends_documentation_fragment:
- shell_windows
N(tAnsibleError(tto_bytestto_text(t	ShellBaset
PowerShells
-NoProfiles-NonInteractives-ExecutionPolicytUnrestrictedtErrorc
C`s�g}x�|r�|jd�d}||jd�|!}||}tj|�}tjd|j�}|rd|jd�nd}|jd|�}|jg|D]3}	|	j	j
d	�|kr�|	jjd
d�^q��q	Wt
dj|��S(s�
    Takes a byte string like '#< CLIXML
<Objs...' and extracts the stream
    message encoded in the XML data. CLIXML is used by PowerShell to encode
    multiple objects in stderr.
    s</Objs>is<Objs s{(.*)}s{%s}its./%sStSt_x000D__x000A_s
(tfindtETt
fromstringtretmatchttagtgrouptfindalltextendtattribtgetttexttreplaceRtjoin(
tdatatstreamtlinestend_idxtcurrent_elementtclixmltnamespace_matcht	namespacetstringste((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pyt
_parse_clixml#s	
KtShellModulecB`s
eZe�ZdZdZdZeZe	�Z
ejd�Z
d�Zd�Zd�Zd�Zd�Zd	�Zd
�Zd�Zd�Zed
�Zdeddd�Zdd�Zd�Zd�Zdd�Zd�Zd�Z d�Z!eeed�Z"RS(t
powershells> $nullt;s^[\d\w_]{1,255}$cC`s)|jj|�s%td|��n|S(Ns&Invalid PowerShell environment key: %s(tsafe_envkeyRR(tselftkey((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pytassert_safe_env_keyVscC`sGt|�dkr%td|��n|jdd�}t|dd�S(Ni�sLPowerShell environment value for key '%s' exceeds 32767 characters in lengtht's''terrorstsurrogate_or_strict(tlenRRR(R*R+tvalue((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pytsafe_env_value[scK`sdS(NR
((R*tkwargs((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pyt
env_prefixbscG`s_g|D]}tj|j|��^q}tj|dg|dD]}|jd�^qC�S(Niis\(tntpathtnormpatht_unquoteRtstrip(R*targstargtpartstpart((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pyt	join_pathfs+cC`sZtjj|j��}tjj|j��\}}|j�dkrP|dS|j�S(Ns.ps1s.exe(s.ps1s.exe(tostpathtbasenameR8tsplitexttlower(R*tpathnamet	base_nametnametext((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pytget_remote_filenameos
cC`s+|j|�}|jd�p*|jd�S(Nt/s\(R7tendswith(R*R?((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pytpath_has_trailing_slashxscC`std��dS(Ns'chmod is not implemented for Powershell(tNotImplementedError(R*tpathstmode((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pytchmod}scC`std��dS(Ns'chown is not implemented for Powershell(RK(R*RLtuser((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pytchown�scC`std��dS(Ns/set_user_facl is not implemented for Powershell(RK(R*RLRORM((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pyt
set_user_facl�scC`sD|j|j|��}|r/|jd|�S|jd|�SdS(Ns!Remove-Item '%s' -Force -Recurse;sRemove-Item '%s' -Force;(t_escapeR7t_encode_script(R*R?trecurse((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pytremove�scC`sn|s|jj�}n|j|j|��}|r<|n|jd�}d||f}|j|j��S(Nt
remote_tmps�
        $tmp_path = [System.Environment]::ExpandEnvironmentVariables('%s')
        $tmp = New-Item -Type Directory -Path $tmp_path -Name '%s'
        Write-Output -InputObject $tmp.FullName
        (t	__class__t_generate_temp_dir_nameRRR7t
get_optionRSR8(R*tbasefiletsystemRMttmpdirt
basetmpdirtscript((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pytmkdtemp�sR
cC`sm|j|�}|dkr$d}n<|jd�rMd|j|d�}nd|j|�}|j|�S(Nt~s Write-Output (Get-Location).Paths~\s)Write-Output ((Get-Location).Path + '%s')isWrite-Output '%s'(R7t
startswithRRRS(R*tuser_home_pathtusernameR^((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pytexpand_user�s	cC`s/|j|j|��}d|}|j|�S(Ns�
            If (Test-Path '%s')
            {
                $res = 0;
            }
            Else
            {
                $res = 1;
            }
            Write-Output '$res';
            Exit $res;
         (RRR7RS(R*R?R^((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pytexists�s
cO`s8|j|j|��}dtd|�}|j|�S(Ns}
            If (Test-Path -PathType Leaf '%(path)s')
            {
                $sp = new-object -TypeName System.Security.Cryptography.SHA1CryptoServiceProvider;
                $fp = [System.IO.File]::Open('%(path)s', [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read);
                [System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace("-", "").ToLower();
                $fp.Dispose();
            }
            ElseIf (Test-Path -PathType Container '%(path)s')
            {
                Write-Output "3";
            }
            Else
            {
                Write-Output "1";
            }
        R?(RRR7tdictRS(R*R?R9R3R^((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pytchecksum�sc		C`sstjdd�}|dkr:|jd|dtdt�Stj|dt�}ttt|��}|r�|j	�dkr�|j
|d	�j	�jd
�s�d|j
|d	�|d	<nd|d	d
|jd|dtdt�}|S|r|jd�r|j
d	|d�n-|sG|j
|d	�|d	<|j|�nd|dj|�f}|j|dt�S(Nsansible.executor.powershellsbootstrap_wrapper.ps1R
R^tstrict_modetpreserve_rctposixs#!powershellis.ps1s"%s.ps1"stype s | s#!is
            Try
            {
                %s
                %s
            }
            Catch
            {
                $_obj = @{ failed = $true }
                If ($_.Exception.GetType)
                {
                    $_obj.Add('msg', $_.Exception.Message)
                }
                Else
                {
                    $_obj.Add('msg', $_.ToString())
                }
                If ($_.InvocationInfo.PositionMessage)
                {
                    $_obj.Add('exception', $_.InvocationInfo.PositionMessage)
                }
                ElseIf ($_.ScriptStackTrace)
                {
                    $_obj.Add('exception', $_.ScriptStackTrace)
                }
                Try
                {
                    $_obj.Add('error_record', ($_ | ConvertTo-Json | ConvertFrom-Json))
                }
                Catch
                {
                }
                Echo $_obj | ConvertTo-Json -Compress -Depth 99
                Exit 1
            }
        t (tpkgutiltget_dataRStFalsetshlextsplittlisttmapRRBR7RIRatinserttappendR(	R*t
env_stringtshebangtcmdtarg_pathtbootstrap_wrappert	cmd_partstwrapper_cmdR^((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pytbuild_module_command�s"".$cC`sd|S(Ns& %s; exit $LASTEXITCODE((R*Rw((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pyt
wrap_for_execscC`s`t|pd�}tjd|�}|r7|jd�Stjd|�}|r\|jd�S|S(s5Remove any matching quotes that wrap the given value.R
s^\s*?\'(.*?)\'\s*?$is^\s*?"(.*?)"\s*?$(RRRR(R*R1tm((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pyR7s

cC`stjd�jd|�S(s9Return value escaped for use in PowerShell single quotes.u(['‘’‚‛])u\1\1(Rtcompiletsub(R*R1((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pyRRscC`s�t|�}|dkr+tddg}n�|r>d|}n|rQd|}ndjg|j�D]}|j�rd|j�^qd�}ttj|jd��d�}td	|g}|r�|Sd
j|�S(s?Convert a PowerShell script to a single base64-encoded command.u-s-Commandt-u"Set-StrictMode -Version Latest
%suz%s
If (-not $?) { If (Get-Variable LASTEXITCODE -ErrorAction SilentlyContinue) { exit $LASTEXITCODE } Else { exit 1 } }
s
s	utf-16-lesutf-8s-EncodedCommandRk(Rt_common_argsRt
splitlinesR8tbase64t	b64encodetencode(R*R^tas_listRhRiRztxtencoded_script((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pyRSs

:!N(#t__name__t
__module__t	frozensettCOMPATIBLE_SHELLStSHELL_FAMILYt_SHELL_REDIRECT_ALLNULLt
_SHELL_ANDtTruet_IS_WINDOWSRftenvRRR)R,R2R4R=RGRJRNRPRQRnRUtNoneR_RdReRgR|R}R7RRRS(((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pyR&>s4													
		=			(t
__future__RRRttypet
__metaclass__t
DOCUMENTATIONR�R>RRoRltxml.etree.ElementTreetetreetElementTreeRR5tansible.errorsRtansible.module_utils._textRRtansible.plugins.shellRR�R%R&(((sD/usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.pyt<module>s

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]