From 429fdcf95422322c1625d82a6313030318a45a5e Mon Sep 17 00:00:00 2001 From: spl0k Date: Sun, 31 Aug 2014 12:47:40 +0200 Subject: [PATCH] Send exceptions to logger and fixed some errors --- bin/supysonic-watcher | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bin/supysonic-watcher b/bin/supysonic-watcher index fdec9c9..179e2cf 100755 --- a/bin/supysonic-watcher +++ b/bin/supysonic-watcher @@ -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)