%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@skdZddlmZmZddlZddlZddlZddlZddlZddl	Z
ddlmZyddl
Z
eZe
je
jBe
jBZiZxIee
�D];Zejd�r�edj�Zee
e�ee<q�q�WWnek
reZdZnXdZeje �Z!d�Z"d	�Z#d
�Z$d�Z%d�Z&d
�Z'd�Z(dS(u
Watch files and translate the changes into salt events

:depends:   - pyinotify Python module >= 0.9.5

:Caution:   Using generic mask options like open, access, ignored, and
            closed_nowrite with reactors can easily cause the reactor
            to loop on itself. To mitigate this behavior, consider
            setting the `disable_during_state_run` flag to `True` in
            the beacon configuration.

:note: The `inotify` beacon only works on OSes that have `inotify`
       kernel support.

i(tabsolute_importtunicode_literalsN(tmapuIN_iuinotifycC@str
tStS(N(t
HAS_PYINOTIFYt__virtualname__tFalse(((s8/usr/lib/python2.7/site-packages/salt/beacons/inotify.pyt__virtual__2scC@stj|d�S(u1
    Return the int that represents the mask
    i(tMASKStget(tmask((s8/usr/lib/python2.7/site-packages/salt/beacons/inotify.pyt	_get_mask8scC@stdj|�dS(u
    Enqueue the event
    u
inotify.queueN(t__context__tappend(trevent((s8/usr/lib/python2.7/site-packages/salt/beacons/inotify.pyt_enqueue?scC@s�dtkr{tj�td<tj�}tj|t�td<d|kr{t|dt�r{|dr{tdj	�q{ntdS(uL
    Check the context for the notifier and construct it if not present
    uinotify.notifieru
inotify.queueucoalesce(
Rtcollectionstdequet	pyinotifytWatchManagertNotifierRt
isinstancetbooltcoalesce_events(tconfigtwm((s8/usr/lib/python2.7/site-packages/salt/beacons/inotify.pyt
_get_notifierFs
cC@s�ddddddddd	d
ddd
ddddg}t|t�sRtdfSi}tt|j|��d|kr�tdfSxP|jd�D]?}t|d|t�s�tdfStd�|d|D��s�tdfSd|d|krt|d|dt�stdfSnd|d|kr[t|d|dt�s[tdfSnd|d|kr�t|d|dt�s�tdfSx<|d|dD]%}||kr�tdj	|�fSq�Wq�q�Wt
dfS( u+
    Validate the beacon configuration
    uaccessuattribu
close_nowriteuclose_writeucreateudeleteudelete_selfuexcl_unlinkuignoredumodifyu
moved_fromumoved_tou	move_selfuoneshotuonlydiruopenuunmountu0Configuration for inotify beacon must be a list.ufilesu4Configuration for inotify beacon must include files.u@Configuration for inotify beacon must be a list of dictionaries.cs@s|]}|dkVqdS(umaskurecurseuauto_addN(umaskurecurseuauto_add((t.0tj((s8/usr/lib/python2.7/site-packages/salt/beacons/inotify.pys	<genexpr>~suNConfiguration for inotify beacon must contain mask, recurse or auto_add items.uauto_addu:Configuration for inotify beacon auto_add must be boolean.urecurseu9Configuration for inotify beacon recurse must be boolean.umasku3Configuration for inotify beacon mask must be list.u9Configuration for inotify beacon invalid mask option {0}.uValid beacon configuration(RtlistRRtupdateRtdicttanyRtformattTrue(Rt
VALID_MASKt_configtpathR	((s8/usr/lib/python2.7/site-packages/salt/beacons/inotify.pytvalidateUsV	


	



	c
C@s�i}tt|j|��g}t|�}|j}|jd�r4|j�|j�td}x�|r0|j	�}t
}|j}x>|dkr�||jdi�kr�Pnt
jj|�}q�W|d|jdd�}	|	r�t|	t�r�x�|	D]�}
t|
t�r�tt|
��}|
|jdt�r�y"tj||j�r]t}nWq�tk
r�tjd|�q�Xq�|}
q�d	|
kr�tj|j|
�r�t}q�q�|jj|
�r�t}q�q�Wn|ri|jd
6|jd6|jd6}|j|�qgtjd
|j|�qgWnt�}
x(|j D]}|
j!|j |j�qGWxm|jdd�D]Y}t|d|t�rU|d|jdt"�}t|t�r�d}xN|D]}|t#|�O}q�Wn-t|t$j%j&j'�rt#|�}n|}|}|d|jdt�}|d|jdt�}nt"}t}t}||
krx^|j D]�}||j |jkr}t}|j |j(|kr�t
}n|j |j)|kr�t
}n|r|j*|d|d|d|�qq}q}Wq{t
jj+|�r{|d|jdd�}	d}t|	t�r�g}xD|	D]<}
t|
t�r�|jt|
�d�q]|j|
�q]Wt-j.|�}n|j/||d|d|d|�q{q{W|S(u�	
    Watch the configured files

    Example Config

    .. code-block:: yaml

        beacons:
          inotify:
            - files:
                /path/to/file/or/dir:
                  mask:
                    - open
                    - create
                    - close_write
                  recurse: True
                  auto_add: True
                  exclude:
                    - /path/to/file/or/dir/exclude1
                    - /path/to/file/or/dir/exclude2
                    - /path/to/file/or/dir/regex[a-m]*$:
                        regex: True
            - coalesce: True

    The mask list can contain the following events (the default mask is create,
    delete, and modify):

    * access            - File accessed
    * attrib            - File metadata changed
    * close_nowrite     - Unwritable file closed
    * close_write       - Writable file closed
    * create            - File created in watched directory
    * delete            - File deleted from watched directory
    * delete_self       - Watched file or directory deleted
    * modify            - File modified
    * moved_from        - File moved out of watched directory
    * moved_to          - File moved into watched directory
    * move_self         - Watched file moved
    * open              - File opened

    The mask can also contain the following options:

    * dont_follow       - Don't dereference symbolic links
    * excl_unlink       - Omit events for children after they have been unlinked
    * oneshot           - Remove watch after one event
    * onlydir           - Operate only if name is directory

    recurse:
      Recursively watch files in the directory
    auto_add:
      Automatically start watching files that are created in the watched directory
    exclude:
      Exclude directories or files from triggering events in the watched directory.
      Can use regex if regex is set to True
    coalesce:
      If this coalescing option is enabled, events are filtered based on
      their unicity, only unique events are enqueued, doublons are discarded.
      An event is unique when the combination of its fields (wd, mask,
      cookie, name) is unique among events of a same batch. After a batch of
      events is processed any events are accepted again.
      This option is top-level (at the same level as the path) and therefore
      affects all paths that are being watched. This is due to this option
      being at the Notifier level in pyinotify.
    iu
inotify.queueu/ufilesuexcludeuuregexuFailed to compile regex: %su*utagupathuchangeuExcluding %s from event for %sumaskiurecurseuauto_addR	trectauto_addtexclude_filter(N(0RRRRt_watch_managertcheck_eventstread_eventstprocess_eventsRtpopleftR!R$RtostdirnameRRtnexttiterRtretsearchtpathnamet	Exceptiontlogtwarningtfnmatcht
startswithtmasknameRtinfotsettwatchestaddtDEFAULT_MASKR
tsalttexttsixtbinary_typeR	R'tupdate_watchtexiststNoneRt
ExcludeFiltert	add_watch(RR#trettnotifierRtqueueteventt_appendR$texcludestexcludet_excludetsubtcurrenttwdR	tr_maskR&R'Rtexcl((s8/usr/lib/python2.7/site-packages/salt/beacons/inotify.pytbeacon�s�A	


		


		


	
		,
)cC@s(dtkr$tdj�td=ndS(Nuinotify.notifier(Rtstop(R((s8/usr/lib/python2.7/site-packages/salt/beacons/inotify.pytcloseFs()t__doc__t
__future__RRRR8tloggingR.R2tsalt.ext.sixR@tsalt.ext.six.movesRRR!Rt	IN_CREATEt	IN_DELETEt	IN_MODIFYR?RtdirtvarR9tlowertkeytgetattrtImportErrorRRFRt	getLoggert__name__R6RR
RRR%RVRX(((s8/usr/lib/python2.7/site-packages/salt/beacons/inotify.pyt<module>s:

					D	�

Zerion Mini Shell 1.0