%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_portspkg.pyo

�
���^c@@srdZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlZ	ddl
Z	ddlZ	ddlZ	ddlmZddlmZeje�ZeZdZd�Zdd	�Zed
�Zd�Zd�Ze	j j!j"ed
�Z#ddd�Z%dedd�Z&ed�Z'ed�Z(d�Z)ed�Z*dS(u�
Support for MacPorts under macOS.

This module has some caveats.

1. Updating the database of available ports is quite resource-intensive.
However, `refresh=True` is the default for all operations that need an
up-to-date copy of available ports.  Consider `refresh=False` when you are
sure no db update is needed.

2. In some cases MacPorts doesn't always realize when another copy of itself
is running and will gleefully tromp all over the available ports database.
This makes MacPorts behave in undefined ways until a fresh complete
copy is retrieved.

Because of 1 and 2 it is possible to get the salt-minion into a state where
`salt mac-machine pkg./something/` won't want to return.  Use

`salt-run jobs.active`

on the master to check for potentially long-running calls to `port`.

Finally, ports database updates are always handled with `port selfupdate`
as opposed to `port sync`.  This makes sense in the MacPorts user commmunity
but may confuse experienced Linux admins as Linux package managers
don't upgrade the packaging software when doing a package database update.
In other words `salt mac-machine pkg.refresh_db` is more like
`apt-get update; apt-get upgrade dpkg apt-get` than simply `apt-get update`.

i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionError(tsixupkgcC@s?tjjj�stdfStjjjd�s;tdfStS(u6
    Confine this module to Mac OS with MacPorts.
    u!mac_ports only available on MacOSuportu$mac_ports requires the "port" binary(tsalttutilstplatformt	is_darwintFalsetpathtwhicht__virtualname__(((s=/usr/lib/python2.7/site-packages/salt/modules/mac_portspkg.pyt__virtual__:s


ucC@s�dj|�}tjjj|�}i}xk|j�D]]}y6tjd|j��dd!\}}}|d}Wnt	k
r�q7nX|||<q7W|S(Nu
port list {0}u\s+iii(
tformatRRt	mac_utilstexecute_return_resultt
splitlinestretsplittlstript
ValueError(tquerytcmdtouttrettlinetnametversion_numtcategory((s=/usr/lib/python2.7/site-packages/salt/modules/mac_portspkg.pyt_listGs(
c
K@s�tjjj|�}tgdD]$}tjjj|j|��^q�rPiSdtkr�|rjtdStjtd�}t	d|�|Sni}ddg}tjj
j|�}x�|j�D]}}y6t
jd|j��dd	!\}}}	|d
}Wntk
rq�nXts,|	dkr�t	d|||�q�q�Wt	d
|�tj|�td<|st	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.stringifyuportu	installedu\s+iiiu(active)upkg_resource.add_pkgupkg_resource.sort_pkglist(uremovedu
purge_desired(RRtdatatis_truetanytgett__context__tcopytdeepcopyt__salt__RRRRRRRtLIST_ACTIVE_ONLY(
tversions_as_listtkwargstxRRRRRRtactive((s=/usr/lib/python2.7/site-packages/salt/modules/mac_portspkg.pyt	list_pkgsWs4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&(tnamesR)((s=/usr/lib/python2.7/site-packages/salt/modules/mac_portspkg.pytversion�s
cO@s�tjjj|jdt��r+t�ntdj|��pCi}t	d�pVi}i}xwt
j|�D]f\}}||ks�tjjj
d||ddd|�r�|||<qodjt|��||<qoW|S(	uP
    Return the latest version of the named package available for upgrade or
    installation

    Options:

    refresh
        Update ports with ``port selfupdate``

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.latest_version <package name>
        salt '*' pkg.latest_version <package1> <package2> <package3>
    urefreshu u
pkg.list_pkgstver1toperu<tver2u{0} (installed)(RRRR R"tTruet
refresh_dbRtjoinR&Rt	iteritemstversionstcompareRR.(R-R)t	availablet	installedRtkeytval((s=/usr/lib/python2.7/site-packages/salt/modules/mac_portspkg.pytlatest_version�s!
4
uavailable_versioncK@std|||�d}t�}g|D]}||kr*|^q*}|sRiSddg}|j|�d}ytjjj|�Wntk
r�}	|	j}nXt	j
dd�t�}
tjjj
||
�}|rtddi|d	6|d
6��n|S(u8
    Removes packages with ``port 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_targetsiuportu	uninstalluu
pkg.list_pkgsu'Problem encountered removing package(s)tinfouerrorsuchangesN(R&R,textendRRRtexecute_return_successRtstrerrorR#tpoptNoneRt
compare_dicts(RtpkgsR)t
pkg_paramstoldR*ttargetsRterr_messagetexctnewR((s=/usr/lib/python2.7/site-packages/salt/modules/mac_portspkg.pytremove�s,

	%

	cK@s�td||i�\}}tjjj|�r;t�n|dkr�|jd�}|jd�}i}|r~||d<n|r�||d<ni||6}n|dks�t|�dkr�iSg}	xwt	j
|�D]f\}
}|	j|
�|r�d|kr|	jd|d�nd|kr?|	j|d�q?q�q�Wt�}ddg}
|
j
|	�d}ytjjj|
�Wntk
r�}|j}nXtjd	d�t�}tjjj||�}|r�td
di|d6|d
6��n|S(u�
    Install the passed package(s) with ``port 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>

    version
        Specify a version to pkg to install. Ignored if pkgs is specified.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install <package name>
            salt '*' pkg.install git-core version='1.8.5.5'

    variant
        Specify a variant to pkg to install. Ignored if pkgs is specified.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install <package name>
            salt '*' pkg.install git-core version='1.8.5.5' variant='+credential_osxkeychain+doc+pcre'

    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"]'
            salt '*' pkg.install pkgs='["foo@1.2","bar"]'
            salt '*' pkg.install pkgs='["foo@1.2+ssl","bar@2.3"]'


    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_targetsuversionuvariantiu@uportuinstalluu
pkg.list_pkgsu)Problem encountered installing package(s)R=uerrorsuchangesN(R&RRRR R3RBR"tlenRR5tappendR,R>RR?RR@R#RARC(RtrefreshRDR)REtpkg_typeRtvariant_spectspectformulas_arraytpnametpparamsRFRRHRIRJR((s=/usr/lib/python2.7/site-packages/salt/modules/mac_portspkg.pytinstall�sL<



	

	cK@s|rt�ntd�S(u�
    Check whether or not an upgrade is available for all packages

    Options:

    refresh
        Update ports with ``port selfupdate``

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_upgrades
    uoutdated(R3R(RNR)((s=/usr/lib/python2.7/site-packages/salt/modules/mac_portspkg.pyt
list_upgradesfs
cC@s|td|�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>
    RN(RV(tpkgRN((s=/usr/lib/python2.7/site-packages/salt/modules/mac_portspkg.pytupgrade_available{s
cC@s2tjjjt�ddg}tjjj|�S(u|
    Update ports with ``port selfupdate``

    CLI Example:

    .. code-block:: bash

        salt mac pkg.refresh_db
    uportu
selfupdate(RRRWt
clear_rtagt__opts__RR?(R((s=/usr/lib/python2.7/site-packages/salt/modules/mac_portspkg.pyR3�scC@s�|rt�nt�}dddg}td|dddt�}tjdd�t�}tjj	j
||�}|d	d
kr�tddi|d
6|d6��n|S(u�
    Run a full upgrade using MacPorts 'port upgrade outdated'

    Options:

    refresh
        Update ports with ``port selfupdate``

    Returns a dictionary containing the changes:

    .. code-block:: python

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


    CLI Example:

    .. code-block:: bash

        salt '*' pkg.upgrade
    uportuupgradeuoutdateducmd.run_alltoutput_loglevelutracetpython_shellu
pkg.list_pkgsuretcodeiu&Problem encountered upgrading packagesR=uchangesuresultN(R3R,R&R	R#RARBRRRRCR(RNRFRtresultRJR((s=/usr/lib/python2.7/site-packages/salt/modules/mac_portspkg.pytupgrade�s
	
		(+t__doc__t
__future__RRRR$tloggingRtsalt.utils.dataRtsalt.utils.functoolstsalt.utils.pathtsalt.utils.pkgtsalt.utils.platformtsalt.utils.mac_utilstsalt.utils.versionstsalt.exceptionsRtsalt.extRt	getLoggert__name__tlogR2R'RR
RR	R,R.R<Rt	functoolstalias_functiontavailable_versionRBRKRURVRXR3R^(((s=/usr/lib/python2.7/site-packages/salt/modules/mac_portspkg.pyt<module>s8	
-		$8s
	

Zerion Mini Shell 1.0