%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlZ	ddl
Z	ddlZ	ddlmZmZddlmZddlmZeje�ZdZd�Zd	�Zdd
�Zd�Zed�Z e!d
�Z"d�Z#d�Z$e	j%jj&e$d�Z'ddd�Z(d�Z)d�Z*ddddd�Z+ed�Z,d�Z-ed�Z.d�Z/dS(u
Homebrew for macOS

.. important::
    If you feel that Salt should be using this module to manage packages on a
    minion, and it is using a different module (or gives an error similar to
    *'pkg.install' is not available*), see :ref:`here
    <module-provider-override>`.
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrortMinionError(tsix(tzipupkgcC@s3tjjjd�r)tddkr)tStdfS(u6
    Confine this module to Mac OS with Homebrew.
    ubrewuosuMacOSuHThe brew module could not be loaded: brew not found or grain os != MacOS(tsalttutilstpathtwhicht
__grains__t__virtualname__tFalse(((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pyt__virtual__%s%cC@sd}t|�dj�S(u,
    List currently installed brew taps
    utapustdout(t
_call_brewt
splitlines(tcmd((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pyt
_list_taps/scC@sY|t�krtSdj|�}yt|�Wn"tk
rTtjd|�tSXtS(uo
    Add unofficial GitHub repos to the list of formulas that brew tracks,
    updates, and installs from.
    utap {0}uFailed to tap "%s"(RtTruetformatRRtlogterrorR
(ttaptrunasR((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pyt_tap7s
cC@s$tdddd�}|d7}|S(uB
    Returns the full path to the homebrew binary in the PATH
    ucmd.runu
brew --prefixtoutput_loglevelutraceu	/bin/brew(t__salt__(tret((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pyt
_homebrew_binIs
cC@s�tdt��}|tdkr)|nd}djtjjjd�|�}td|d|ddd	t	�}|r�|d
dkr�t
dd
i|d6��n|S(u>
    Calls the brew command with the user account of brew
    u
file.get_useruuseru{} {}ubrewucmd.run_allRRutracetpython_shelluretcodeiuBrew command failedtinfouresultN(RRt__opts__tNoneRRRR	R
R
R(RtfailhardtuserRtresult((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pyRRs!
		cK@sttjjj|�}tgdD]$}tjjj|j|��^q�rPiSdtkr�|rjtdStjtd�}t	d|�|Sni}d}tjj
jt|�d�}x�|D]�}g|dD]}|d^q�}|d	|d
|dg}	g|	D]}
|D]}|
|f^qq}x(|D] \}}
t	d|||
�q:Wq�Wy�d
}t|�d}x�|j
�D]�}yf|jd�}djd|df�}|d}tjtjjj�}t|d|�j�}Wntk
r
q�nXt	d|||�q�WWntk
r7nXt	d|�tj|�td<|spt	d|�n|S(u�
    List the packages currently installed in a dict::

        {'<package_name>': '<version>'}

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_pkgs
    uremovedu
purge_desiredu
pkg.list_pkgsupkg_resource.stringifyuinfo --json=v1 --installedustdoutu	installeduversionualiasesunameu	full_nameupkg_resource.add_pkgucask list --versionsu u/u
caskroom/caskiitkeyupkg_resource.sort_pkglist(uremovedu
purge_desired(RRtdatatis_truetanytgett__context__tcopytdeepcopyRtjsontloadsRRtsplittjoint	functoolst
cmp_to_keytversionstversion_cmptsortedtpopt
ValueErrorR(tversions_as_listtkwargstxRRtpackage_infotpackagetvR3tnamestntcombinationstnametversiontcask_cmdtouttlinetname_and_versionstinstalled_versionstkey_functnewest_version((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pyt	list_pkgscsN1
!,


cO@std||�S(uU
    Returns a string representing the package version or an empty string if not
    installed. If more than one package name is specified, a dict of
    name/version pairs is returned.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.version <package name>
        salt '*' pkg.version <package1> <package2> <package3>
    upkg_resource.version(R(R>R9((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pyRB�s
c@s�tjjj|jdt��}|r1t�nd��t�fd�tj	t
|��D��}t|�dkr�ttj
|��S|SdS(ua
    Return the latest version of the named package available for upgrade or
    installation

    Currently chooses stable versions, falling back to devel if that does not
    exist.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.latest_version <package name>
        salt '*' pkg.latest_version <package1> <package2> <package3>
    urefreshcS@s|ddp|ddS(Nuversionsustableudevel((tpkg_info((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pytget_version�sc3@s'|]\}}|�|�fVqdS(N((t.0R%tval(RL(s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pys	<genexpr>�siN(RRR&R'R6Rt
refresh_dbtdictRt	iteritemst_infotlentnextt
itervalues(R>R9trefresht
versions_dict((RLs=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pytlatest_version�s!
	+uavailable_versionc
K@s*ytd|||�d}Wntk
r?}t|��nXt�}g|D]}||krP|^qP}|sxiSdjdj|��}t|�}	|	ddkr�|	dr�|	dg}
ng}
tjdd�t�}t
jjj
||�}|
r&tdd	i|
d
6|d6��n|S(
u8
    Removes packages with ``brew uninstall``.

    name
        The name of the package to be deleted.


    Multiple Package Options:

    pkgs
        A list of packages to delete. Must be passed as a python list. The
        ``name`` parameter will be ignored if this option is passed.

    .. versionadded:: 0.16.0


    Returns a dict containing the changes.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.remove <package name>
        salt '*' pkg.remove <package1>,<package2>,<package3>
        salt '*' pkg.remove pkgs='["foo", "bar"]'
    upkg_resource.parse_targetsiu
uninstall {0}u uretcodeustderru
pkg.list_pkgsu'Problem encountered removing package(s)RuerrorsuchangesN(RRRRJRR0RR*R6R!RRR&t
compare_dicts(
RAtpkgsR9t
pkg_paramstexctoldR:ttargetsRRDterrorstnewR((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pytremove�s.	%	cC@s>tjjjt�d}t|�dr:tjd�tSt	S(u~
    Update the homebrew package repository.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.refresh_db
    uupdateuretcodeuFailed to update(
RRtpkgt
clear_rtagR RRRR
R(R((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pyROs
cG@swdjdj|��}t|�}|drKtjddj|��iStjjj|d�}t	t
||��S(u
    Get all info brew can provide about a list of packages.

    Does not do any kind of processing, so the format depends entirely on
    the output brew gives. This may change if a new version of the format is
    requested.

    On failure, returns an empty dict and logs failure.
    On success, returns a dict mapping each item in pkgs to its corresponding
    object in the output of 'brew info'.

    Caveat: If one of the packages does not exist, no packages will be
            included in the output.
    uinfo --json=v1 {0}u uretcodeu%Failed to get info about packages: %sustdout(RR0RRRRRR-R.RPR(RZRtbrew_resulttoutput((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pyRR+s
	cK@s�y,td|||jdi��\}}Wntk
rM}t|��nX|dkslt|�dkrpiSdj|�}t�}	|r�t|t	�s�|g}nx|D]}
t
|
�q�Wn|r�dj|dj|��}ndj|�}t|�}|ddkr0|dr0|dg}
ng}
t
jd	d�t�}tjjj|	|�}|
r�td
di|
d6|d
6��n|S(u�
    Install the passed package(s) with ``brew install``

    name
        The name of the formula to be installed. Note that this parameter is
        ignored if "pkgs" is passed.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install <package name>

    taps
        Unofficial GitHub repos to use when updating and installing formulas.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install <package name> tap='<tap>'
            salt '*' pkg.install zlib taps='homebrew/dupes'
            salt '*' pkg.install php54 taps='["josegonzalez/php", "homebrew/dupes"]'

    options
        Options to pass to brew. Only applies to initial install. Due to how brew
        works, modifying chosen options requires a full uninstall followed by a
        fresh install. Note that if "pkgs" is used, all options will be passed
        to all packages. Unrecognized options for a package will be silently
        ignored by brew.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install <package name> tap='<tap>'
            salt '*' pkg.install php54 taps='["josegonzalez/php", "homebrew/dupes"]' options='["--with-fpm"]'

    Multiple Package Installation Options:

    pkgs
        A list of formulas to install. Must be passed as a python list.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install pkgs='["foo","bar"]'


    Returns a dict containing the new package names and versions::

        {'<package>': {'old': '<old-version>',
                       'new': '<new-version>'}}

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.install 'package package package'
    upkg_resource.parse_targetsusourcesiu uinstall {0} {1}uinstall {0}uretcodeustderru
pkg.list_pkgsu)Problem encountered installing package(s)RuerrorsuchangesN(RR)RRR!RSR0RJt
isinstancetlistRRRR*R6RRR&RY(RARZttapstoptionsR9R[tpkg_typeR\tformulasR]RRRDR_R`R((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pytinstallDs:>%	
	cK@s�|rt�ntd�}i}ytjjj|d�}Wn;tk
r|}dj|�}tj	|�t
|��nXx |D]}|d||d<q�W|S(u�
    Check whether or not an upgrade is available for all packages

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_upgrades
    uoutdated --json=v1ustdoutu4unable to interpret output from "brew outdated": {0}ucurrent_versionuname(RORRRR-R.R7RRRR(RVR9tresRR&terrtmsgRb((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pyt
list_upgrades�s



cC@s
|t�kS(u�
    Check whether or not an upgrade is available for a given package

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.upgrade_available <package name>
    (Rp(Rb((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pytupgrade_available�s
cC@s�iid6td6dd6}t�}tjjj|�rCt�ntddt�}t	j
dd�t�}tjjj||�}|dd	kr�t
d
di|d6|d6��n|S(
u�
    Upgrade outdated, unpinned brews.

    refresh
        Fetch the newest version of Homebrew and all formulae from GitHub before installing.

    Returns a dictionary containing the changes:

    .. code-block:: python

        {'<package>':  {'old': '<old-version>',
                        'new': '<new-version>'}}


    CLI Example:

    .. code-block:: bash

        salt '*' pkg.upgrade
    uchangesuresultuucommentuupgradeR"u
pkg.list_pkgsuretcodeiu&Problem encountered upgrading packagesRN(RRJRRR&R'RORR
R*R6R!RYR(RVRR]R$R`((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pytupgrade�s

	
	cG@s
t|�S(ud
    Return the information of the named package(s) installed on the system.

    .. versionadded:: 2016.3.1

    names
        The names of the packages for which to return information.

    CLI example:

    .. code-block:: bash

        salt '*' pkg.info_installed <package1>
        salt '*' pkg.info_installed <package1> <package2> <package3> ...
    (RR(R>((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pytinfo_installeds(0t__doc__t
__future__RRRR+R1tloggingtsalt.utils.dataRtsalt.utils.functoolstsalt.utils.jsontsalt.utils.pathtsalt.utils.pkgtsalt.utils.versionstsalt.exceptionsRRtsalt.extRtsalt.ext.six.movesRt	getLoggert__name__RRRRR!RRRRR
RJRBRXRtalias_functiontavailable_versionRaRORRRlRpRqRrRs(((s=/usr/lib/python2.7/site-packages/salt/modules/mac_brew_pkg.pyt<module>
s@	
			F		 ;		m	
-

Zerion Mini Shell 1.0