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

�
���^c@@s�dZddlmZmZmZddlZddlZddlmZddl	m
Z
ddlZddl
ZddlZddlZeje�ZdZdZdd	d
ddd
dddddddddddddgZd�Zd�Zd�Zd�Zd�Zd �Zd!�Zd"�Zd#�Zd$�Zd%�Z ej!j"j#e d&�Z$d'�Z%d(�Z&ej!j"j#e&d)�Z'dS(*u
Work with incron
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(trangeu## Line managed by Salt, do not editu/etc/incron.d/u	IN_ACCESSu	IN_ATTRIBuIN_CLOSE_WRITEuIN_CLOSE_NOWRITEu	IN_CREATEu	IN_DELETEuIN_DELETE_SELFu	IN_MODIFYuIN_MOVE_SELFu
IN_MOVED_FROMuIN_MOVED_TOuIN_OPENu
IN_ALL_EVENTSuIN_MOVEuIN_CLOSEuIN_DONT_FOLLOWu
IN_ONESHOTu
IN_ONLYDIRu
IN_NO_LOOPcC@sB||kr>|dkr+|dkr;tSq>|dk	r>tSntS(Nurandomu*(tTruetNonetFalse(toldtnew((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pyt
_needs_change$scC@srg}x(|dD]}|jdj|��qWx:|dD].}|jdj|d|d|d��q<W|S(u[
    Takes a tab list structure and renders it to a list for applying it to
    a file
    upreu{0}
ucronsu{0} {1} {2}
upathumaskucmd(tappendtformat(tlsttrettpretcron((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pyt_render_tab/scC@s
dj|�S(uL
    Returns a format string, to be used to build an incrontab command.
    u
incrontab {0}(R(tpath((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pyt_get_incron_cmdstr@scC@s&tdt|�d|dt�dkS(u�
    Writes the contents of a file to a user's incrontab

    CLI Example:

    .. code-block:: bash

        salt '*' incron.write_incron_file root /tmp/new_incron
    ucmd.retcodetrunastpython_shelli(t__salt__RR(tuserR((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pytwrite_incron_fileGs
cC@s tdt|�d|dt�S(u�
    Writes the contents of a file to a user's incrontab and return error message on error

    CLI Example:

    .. code-block:: bash

        salt '*' incron.write_incron_file_verbose root /tmp/new_incron
    ucmd.run_allRR(RRR(RR((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pytwrite_incron_file_verboseTs
cC@s�|dkr5i}ttddj|��|d<|Stjjj�}tjjj|d��#}|jtjj	j
|��WdQXtddkr�|d	kr�td
dj
||�dt�ntd
t|�d|dt�}tj|�|SdS(uS
    Takes a list of lines to be committed to a user's incrontab and writes it
    usystemusaltuuretcodeuwbNu	os_familyuSolarisurootucmd.runu
chown {0} {1}Rucmd.run_allR(t_write_filet_INCRON_SYSTEM_TABtjointsalttutilstfilestmkstemptfopent
writelinestdatatencodet
__grains__RRRRtostremove(RtlinesRRtfp_((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pyt_write_incron_linesas"#"
cC@s�tjj||�}tjj|�s^dj||�}tj|�ttj	|���nt
jjj
|d��#}|jt
jjj|��WdQXdS(u
    Writes a file to disk
    u){0} cannot be written. {1} does not existuwNi(R&RRtexistsRtlogterrortAttributeErrorRt	text_typeRRRR!twritetstringutilstto_str(tfoldertfilenameR#RtmsgR)((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pyRts
"cC@srtjj||�}y>tjjj|d�� }tjjj|j	��SWdQXWnt
tfk
rmdSXdS(u2
    Reads and returns the contents of a file
    urbNu(R&RRRRRR!R#tdecodet	readlinestOSErrortIOError(R3R4Rtcontents((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pyt
_read_file�s#cC@s5tjdjttd���djttd��S(u�
    Return the contents of the system wide incrontab

    CLI Example:

    .. code-block:: bash

        salt '*' incron.raw_system_incron
    u
read_file {0}usaltu(R,tdebugRR;RR(((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pytraw_system_incron�s
cC@sQtddkr"dj|�}ndj|�}td|dtd|dt�S(	u�
    Return the contents of the user's incrontab

    CLI Example:

    .. code-block:: bash

        salt '*' incron.raw_incron root
    u	os_familyuSolarisuincrontab -l {0}uincrontab -l -u {0}ucmd.run_stdouttrstripRR(R%RRR(Rtcmd((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pyt
raw_incron�s
c
C@s�|dkrt�}n"t|�}tjdj|��igd6gd6}t}x�|j�D]�}t|j��dkr�|j�}|d}|d}dj	|d	�}i|d
6|d6|d6}	|dj
|	�qa|dj
|�qaW|S(
u�
    Return the contents of the specified user's incrontab

    CLI Example:

    .. code-block:: bash

        salt '*' incron.list_tab root
    usystemu
user data {0}ucronsupreiiiu iupathumaskucmd(R=R@R,R<RRt
splitlinestlentsplitRR(
RR#RtflagtlinetcompsRtmaskR?tdat((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pytlist_tab�s&






ulsc
C@s�tj|�j�}x0|jd�D]}|tkr%dj|�Sq%Wt}|jd�}|j�t|�}g}x�t	|d�D]�\}}	||	dkr1|	d|kr!|	djd�}
|
j�|
|kr�dSt
g|D]}||
k^q��rt}q.|j|	�q>|j|	�q�|j|	�q�Wi|d6|d6|d6}	|j|	�||d<t
|t|��}|dr�|d	S|r�d
SdSdS(
u�
    Sets an incron job up for a specified user.

    CLI Example:

    .. code-block:: bash

        salt '*' incron.set_job root '/root' 'IN_MODIFY' 'echo "$$ $@ $# $% $&"'
    u,uInvalid mask type: {0}ucronsupathucmdumaskupresenturetcodeustderruupdatedunewN(RR/tupperRCt_MASK_TYPESRRtsortRIt	enumeratetanyRRR*R(
RRRGR?titemtupdatedtarg_maskR
t
updated_cronsRt	cron_masktxtcomdat((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pytset_job�s<

%	


c
C@s9tj|�j�}x0|jd�D]}|tkr%dj|�Sq%Wt|�}d}d}x�tt	|d��D]m}|dk	r�Pn||d|dkrw||d|dkr�||d|dkr�|}q�q�qwqwW|dk	r|dj
|�d}nt|t|��}	|	d	r5|	d
S|S(u�
    Remove a incron job for a specified user. If any of the day/time params are
    specified, the job will only be removed if the specified params match.

    CLI Example:

    .. code-block:: bash

        salt '*' incron.rm_job root /path
    u,uInvalid mask type: {0}uabsentucronsupathucmdumaskuremoveduretcodeustderrN(
RR/RJRCRKRRIRRRBtpopR*R(
RRRGR?ROR
Rtrm_tindRU((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pytrm_jobs*	
urm((t__doc__t
__future__RRRtloggingR&tsalt.extRtsalt.ext.six.movesRtsalt.utils.dataRtsalt.utils.filestsalt.utils.functoolstsalt.utils.stringutilst	getLoggert__name__R,tTAGRRKR
RRRRR*RR;R=R@RIRt	functoolstalias_functiontlsRVRZtrm(((s7/usr/lib/python2.7/site-packages/salt/modules/incron.pyt<module>sD											
	
						%	:	,

Zerion Mini Shell 1.0