replaced watchdog with pyinotify

This commit is contained in:
byt3bl33d3r 2015-08-22 16:51:50 +02:00
commit 885ecc3a4e
5 changed files with 27 additions and 20 deletions

View file

@ -17,24 +17,27 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import pyinotify
import threading
from configobj import ConfigObj
class ConfigWatcher(FileSystemEventHandler):
class ConfigWatcher(pyinotify.ProcessEvent):
@property
def config(self):
return ConfigObj("./config/mitmf.conf")
def on_modified(self, event):
def process_IN_MODIFY(self, event):
self.on_config_change()
def start_config_watch(self):
observer = Observer()
observer.schedule(self, path='./config', recursive=False)
observer.start()
wm = pyinotify.WatchManager()
wm.add_watch('./config/mitmf.conf', pyinotify.IN_MODIFY)
notifier = pyinotify.Notifier(wm, self)
t = threading.Thread(name='ConfigWatcher', target=notifier.loop)
t.setDaemon(True)
t.start()
def on_config_change(self):
""" We can subclass this function to do stuff after the config file has been modified"""