cc-4105: code formatting

This commit is contained in:
Rudi Grinberg 2012-08-14 14:00:44 -04:00
parent a2333309a7
commit d1bc4fd097
3 changed files with 23 additions and 19 deletions

View file

@ -40,5 +40,4 @@ class EventContractor(Loggable):
return True # We actually added something, hence we return true.
# events are unregistered automatically no need to screw around with them
def __unregister(self, evt):
del self.store[evt.path]
def __unregister(self, evt): del self.store[evt.path]

View file

@ -6,6 +6,9 @@ from media.monitor.pure import LazyProperty
appname = 'root'
def setup_logging(log_path):
"""
Setup logging by writing log to 'log_path'
"""
#logger = logging.getLogger(appname)
logging.basicConfig(filename=log_path, level=logging.DEBUG)
@ -16,6 +19,10 @@ def get_logger():
return logging.getLogger()
class Loggable(object):
"""
Any class that wants to log can inherit from this class and automatically
get a logger attribute that can be used like: self.logger.info(...) etc.
"""
__metaclass__ = abc.ABCMeta
@LazyProperty
def logger(self): return get_logger()

View file

@ -28,14 +28,10 @@ class Manager(Loggable):
'imported_path' : None,
'recorded_path' : None,
'problem_files_path' : None,
# This guy doesn't need to be changed, always the same.
# Gets hooked by wm to different directories
'organize_listener' : OrganizeListener(signal=
self.organize_channel),
# Also stays the same as long as its target, the directory
# which the "organized" files go to, isn't changed.
'organizer' : None,
'problem_handler' : None,
'organize_listener' : OrganizeListener(signal=
self.organize_channel),
}
def dummy(sender, event): self.watch_move( event.path, sender=sender )
dispatcher.connect(dummy, signal='watch_move', sender=dispatcher.Any,
@ -54,12 +50,14 @@ class Manager(Loggable):
# through dedicated handler objects. Because we must have access to a
# manager instance. Hence we must slightly break encapsulation.
def watch_move(self, watch_dir, sender=None):
"""
handle 'watch move' events directly sent from listener
"""
self.logger.info("Watch dir '%s' has been renamed (hence removed)" %
watch_dir)
self.remove_watch_directory(normpath(watch_dir))
def watch_signal(self):
return self.watch_listener.signal
def watch_signal(self): return self.watch_listener.signal
def __remove_watch(self,path):
# only delete if dir is actually being watched