Added __virtual__ and __virtualname__ to inotify beacon module

This commit is contained in:
Seth House 2015-01-26 18:07:13 -07:00
parent b777d3cba1
commit 2f7376ad6b

View File

@ -3,10 +3,22 @@ Watch files and translate the changes into salt events
'''
# Import python libs
import collections
# Import third party libs
import pyinotify
DEFAULT_MASK = pyinotify.IN_CREATE | pyinotify.IN_DELETE | pyinotify.IN_MODIFY
# Import third party libs
try:
import pyinotify
HAS_PYINOTIFY = True
DEFAULT_MASK = pyinotify.IN_CREATE | pyinotify.IN_DELETE | pyinotify.IN_MODIFY
except ImportError:
HAS_PYINOTIFY = False
DEFAULT_MASK = None
__virtualname__ = 'inotify'
def __virtual__():
if HAS_PYINOTIFY:
return __virtualname__
return False
def _enqueue(revent):
@ -27,6 +39,7 @@ def _get_notifier():
__context__['inotify.notifier'] = pyinotify.Notifier(wm, _enqueue)
return __context__['inotify.notifier']
def beacon(config):
'''
Watch the configured files