%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/pip_state.pyo

�
���^c-@@s�dZddlmZmZmZddlZddlZddlZddlZyddl	Z	e
ZWnek
r�e
ZnXddlZddlZddlmZddlmZmZddljjZd�Zd�Zd�ZyddlZe
ZWnek
re
ZnXee
kr�eed	�rHej e_!n4ej!ej kr|e�ddlZej e_!neej �r�dd
l"m#Z#n(eej �r�dd
l$m#Z#ne%Z#nej&e'�Z(dZ)d�Z*d
�Z+d�Z,d�Z-e
d�Z.e
d�Z/e0e0e0e0e
e
e0e0e0e0e0e0e0e0e
e0e0e0e0e0e0e
e
e
e0e
e
e
e0e0e0e0e
e0e
e0e0e
e0e
e0e
e0e0d�,Z1e0e0e0e0e0e0e0e
d�Z2e0e0e0e
d�Z3dS(u�
Installation of Python Packages Using pip
=========================================

These states manage system installed python packages. Note that pip must be
installed for these states to be available, so pip states should include a
requisite to a pkg.installed state for the package which provides pip
(``python-pip`` in most cases). Example:

.. code-block:: yaml

    python-pip:
      pkg.installed

    virtualenvwrapper:
      pip.installed:
        - require:
          - pkg: python-pip
i(tabsolute_importtprint_functiontunicode_literalsN(tSaltStackVersion(tCommandExecutionErrortCommandNotFoundErrorcC@s
dtjkrdSgtjj�pat|dd�jd�pat|tj�oa|jjd�D]\}}||f^qb}x'|D]\}}tjj	|�~q�Wdt
�kr�t
�d=ndt�kr�t�d=ntjj	dd�}|dk	r	~ndS(u(
    Purge pip and it's sub-modules
    upipNu
__module__uupip.(
tsystmodulestitemstgetattrt
startswitht
isinstancettypest
ModuleTypet__name__tpoptglobalstlocalstNone(tvtktpip_related_entriestnametentrytsys_modules_pip((s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pyt	purge_pip-s@

cC@s"tjjjd|dddd�S(uM
    True when the pip version has the `pip._internal.exceptions` module
    tver1toperu>=tver2u10.0(tsalttutilstversionstcompare(tver((s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pytpip_has_internal_exceptions_modFscC@s2t|�rtStjjjd|dddd�S(uC
    True when the pip version has the `pip.exceptions` module
    RRu>=Ru1.0(R"tFalseRRRR (R!((s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pytpip_has_exceptions_modQsu__pip_ver__(tInstallationErrorupipcO@s�ddl}tjjjd|jdddd�rXddl}|jjj	j
||�Stjjjd|jdddd�r�ddl}|jjjj
||�Sddl}|jjj
||�SdS(NiRRu>=Ru18.1u10.0(tpipRRRR t__version__tpip._internal.req.constructorst	_internaltreqtconstructorstinstall_req_from_linetpip._internal.reqtInstallRequirementt	from_linetpip.req(targstkwargsR&((s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pyt
_from_line|s		cC@s*ttkrtdfSdtkr&tStS(u>
    Only load if the pip module is available in __salt__
    u1The pkg_resources python library is not installedupip.list(tHAS_PKG_RESOURCESR#t__salt__t__virtualname__(((s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pyt__virtual__�s

c
C@s[xT|D]L\}}|dkr%qntjjjd|d|d|dt�stSqWtS(u�
    Check version number against version specification info and return a
    boolean value based on whether or not the version number meets the
    specified version.
    RRRtcmp_funcN(RRRRR t_pep440_version_cmpR#tTrue(tversiontversion_specRtspec((s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pyt_fulfills_version_spec�s*c	C@sIitd6dd6dd6dd6}ts6d|d<|St}y�y#tjdtj�t|�}Wn�tk
r�tjd�d}|j	|�r�xX|D]A}|j	|�r�t
}t|jdj|��d
�}Pq�q�Wq�t|�}nXWnpt
tfk
rf}t|d<|rLd|krLd|krLdj|�|d<|Sdj||�|d<|SX|jdkr�t
|d<d|d<g|d<n�t
|d<y$|jj|d<|jj|d<Wn}tk
rDtjdd|j�|d<t|d�r|j}n|jj}g|D]}|j|jf^q|d<nX|S(uj
    Takes a package name and version specification (if any) and checks it using
    the pip library.
    uresultucommentuprefixuversion_specu�An importable Python 2 pip module is required but could not be found on your system. This usually means that the system's pip package is not installed properly.uInstalled pip version: %su'Installed pip version is lower than 1.2ugitusvnuhgubzru{0}+i����u=u==uUInvalid version specification in package {0}. '=' is not supported, use '==' instead.u0pip raised an exception while parsing '{0}': {1}uu[^A-Za-z0-9.]+u-u	specifierN(ugitusvnuhgubzr(R#RtHAS_PIPtlogtdebugR&R'R3tAttributeErrorR
R:tsplittformatt
ValueErrorR%R*tproject_nametspecst	ExceptiontretsubRthasattrt	specifiertoperatorR;(	tpkgtrettfrom_vcstinstall_reqt
supported_vcstvcstexcRLR=((s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pyt_check_pkg_version_format�sZ










-c
K@sXitd6dd6}tjjj|pNtd|d|d|d|d|	|
��}|tkrT||krT|tkr�|r�t|�r�t|||�s�t|�r�t	|d<dj
|�|d<|Sn|tkrT|rTt}t}t}t|�r^x\|D]Q}d	|d
kr%t	}nd|d
kr>t	}nd|d
krt	}qqWntd
|d|d|d|d|d|d|d|
d|�}d}t|�r�x:t|�D]}t||�r�|}Pq�q�Wn
|d}|st	|d<dj
|�|d<|St|||�dkrQt	|d<dj
|�|d<|SqTn|S(u"
    Takes a package name and version specification (if any) and checks it is
    installed

    Keyword arguments include:
        pip_list: optional dict of installed pip packages, and their versions,
            to search through to check if the package is installed. If not
            provided, one will be generated in this function by querying the
            system.

    Returns:
     result: None means the command failed to run
     result: True means the package is installed
     result: False means the package is not installed
    uresultucommentupip.listtbin_envtusertcwdtenv_varsu(Python package {0} was already installeduaiuburcupip.list_all_versionst
include_alphatinclude_betat
include_rct	index_urltextra_index_urlui����ulPython package {0} was already installed and
the available upgrade doesn't fulfills the version requirementsiN(
R#RRRtdatatCaseInsensitiveDictR5tanyR>R:RDtreversedR9(tprefixtstate_pkg_nameR<tignore_installedtforce_reinstalltupgradeRWRXRVRYR]R^tpip_listR2RORZR[R\R=tavailable_versionstdesired_versionR;((s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pyt_check_if_installed�s`



		





c@s�ttkrtjd�dS�fd�}||�}||�}yjtj|�tj|�kridStj|�tj|�kr�dStj|�tj|�kr�dSWn tk
r�}tj|�nXdS(u�
    Compares two version strings using pkg_resources.parse_version.
    Return -1 if version1 < version2, 0 if version1 ==version2,
    and 1 if version1 > version2. Return None if there was a problem
    making the comparison.
    uEThe pkg_resources packages was not loaded. Please install setuptools.c@s0�r#tj|�jdd�dStj|�S(Nu!ii����(tsixt	text_typeRC(tx(tignore_epoch(s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pyt<lambda>Zsi����iiN(	R4R#R@twarningRt
pkg_resourcest
parse_versionRHt	exception(tpkg1tpkg2Rot	normalizeRT((Ros9/usr/lib/python2.7/site-packages/salt/states/pip_state.pyR9Ps 
c-T\K@s�|o
|r|}n|rRt|t�rOi|d6td6id6dd6Snn	|g}d�}.g|D]}/|.|/�^qk}idj|�d6td6dd6id6}0ytd	|�}1Wn=ttfk
r}2t|0d<d
j||2�|0d<|0SnX|r�d}3d}4t	j
jjd
|1ddd|3�}5t	j
jjd
|1ddd|4�}6|5pe|6r�t|0d<dj|3|4|1�|0d<|0Snn|r(d}3d}4t	j
jjd
|1ddd|3�}5t	j
jjd
|1ddd|4�}6|5p�|6r%t|0d<dj|3|4|1�|0d<|0Snn|,r�d}3t	j
jjd
|1ddd|3�}5|5r�t|0d<dj|3|1�|0d<|0Snn|
tk	r�dj||
dt
jd�j�}7t	j
jjd|7�|0jdg�j|7�|
}ng}8|o|p|r�g}9xt|�D]q}/t|/�}:|:dtkr\t|0d<|9j|:d�n1|:dtkr�|8j|:d|/|:df�nqW|0dtkr�dj|9�|0d<|0Snng};g}<|p�|rKg}9tdrHt|0d<|r|9jdj|��n|r.|9jdj|��nd j|9�|0d<|0Snny#td!d"|d#|d$| �}=Wn&tk
r�}>|j|>�t}=nXxY|8D]Q\}?}@}A|?r$|@}@|A}At|?|@|A||||| ||'|
||=|-�
}:|:dtkr!t|0d<|:d|0d<|0Snnitd6td6}:|:d}B|Btkr�|;j|?|@jd%d�f�tdr�d&}7t|0d<|7j|@�|0d<|0SnnK|Btkr�|<j|:d�n+|Btkr�t|0d<|:d|0d<|0Snq�W|;rNt|0d<dj|<�}Cd'|r"d(nd}D|C|Cr8dnd|D|0d<|0Snd%jg|;D]\}E}F|F^q[�}Gtd)d*|Gr�d+j|G�ndd,|d"|d-|d.|d/|,d0|d1|d2|	d3|d4|d5|
d6|d7|d8|d9|d:|d;|d<|d=|d>|d?|d@|dA|dB|dC|dD|dE|dF|d#|d$| dG|!dH|"dI|#dJ|$dK|%dL|&dMtdN|'dO|(dP|)dQ|*|-�*}H|Ho�|HjdRdS�dTkrq
t|0d<|p�|r�g}9|r�dUdVdWdXdYdZg}Ixc|Hjd[d�jd�D]F}Jtg|ID]}K|Jj�j |K�^q�rQt|0dd\<nqW|0djd\�r�|9jd]j|��n
|9jd^�n|r�|9jd_j|��t|0dd`<nd j|9�|0d<n�g}Lt!�}Mxh|Hjd[d�jd�D]K}J|Jj da�rJ	|JjdbdS�dSj�dT}N|Mj"|Nj#��nq�Wx�|;D]�\}?}F|?r
t	j
j$j%td!|?|d#|d$| dN|'|-��}O|Or�	|Ljdcj|/��nE|?|Oko�	|?j#�|Mkr
|O|?}Pdd|0ddej|?|P�<nndd|0ddfj|F�<qU	Wdj|<�}C|Lr=
dgndj|L�}Q|C|Cr[
dnd|Q|0d<|0Sn=|Hr�t|0d<d[|Hkr�
dhj|Hd[|Hdi�}Rndjj|Hd�}R|p�
|r0g}9|r�
|9jdkj|��n|r
|9jdlj|��n|9j|R�d j|9�|0d<ngdmjg|;D]\}E}F|F^q=�}Gdj|<�}Cdnj|G|R�}S|C|Cr�dnd|S|0d<nt|0d<do|0d<|0S(pu
    Make sure the package is installed

    name
        The name of the python package to install. You can also specify version
        numbers here using the standard operators ``==, >=, <=``. If
        ``requirements`` is given, this parameter will be ignored.

    Example:

    .. code-block:: yaml

        django:
          pip.installed:
            - name: django >= 1.6, <= 1.7
            - require:
              - pkg: python-pip

    This will install the latest Django version greater than 1.6 but less
    than 1.7.

    requirements
        Path to a pip requirements file. If the path begins with salt://
        the file will be transferred from the master file server.

    user
        The user under which to run pip

    use_wheel : False
        Prefer wheel archives (requires pip>=1.4)

    no_use_wheel : False
        Force to not use wheel archives (requires pip>=1.4)

    no_binary
        Force to not use binary packages (requires pip >= 7.0.0)
        Accepts either :all: to disable all binary packages, :none: to empty the set,
        or a list of one or more packages

    Example:

    .. code-block:: yaml

        django:
          pip.installed:
            - no_binary: ':all:'

        flask:
          pip.installed:
            - no_binary:
              - itsdangerous
              - click

    log
        Log file where a complete (maximum verbosity) record will be kept

    proxy
        Specify a proxy in the form
        user:passwd@proxy.server:port. Note that the
        user:password@ is optional and required only if you
        are behind an authenticated proxy.  If you provide
        user@proxy.server:port then you will be prompted for a
        password.

    timeout
        Set the socket timeout (default 15 seconds)

    editable
        install something editable (i.e.
        git+https://github.com/worldcompany/djangoembed.git#egg=djangoembed)

    find_links
        URL to look for packages at

    index_url
        Base URL of Python Package Index

    extra_index_url
        Extra URLs of package indexes to use in addition to ``index_url``

    no_index
        Ignore package index

    mirrors
        Specific mirror URL(s) to query (automatically adds --use-mirrors)

    build
        Unpack packages into ``build`` dir

    target
        Install packages into ``target`` dir

    download
        Download packages into ``download`` instead of installing them

    download_cache
        Cache downloaded packages in ``download_cache`` dir

    source
        Check out ``editable`` packages into ``source`` dir

    upgrade
        Upgrade all packages to the newest available version

    force_reinstall
        When upgrading, reinstall all packages even if they are already
        up-to-date.

    ignore_installed
        Ignore the installed packages (reinstalling instead)

    exists_action
        Default action when a path already exists: (s)witch, (i)gnore, (w)ipe,
        (b)ackup

    no_deps
        Ignore package dependencies

    no_install
        Download and unpack all packages, but don't actually install them

    no_cache_dir:
        Disable the cache.

    cwd
        Current working directory to run pip from

    pre_releases
        Include pre-releases in the available versions

    cert
        Provide a path to an alternate CA bundle

    allow_all_external
        Allow the installation of all externally hosted files

    allow_external
        Allow the installation of externally hosted files (comma separated list)

    allow_unverified
        Allow the installation of insecure and unverifiable files (comma separated list)

    process_dependency_links
        Enable the processing of dependency links

    bin_env : None
        Absolute path to a virtual environment directory or absolute path to
        a pip executable. The example below assumes a virtual environment
        has been created at ``/foo/.virtualenvs/bar``.

    env_vars
        Add or modify environment variables. Useful for tweaking build steps,
        such as specifying INCLUDE or LIBRARY paths in Makefiles, build scripts or
        compiler calls.  This must be in the form of a dictionary or a mapping.

        Example:

        .. code-block:: yaml

            django:
              pip.installed:
                - name: django_app
                - env_vars:
                    CUSTOM_PATH: /opt/django_app
                    VERBOSE: True

    use_vt
        Use VT terminal emulation (see output while installing)

    trusted_host
        Mark this host as trusted, even though it does not have valid or any
        HTTPS.

    Example:

    .. code-block:: yaml

        django:
          pip.installed:
            - name: django >= 1.6, <= 1.7
            - bin_env: /foo/.virtualenvs/bar
            - require:
              - pkg: python-pip

    Or

    Example:

    .. code-block:: yaml

        django:
          pip.installed:
            - name: django >= 1.6, <= 1.7
            - bin_env: /foo/.virtualenvs/bar/bin/pip
            - require:
              - pkg: python-pip

    .. admonition:: Attention

        The following arguments are deprecated, do not use.

    pip_bin : None
        Deprecated, use ``bin_env``

    .. versionchanged:: 0.17.0
        ``use_wheel`` option added.

    install_options

        Extra arguments to be supplied to the setup.py install command.
        If you are using an option with a directory path, be sure to use
        absolute path.

        Example:

        .. code-block:: yaml

            django:
              pip.installed:
                - name: django
                - install_options:
                  - --prefix=/blah
                - require:
                  - pkg: python-pip

    global_options
        Extra global options to be supplied to the setup.py call before the
        install command.

        .. versionadded:: 2014.1.3

    .. admonition:: Attention

        As of Salt 0.17.0 the pip state **needs** an importable pip module.
        This usually means having the system's pip package installed or running
        Salt from an active `virtualenv`_.

        The reason for this requirement is because ``pip`` already does a
        pretty good job parsing its own requirements. It makes no sense for
        Salt to do ``pip`` requirements parsing and validation before passing
        them to the ``pip`` library. It's functionality duplication and it's
        more error prone.


    .. admonition:: Attention

        Please set ``reload_modules: True`` to have the salt minion
        import this module after installation.


    Example:

    .. code-block:: yaml

        pyopenssl:
            pip.installed:
                - name: pyOpenSSL
                - reload_modules: True
                - exists_action: i


    .. _`virtualenv`: http://www.virtualenv.org/en/latest/
    unameuresultuchangesu)pkgs argument must be formatted as a listucommentcS@sKt|tj�r|Sdjtj|�ddtj|�ddf�S(Nu ii(RRltstring_typestjoint	iteritems(RN((s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pyRp�su;uupip.versionuError installing '{0}': {1}u1.4u9.0.3RRu<Ru>uiThe 'use_wheel' option is only supported in pip between {0} and {1}. The version of pip detected was {2}.ulThe 'no_use_wheel' option is only supported in pip between {0} and {1}. The version of pip detected was {2}.u7.0.0ucThe 'no_binary' option is only supported in pip {0} and newer. The version of pip detected was {1}.u�The 'repo' argument to pip.installed is deprecated and will be removed in Salt {version}. Please use 'name' instead. The current value for name, '{0}' will be replaced by the value of repo, '{1}'R;uLithiumuwarningsuprefixuversion_specu
utestu*Requirements file '{0}' will be processed.uUPackage will be installed in editable mode (i.e. setuptools "develop mode") from {0}.u upip.listRVRWRXu,u)Python package {0} is set to be installedu,All specified packages are already installedu and up-to-dateupip.installtpkgsu{0}trequirementst	use_wheeltno_use_wheelt	no_binaryR@tproxyttimeoutteditablet
find_linksR]R^tno_indextmirrorstbuildttargettdownloadtdownload_cachetsourceRgRfRet
exists_actiontno_depst
no_installtno_downloadtinstall_optionstglobal_optionstpre_releasestcerttallow_all_externaltallow_externaltallow_unverifiedtprocess_dependency_linkstsaltenvRYtuse_vtttrusted_hosttno_cache_diruretcodeiiuRequirement already satisfieduRequirement already up-to-dateuRequirement not upgradedu
CollectinguCloninguCleaning up...ustdouturequirementsu-Successfully processed requirements file {0}.u$Requirements were already installed.u5Package successfully installed from VCS checkout {0}.ueditableu Requirement already up-to-date: u:u`There was no error installing package '{0}' although it does not show when calling 'pip.freeze'.u	Installedu{0}=={1}u{0}==???u(All packages were successfully installeduError: {0} {1}ustderru
Error: {0}u*Unable to process requirements file "{0}".u'Unable to install from VCS checkout{0}.u, u$Failed to install packages: {0}. {1}uCould not install package(&RtlistR#RyRR5RRRDRRRR t_SaltStackVersiont	from_nametformatted_versiont
warn_untilt
setdefaulttappendtiterRUR:t__opts__RHRtRktreplacet__env__tgetRCRatstripR
tsettaddtlowerR_R`(TRR{tpip_binR|RVR}R~R@R�R�trepoR�R�R]R^R�R�R�R�R�R�R�RgRfReR�R�R�R�R�R�RWRXR�R�R�R�R�R�RYR�R�R�t	cache_dirRR2tpreproRNROtcur_versionterrtmin_versiontmax_versionttoo_lowttoo_hightmsgtpkgs_detailstcommentstoutttarget_pkgstalready_installed_commentsRhRTRcRdR<tresulttaicommst	last_linet_t
state_nametpkgs_strtpip_install_calltPIP_REQUIREMENTS_NOCHANGEtlineRnt
pkg_404_commstalready_installed_packagestpackaget	pipsearchR!t	succ_commterrort
error_comm((s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pyt	installedjs��6
	
		
$$

$$

$

	
%





#

		







(
	
	")

	" 

 




(!

c	C@sQi|d6dd6dd6id6}	y#tdd|d|d	|�}
Wn:ttfk
r�}t|	d<d
j||�|	d<|	SX||
kr�t|	d<d|	d<|	Stdr�d|	d<d
j|�|	d<|	Stdd|d|d|d|d|d|d|d	|d|�	r9t|	d<d|	d|<d|	d<nt|	d<d|	d<|	S(u,
    Make sure that a package is not installed.

    name
        The name of the package to uninstall
    user
        The user under which to run pip
    bin_env : None
        the pip executable or virtualenenv to use
    use_vt
        Use VT terminal emulation (see output while installing)
    unameuresultuucommentuchangesupip.listRVRWRXuError uninstalling '{0}': {1}uPackage is not installed.utestu Package {0} is set to be removedu
pip.uninstallR{R|R@R�R�R�uRemovedu!Package was successfully removed.uCould not remove package.N(RR5RRR#RDR:R�(RR|RVR@R�R�RWRXR�RORhR�((s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pytremoved�s<"#




	



c		C@s.i|d6id6td6dd6}y#tdd|d|d	|�}Wn'tk
rn}tj|�|d<|SX|s�d
|d<t|d<|Stdr�d|d<d|d<|Std
d|d|d	|d|�}|jd�tkr�|j	|�n1|r ||d<d|d<t|d<n
d|d<|S(ux
    .. versionadded:: 2015.5.0

    Verify that the system is completely up to date.

    name
        The name has no functional value and is only used as a tracking
        reference
    user
        The user under which to run pip
    bin_env
        the pip executable or virtualenenv to use
    use_vt
        Use VT terminal emulation (see output while installing)
    unameuchangesuresultuFailed to update.ucommentupip.list_upgradesRVRWRXuSystem is already up-to-date.utestuSystem update will be performedupip.upgradeR�uUpgrade successful.uUpgrade failed.N(
R#R5RHRlRmR:R�RR�tupdate(	RRVRWRXR�ROtpackagestetupdated((s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pytuptodate7s4

#




%



(4t__doc__t
__future__RRRRIRtloggingRRrR:R4tImportErrorR#tsalt.utils.dataRtsalt.utils.versionstsalt.versionRR�tsalt.exceptionsRRtsalt.ext.sixtextRlRR"R$R&R?RKR't__pip_ver__tpip._internal.exceptionsR%tpip.exceptionsREt	getLoggerRR@R6R3R7R>RURkR9RR�R�R�(((s9/usr/lib/python2.7/site-packages/salt/states/pip_state.pyt<module>s�


			



					ZP��j3

Zerion Mini Shell 1.0