%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/logrotate.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlmZddl	Z
ddlZ
ddlZ
ddl
mZeje�ZdZidd6Zd	�Zd
�Zed�Zed�Zded
�Zded�Zd�ZdS(u 
Module for managing logrotate.
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tSaltInvocationErroru/etc/logrotate.confusetuset_cC@s tjjj�rtdfStS(u)
    Only work on POSIX-like systems
    uWThe logrotate execution module cannot be loaded: only available on non-Windows systems.(tsalttutilstplatformt
is_windowstFalsetTrue(((s:/usr/lib/python2.7/site-packages/salt/modules/logrotate.pyt__virtual__scC@s1yttj|��}Wntk
r,nX|S(u�
    Convert to an int if necessary.

    :param str value: The value to check/convert.

    :return: The converted or passed value.
    :rtype: bool|int|str
    (tintRt	text_typet
ValueError(tvalue((s:/usr/lib/python2.7/site-packages/salt/modules/logrotate.pyt_convert_if_int)s
	
cC@s�i}d}g}i}d
}tjjj|d��D}x:|D]2}tjjj|�j�}|smq@n|jd�r�q@n|j	�}d|kr�d|kr�d}t
|�dkr�|r�|}q@|}|j�q@nd|kr"d}x|D]}	|||	<q�Wg}i}q@n|dkr7|}
n|}
|dd	krd
|krfi|d
<nx�tj
|d�D]�}||d
kr�g|d
|<ntjj|d|�}t|�}
x1|
D])}|
|||<|d
|j|�q�WqzWn|}t
|�dkr7dj|d�|
|d<q@t
|�dkrdt|d�|
|d<q@t|
|d<q@WWd
QX|S(uf
    Parse a logrotate configuration file.

    Includes will also be parsed, and their configuration will be stored in the
    return dict, as if they were part of the main config file. A dict of which
    configs came from which includes will be stored in the 'include files' dict
    inside the return dict, for later reference by the user or module.
    usingleuru#u{u}umultiiiuincludeu
include filesiu N(tNoneRRtfilestfopentstringutilst
to_unicodetstript
startswithtsplittlentpoptostlistdirtpathtjoint_parse_conftappendRR
(t	conf_filetrettmodetmulti_namestmultit
prev_compstifiletlinetcompst
multi_nametkeytincludetinclude_pathtinclude_conftfile_key((s:/usr/lib/python2.7/site-packages/salt/modules/logrotate.pyR9s`	
	

	

 cC@s
t|�S(u�
    Show parsed configuration

    :param str conf_file: The logrotate configuration file.

    :return: The parsed configuration.
    :rtype: dict

    CLI Example:

    .. code-block:: bash

        salt '*' logrotate.show_conf
    (R(R!((s:/usr/lib/python2.7/site-packages/salt/modules/logrotate.pyt	show_conf~scC@sQt|�}|j|t�}|rM|r:|j|t�Stjd|�n|S(u
    Get the value for a specific configuration line.

    :param str key: The command or stanza block to configure.
    :param str value: The command value or command of the block specified by the key parameter.
    :param str conf_file: The logrotate configuration file.

    :return: The value for a specific configuration line.
    :rtype: bool|int|str

    CLI Example:

    .. code-block:: bash

        salt '*' logrotate.get rotate

        salt '*' logrotate.get /var/log/wtmp rotate /etc/logrotate.conf
    u Block '%s' not present or empty.(RtgetR	t_LOGtwarning(R+RR!tcurrent_conftstanza((s:/usr/lib/python2.7/site-packages/salt/modules/logrotate.pyR1�scC@s<t|�}xB|dD]6}||d|krtjj|d|�}qqWtj�}idd6td6|d6dj|�d6td	6}|dkrD|j	|t�}t
|t�r�d
j|�}	t|	��n||kr�t
jd||�tS|tkr|}n|r-dj||�}n|jitd
6�n�|j	|t��}
|
r�t
|
t�r�d}	t|	��n||
j	|t�kr�t
jd||�tS|r�||
|<n|
|=t||
�}|jidj|�d6dd6td6�|ji|d6�t
jd||�td|�S(u
    Set a new value for a specific configuration line.

    :param str key: The command or block to configure.
    :param str value: The command value or command of the block specified by the key parameter.
    :param str setting: The command value for the command specified by the value parameter.
    :param str conf_file: The logrotate configuration file.

    :return: A boolean representing whether all changes succeeded.
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' logrotate.set rotate 2

    Can also be used to set a single value inside a multiline configuration
    block. For instance, to change rotate in the following block:

    .. code-block:: text

        /var/log/wtmp {
            monthly
            create 0664 root root
            rotate 1
        }

    Use the following command:

    .. code-block:: bash

        salt '*' logrotate.set /var/log/wtmp rotate 2

    This module also has the ability to scan files inside an include directory,
    and make changes in the appropriate file.
    u
include filesuincludeiuflagsubackupupathu^{0}.*upatternushow_changesuSError: {0} includes a dict, and a specific setting inside the dict was not declareduCommand '%s' already has: %su{0} {1}uprepend_if_not_founduXError: A setting for a dict was declared, but the configuration line given is not a dictu^{0}.*?{{.*?}}iuappend_if_not_foundurepluSetting file '%s' line: %sufile.replaceN(RRRRRR
R	tformatRR1t
isinstancetdictRR2tdebugR
tupdatet_dict_to_stanzat__salt__(R+RtsettingR!tconfR,tnew_linetkwargst
current_valuet	error_msgR5((s:/usr/lib/python2.7/site-packages/salt/modules/logrotate.pytset_�sV& 
		
	cC@s^d}xE|D]=}||tkr0d||<n|dj|||�7}q
Wdj||�S(u/
    Convert a dict to a multi-line stanza
    uu    {0} {1}
u{0} {{
{1}}}(R
R6(R+R5R"tskey((s:/usr/lib/python2.7/site-packages/salt/modules/logrotate.pyR;s

(t__doc__t
__future__RRRRtloggingtsalt.extRtsalt.utils.filesRtsalt.utils.platformtsalt.utils.stringutilstsalt.exceptionsRt	getLoggert__name__R2t
_DEFAULT_CONFt__func_alias__RRRR0RR1RCR;(((s:/usr/lib/python2.7/site-packages/salt/modules/logrotate.pyt<module>s&
	
	Eg

Zerion Mini Shell 1.0