add debug logging to win32 filemon

This commit is contained in:
Lance Edgar 2012-08-11 12:07:40 -07:00
parent 3fd052b169
commit 531d3d830e

View file

@ -31,6 +31,7 @@ import sys
import socket
import time
import Queue
import logging
from traceback import format_exception
import edbob
@ -46,6 +47,9 @@ if sys.platform == 'win32': # docs should build for everyone
import win32api
log = logging.getLogger(__name__)
class FileMonitorService(win32serviceutil.ServiceFramework):
"""
Implements edbob's file monitor Windows service.
@ -80,9 +84,14 @@ class FileMonitorService(win32serviceutil.ServiceFramework):
self.monitored = {}
monitored = edbob.config.require('edbob.filemon', 'monitored')
monitored = monitored.split(',')
for m in monitored:
m = m.strip()
self.monitored[m] = MonitorProfile(m)
for key in monitored:
key = key.strip()
profile = MonitorProfile(key)
self.monitored[key] = profile
log.debug("Monitoring profile '%s': %s" % (key, profile.dirs))
for path in profile.dirs:
if not os.path.exists(path):
log.warning("Path does not exist: %s" % path)
queue = Queue.Queue()
for key in self.monitored:
@ -95,6 +104,7 @@ class FileMonitorService(win32serviceutil.ServiceFramework):
except Queue.Empty:
pass
else:
log.debug("Got notification: %s, %s, %s" % (key, ftype, fpath))
# if ftype == 'file' and action in (
# ACTION_CREATE, ACTION_UPDATE):
if ftype == 'file' and action == ACTION_CREATE: