1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 17:06:17 +00:00

Send exceptions to logger and fixed some errors

This commit is contained in:
spl0k 2014-08-31 12:47:40 +02:00
parent 4ec9aa11f2
commit 429fdcf954

View File

@ -31,7 +31,7 @@ from supysonic.scanner import Scanner
OP_SCAN = 1
OP_REMOVE = 2
OP_MOVE = 3
OP_MOVE = 4
class SupysonicWatcherEventHandler(PatternMatchingEventHandler):
def __init__(self, queue, logger):
@ -42,6 +42,12 @@ class SupysonicWatcherEventHandler(PatternMatchingEventHandler):
self.__queue = queue
self.__logger = logger
def dispatch(self, event):
try:
super(SupysonicWatcherEventHandler, self).dispatch(event)
except Exception, e:
self.__logger.critical(e)
def on_created(self, event):
self.__logger.debug("File created: '%s'", event.src_path)
self.__queue.put(event.src_path, OP_SCAN)
@ -55,7 +61,7 @@ class SupysonicWatcherEventHandler(PatternMatchingEventHandler):
self.__queue.put(event.src_path, OP_SCAN)
def on_moved(self, event):
self.__logger.debug("File moved: '%s' -> '%s'", event.src_path, event.dst_path)
self.__logger.debug("File moved: '%s' -> '%s'", event.src_path, event.dest_path)
self.__queue.put(event.src_path, OP_MOVE)
class Event(object):
@ -101,6 +107,12 @@ class ScannerProcessingQueue(Thread):
self.__running = True
def run(self):
try:
self.__run()
except Exception, e:
self.__logger.critical(e)
def __run(self):
while self.__running:
time.sleep(0.1)