%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/dpkg_lowpkg.pyo

�
���^c@@s#dZddlmZmZmZddlZddlZddlZddlZddl	Z
ddlZ
ddlZ
ddl
Z
ddlZ
ddlmZmZeje�ZdZd�Zdd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Z dS(u
Support for DEB packages
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrortSaltInvocationErrorulowpkgcC@stddkrtStdfS(u9
    Confirm this module is on a Debian based system
    u	os_familyuDebianuPThe dpkg execution module cannot be loaded: only works on Debian family systems.(t
__grains__t__virtualname__tFalse(((s</usr/lib/python2.7/site-packages/salt/modules/dpkg_lowpkg.pyt__virtual__subasecC@swtd|�rMtd||�}|sDtdj||���n|}nTtjj|�swtdj|���n*tjj|�s�tdj|���ndd|g}td|dd	�}|d
dkrd|}|d
r�|d|d
7}nt|��ni}x�|dj�D]�}|j	�}|j
d�r]|j�d|d<q%|j
d�r�|j�d|d<q%|j
d�r%|j�d|d<q%q%Wgd D]}||kr�|^q�}	|	r�tdjdj|	�|���nt
jdd�dkrst
jdd�}
|d}|dkrs|
dkrs|
|krs|dcdj|�7<qsn|S(!u�
    .. versionadded:: 2015.8.0

    Parses RPM metadata and returns a dictionary of information about the
    package (name, version, etc.).

    path
        Path to the file. Can either be an absolute path to a file on the
        minion, or a salt fileserver URL (e.g. ``salt://path/to/file.rpm``).
        If a salt fileserver URL is passed, the file will be cached to the
        minion so that it can be examined.

    saltenv : base
        Salt fileserver envrionment from which to retrieve the package. Ignored
        if ``path`` is a local file path on the minion.

    CLI Example:

    .. code-block:: bash

        salt '*' lowpkg.bin_pkg_info /root/foo-1.2.3-1ubuntu1_all.deb
        salt '*' lowpkg.bin_pkg_info salt://foo-1.2.3-1ubuntu1_all.deb
    uconfig.valid_fileprotou
cp.cache_fileu)Unable to retrieve {0} from saltenv '{1}'u{0} does not exist on minionudpkgu-Iucmd.run_alltoutput_loglevelutraceuretcodeiuUnable to get info for ustderru: ustdoutuPackage:i����unameuVersion:uversionu
Architecture:uarchuUnable to get {0} for {1}u, ucpuarchuux86_64uosarchualluamd64u:{0}(unameuversionuarch(t__salt__RtformattostpathtexiststisabsRt
splitlineststript
startswithtsplittjoinRtget(R
tsaltenvtnewpathtcmdtresulttmsgtrettlinetxtmissingtosarchtarch((s</usr/lib/python2.7/site-packages/salt/modules/dpkg_lowpkg.pytbin_pkg_info%sN	

%!
$cG@s�|s
iStddt�}i}tdddgddjg|D]}dj|�^qC�d	td
d�tjdd�tddt�}tj	j
j||�S(
u�
    Change package selection for each package specified to 'install'

    CLI Example:

    .. code-block:: bash

        salt '*' lowpkg.unpurge curl
    u
pkg.list_pkgst
purge_desireducmd.runudpkgu--set-selectionststdinu\nu{0} installtpython_shellR	utraceN(R
tTrueRRRt__context__tpoptNonetsalttutilstdatat
compare_dicts(tpackagestoldRRtnew((s</usr/lib/python2.7/site-packages/salt/modules/dpkg_lowpkg.pytunpurgeqs
+cG@s�i}djdj|��}td|dt�}|ddkrcd|d}tj|�|S|d	}xD|j�D]6}|jd
�rz|j�}|d||d<qzqzW|S(
u�
    List the packages currently installed in a dict::

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

    External dependencies::

        Virtual package resolution requires aptitude. Because this function
        uses dpkg, virtual packages will be reported as not installed.

    CLI Example:

    .. code-block:: bash

        salt '*' lowpkg.list_pkgs
        salt '*' lowpkg.list_pkgs httpd
    udpkg -l {0}u ucmd.run_allR$uretcodeiuError:  ustderrustdoutuii ii(	RRR
RtlogterrorRRR(R-tpkgsRtoutRRtcomps((s</usr/lib/python2.7/site-packages/salt/modules/dpkg_lowpkg.pyt	list_pkgs�s

cG@s�g}tg�}i}djdj|��}td|dt�}|ddkrud|d}tj|�|S|d	}x{|j�D]m}|jd
�r�|j	�}i|dd6dj|d
�d6||d<nd|kr�|j
|�q�q�Wxr|D]j}	g}
dj|	�}x1td|dt�j�D]}|
j
|�q<Wt|
�}|j|�}qWi|d6t|�d6S(u_
    List the files that belong to a package. Not specifying any packages will
    return a list of _every_ file on the system's package database (not
    generally recommended).

    CLI Examples:

    .. code-block:: bash

        salt '*' lowpkg.file_list httpd
        salt '*' lowpkg.file_list httpd postfix
        salt '*' lowpkg.file_list
    udpkg -l {0}u ucmd.run_allR$uretcodeiuError:  ustderrustdoutuii iuversioniudescriptioniuNo packages foundudpkg -L {0}ucmd.runuerrorsufiles(
tsetRRR
RR1R2RRRtappendtuniontlist(R-terrorsRR3RR4RRR5tpkgtfilestfileset((s</usr/lib/python2.7/site-packages/salt/modules/dpkg_lowpkg.pyt	file_list�s2

"
#cG@smg}i}i}djdj|��}td|dt�}|ddkrod|d}tj|�|S|d	}x{|j�D]m}|jd
�r�|j�}i|dd6dj|d
�d6||d<nd|kr�|j	|�q�q�Wxa|D]Y}	g}
dj|	�}x1td|dt�j�D]}|
j	|�q6W|
||	<q�Wi|d6|d6S(us
    List the files that belong to a package, grouped by package. Not
    specifying any packages will return a list of _every_ file on the system's
    package database (not generally recommended).

    CLI Examples:

    .. code-block:: bash

        salt '*' lowpkg.file_list httpd
        salt '*' lowpkg.file_list httpd postfix
        salt '*' lowpkg.file_list
    udpkg -l {0}u ucmd.run_allR$uretcodeiuError:  ustderrustdoutuii iuversioniudescriptioniuNo packages foundudpkg -L {0}ucmd.runuerrorsupackages(
RRR
RR1R2RRRR8(R-R;RR3RR4RRR5R<R=((s</usr/lib/python2.7/site-packages/salt/modules/dpkg_lowpkg.pyt	file_dict�s0

"
#cO@stjjj|�}|jdt�}|rCtjjj|�ntddkrltddkrld}nd}g}d	|d
}|djdj	|��7}|j
�}td
|dt�}|dr�|r�t
dj|d���q�|Snxgtjd|d�D]}|j
�r|^qD]�}i}	tjd|�\}}
x�g|jtj�D]}|j
�rg|j
�^qgD]Y}|jdd�\}
}|r�||	|
<nt|	jd��}|r�||	d<q�q�W|
jdd�d|	d<|j|	�q-W|S(u
    Return list of package information. If 'packages' parameter is empty,
    then data about all installed packages will be returned.

    :param packages: Specified packages.
    :param failhard: Throw an exception if no packages found.
    :return:
    ufailharduosuUbuntuuosrelease_infoiiu	${binary}u
${Package}udpkg-query -W -f='package:ua\nrevision:${binary:Revision}\narchitecture:${Architecture}\nmaintainer:${Maintainer}\nsummary:${Summary}\nsource:${source:Package}\nversion:${Version}\nsection:${Section}\ninstalled_size:${Installed-size}\nsize:${Size}\nMD5:${MD5sum}\nSHA1:${SHA1}\nSHA256:${SHA256}\norigin:${Origin}\nhomepage:${Homepage}\n======\ndescription:${Description}\n------\n'u {0}u ucmd.run_alltpython_chelluretcodeu'Error getting packages information: {0}ustderru------ustdoutu======u:iupackageuinstall_datei����udescription(ii(R)R*targstclean_kwargsR'R%tinvalid_kwargsRRRRR
RRtreRRtlinesept_get_pkg_install_timeRR8(R-tkwargstfailhardtbin_varRRtcalltelmtpkg_infotpkg_datat	pkg_descrtelt
pkg_info_linetkeytvaluetinstall_date((s</usr/lib/python2.7/site-packages/salt/modules/dpkg_lowpkg.pyt
_get_pkg_info�s:	 	
<>
c	C@s�t�}dj|�}tjj|�r�tjjj|��n}xdtjj	j
|j��jtj
�D];}|jd�rj|j|jdd�dj��qjqjWWdQXndjt|��S(u�
    Try to get a license from the package.
    Based on https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/

    :param pkg:
    :return:
    u/usr/share/doc/{0}/copyrightuLicense:u:iNu, (R7RRR
RR)R*R=tfopentstringutilst
to_unicodetreadRRFRtaddRRtsorted(R<tlicensestcprtfp_R((s</usr/lib/python2.7/site-packages/salt/modules/dpkg_lowpkg.pyt_get_pkg_license?s	.3cC@skd}|dk	rgdj|�}tjj|�rgtjjttjj|���j	�d}qgn|S(uc
    Return package install time, based on the /var/lib/dpkg/info/<package>.list

    :return:
    u/var/lib/dpkg/info/{0}.listuZN(
R(RRR
Rtdatetimetutcfromtimestamptinttgetmtimet	isoformat(R<tiso_timetlocation((s</usr/lib/python2.7/site-packages/salt/modules/dpkg_lowpkg.pyRGRs4c

C@s;d}tjjjd�s/tjj|�r6t�St�}d}d}tjjj|���}x�tjj	j
|j��j|�D]�}t�}xs||jtj
�D][}|jdd�}t|�dkr�q�n|\}}	|	j�r�|	||j�<q�q�W|j|�r�||||<q�q�WWdQX|S(	u�
    Get the package information of the available packages, maintained by dselect.
    Note, this will be not very useful, if dselect isn't installed.

    :return:
    u/var/lib/dpkg/availableudselectuPackage:upackageu: iiN(R)R*R
twhichRRtdictR=RVRWRXRYRRFtlenRtlowerR(
tavailRtpkg_mrktpkg_nameR^RMtnfoRRRRS((s</usr/lib/python2.7/site-packages/salt/modules/dpkg_lowpkg.pyt_get_pkg_ds_availas&)	+	c

O@s/t�}tjjj|�}|jdt�}|rLtjjj|�nt�}x�t	d||�D]�}xC|j
|di�j�D]%\}}||kr�|||<q�q�Wx?dddddd	d
ddg	D]}||kr�||=q�q�Wt|d�}	|	r|	|d
<n|||d<qhW|S(uK
    Returns a detailed summary of package information for provided package names.
    If no packages are specified, all packages will be returned.

    .. versionadded:: 2015.8.1

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

    failhard
        Whether to throw an exception if none of the packages are installed.
        Defaults to True.

        .. versionadded:: 2016.11.3

    CLI example:

    .. code-block:: bash

        salt '*' lowpkg.info
        salt '*' lowpkg.info apache2 bash
        salt '*' lowpkg.info 'php5*' failhard=false
    ufailhardRIupackageuinstalled_sizeudependsu
recommendsuprovidesureplacesu	conflictsubugsudescription-md5utaskulicense(
RoR)R*RBRCR'R%RDRhRURtitemsR_(
R-RHtdselect_pkg_availRIRR<t	pkg_ext_kt	pkg_ext_vtt_keytlic((s</usr/lib/python2.7/site-packages/salt/modules/dpkg_lowpkg.pytinfo�s(		)
(!t__doc__t
__future__RRRtloggingRRER`tsalt.utils.argsR)tsalt.utils.datatsalt.utils.filestsalt.utils.pathtsalt.utils.stringutilstsalt.exceptionsRRt	getLoggert__name__R1RRR!R0R6R?R@RUR_RGRoRv(((s</usr/lib/python2.7/site-packages/salt/modules/dpkg_lowpkg.pyt<module>s0	
L		"	*	)	@			

Zerion Mini Shell 1.0