mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-23 01:16:18 +00:00
Send exceptions to logger and fixed some errors
This commit is contained in:
parent
4ec9aa11f2
commit
429fdcf954
@ -31,7 +31,7 @@ from supysonic.scanner import Scanner
|
|||||||
|
|
||||||
OP_SCAN = 1
|
OP_SCAN = 1
|
||||||
OP_REMOVE = 2
|
OP_REMOVE = 2
|
||||||
OP_MOVE = 3
|
OP_MOVE = 4
|
||||||
|
|
||||||
class SupysonicWatcherEventHandler(PatternMatchingEventHandler):
|
class SupysonicWatcherEventHandler(PatternMatchingEventHandler):
|
||||||
def __init__(self, queue, logger):
|
def __init__(self, queue, logger):
|
||||||
@ -42,6 +42,12 @@ class SupysonicWatcherEventHandler(PatternMatchingEventHandler):
|
|||||||
self.__queue = queue
|
self.__queue = queue
|
||||||
self.__logger = logger
|
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):
|
def on_created(self, event):
|
||||||
self.__logger.debug("File created: '%s'", event.src_path)
|
self.__logger.debug("File created: '%s'", event.src_path)
|
||||||
self.__queue.put(event.src_path, OP_SCAN)
|
self.__queue.put(event.src_path, OP_SCAN)
|
||||||
@ -55,7 +61,7 @@ class SupysonicWatcherEventHandler(PatternMatchingEventHandler):
|
|||||||
self.__queue.put(event.src_path, OP_SCAN)
|
self.__queue.put(event.src_path, OP_SCAN)
|
||||||
|
|
||||||
def on_moved(self, event):
|
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)
|
self.__queue.put(event.src_path, OP_MOVE)
|
||||||
|
|
||||||
class Event(object):
|
class Event(object):
|
||||||
@ -101,6 +107,12 @@ class ScannerProcessingQueue(Thread):
|
|||||||
self.__running = True
|
self.__running = True
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
try:
|
||||||
|
self.__run()
|
||||||
|
except Exception, e:
|
||||||
|
self.__logger.critical(e)
|
||||||
|
|
||||||
|
def __run(self):
|
||||||
while self.__running:
|
while self.__running:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user