%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@sLdZddlmZmZmZddlZddlZddlmZy*ddl	m
Z
ddlmZe
ZWn-ek
r�eZdefd��YZnXd	Zeje�Zd
ddd
gZdefd��YZd�Zd�Zdefd��YZd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"dS(u�
watchdog beacon

.. versionadded:: 2019.2.0

Watch files and translate the changes into salt events

:depends:   - watchdog Python module >= 0.8.3

i(tabsolute_importtprint_functiontunicode_literalsN(tmap(tObserver(tFileSystemEventHandlerRcB@seZdZd�ZRS(u' A dummy class to make the import work cC@sdS(N((tself((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyt__init__s(t__name__t
__module__t__doc__R(((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyRsuwatchdogucreateudeleteumodifyumovetHandlercB@sJeZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cC@s/tt|�j�|pt|_||_dS(N(tsuperRRtDEFAULT_MASKtmaskstqueue(RRR((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyR-scC@s|j|d�dS(Nucreate(t_append_if_mask(Rtevent((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyt
on_created2scC@s|j|d�dS(Numodify(R(RR((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyton_modified5scC@s|j|d�dS(Nudelete(R(RR((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyt
on_deleted8scC@s|j|d�dS(Numove(R(RR((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyton_moved;scC@s!tj|�|j||�dS(N(tloggingtdebugt_append_path_if_mask(RRtmask((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyR>s
cC@s&||jkr"|jj|�ndS(N(RRtappend(RRR((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyRCsN(
RR	tNoneRRRRRRR(((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyR,s					cC@str
tStS(N(tHAS_WATCHDOGt__virtualname__tFalse(((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyt__virtual__HscC@s�dtkr�tj�}t�}xc|jdi�D]O}|jd�j|�}|jdt�}t||�}|j||�q4W|j�|td<|td<ntdS(uL
    Check the context for the notifier and construct it if not present
    uwatchdog.observerudirectoriesumaskuwatchdog.queue(	t__context__tcollectionstdequeRtgetR
Rtscheduletstart(tconfigRtobservertpathtpath_paramsRt
event_handler((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyt
_get_queueNs	


tValidationErrorcB@seZRS((RR	(((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyR,dscC@s?yt|�tdfSWn tk
r:}tt|�fSXdS(u+
    Validate the beacon configuration
    uValid beacon configurationN(t	_validatetTrueR,Rtstr(R&terror((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pytvalidatehs

cC@s�t|t�std��ni}x|D]}|j|�q+Wd|kr]td��nt|dt�std��nx$|dD]}t|d|�q�WdS(Nu1Configuration for watchdog beacon must be a list.udirectoriesu;Configuration for watchdog beacon must include directories.uCConfiguration for watchdog beacon directories must be a dictionary.(t
isinstancetlistR,tupdatetdictt_validate_path(R&t_configtpartR(((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyR-ts
cC@s?t|t�std��nd|kr;t|d�ndS(NuFConfiguration for watchdog beacon directory path must be a dictionary.umask(R2R5R,t_validate_mask(tpath_config((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyR6�s
c@s_ddddg�t|t�s0td��nt�fd�|D��r[td��ndS(Nucreateumodifyudeleteumoveu4Configuration for watchdog beacon mask must be list.c3@s|]}|�kVqdS(N((t.0R(t
valid_mask(s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pys	<genexpr>�su7Configuration for watchdog beacon contains invalid mask(R2R3R,tany(tmask_config((R<s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyR9�s	cC@sitd6|jd6|jd6S(Nutagupathuchange(Rtsrc_patht
event_type(R((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyt
to_salt_event�s
cC@sXi}tt|j|��t|�}g}x#|rS|jt|j���q1W|S(u�
    Watch the configured directories

    Example Config

    .. code-block:: yaml

        beacons:
          watchdog:
            - directories:
                /path/to/dir:
                  mask:
                    - create
                    - modify
                    - delete
                    - move

    The mask list can contain the following events (the default mask is create,
    modify delete, and move):
    * create  - File or directory is created in watched directory
    * modify  - The watched directory is modified
    * delete  - File or directory is deleted from watched directory
    * move    - File or directory is moved or renamed in the watched directory
    (R3RR4R+RRAtpopleft(R&R7Rtret((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pytbeacon�s	cC@s)tjdd�}|r%|j�ndS(Nuwatchdog.observer(R tpopRtstop(R&R'((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pytclose�s(#R
t
__future__RRRR!Rtsalt.ext.six.movesRtwatchdog.observersRtwatchdog.eventsRR.RtImportErrorRtobjectRt	getLoggerRtlogR
RRR+t	ExceptionR,R1R-R6R9RARDRG(((s9/usr/lib/python2.7/site-packages/salt/beacons/watchdog.pyt<module>s8

						
			&

Zerion Mini Shell 1.0