diff options
author | Siddharth Ravikumar <sravik@bgsu.edu> | 2015-01-28 20:08:31 -0500 |
---|---|---|
committer | Siddharth Ravikumar <sravik@bgsu.edu> | 2015-01-28 20:08:31 -0500 |
commit | 002c07684d97eae94881f7e45f07206ae4c6827a (patch) | |
tree | 94a9f7b53885d50736195978234342861a12c4f9 | |
parent | 24eb6541326111f58b750f5be116dc66ce072bd5 (diff) |
combox/events.py: ComboxDirMonitor now inherits LoggingEventHandler instead of FileSystemEventHandler.
-rw-r--r-- | combox/events.py | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/combox/events.py b/combox/events.py index f4bbcc0..ddd4a2c 100644 --- a/combox/events.py +++ b/combox/events.py @@ -21,7 +21,7 @@ import logging from os import path -from watchdog.events import FileSystemEventHandler +from watchdog.events import LoggingEventHandler from combox.crypto import split_and_encrypt from combox.file import (mk_nodedir, rm_nodedir, rm_shards, @@ -29,7 +29,7 @@ from combox.file import (mk_nodedir, rm_nodedir, rm_shards, from combox.silo import ComboxSilo -class ComboxDirMonitor(FileSystemEventHandler): +class ComboxDirMonitor(LoggingEventHandler): """Monitors Combox directory for changes and does its crypto thing. """ @@ -38,13 +38,11 @@ class ComboxDirMonitor(FileSystemEventHandler): """ config: a dictinary which contains combox configuration. """ + super(ComboxDirMonitor, self).__init__() + self.config = config self.silo = ComboxSilo(self.config) - logging.basicConfig(level=logging.INFO, - format='%(asctime)s - %(message)s', - datefmt='%Y-%m-%d %H:%M:%S') - def housekeep(self): """Recursively traverses combox directory, discovers changes and updates silo and node directories. @@ -111,10 +109,6 @@ class ComboxDirMonitor(FileSystemEventHandler): self.silo.remove(event.src_path) self.silo.update(event.dest_path) - type_ = 'directory' if event.is_directory else 'file' - logging.info("Moved %s: from %s to %s", type_, event.src_path, - event.dest_path) - def on_created(self, event): super(ComboxDirMonitor, self).on_created(event) @@ -128,9 +122,6 @@ class ComboxDirMonitor(FileSystemEventHandler): # store file info in silo. self.silo.update(event.src_path) - type_ = 'directory' if event.is_directory else 'file' - logging.info("Created %s: %s", type_, event.src_path) - def on_deleted(self, event): super(ComboxDirMonitor, self).on_deleted(event) @@ -145,9 +136,6 @@ class ComboxDirMonitor(FileSystemEventHandler): # remove file info from silo. self.silo.remove(event.src_path) - type_ = 'directory' if event.is_directory else 'file' - logging.info("Deleted %s: %s", type_, event.src_path) - def on_modified(self, event): super(ComboxDirMonitor, self).on_modified(event) @@ -160,6 +148,3 @@ class ComboxDirMonitor(FileSystemEventHandler): split_and_encrypt(event.src_path, self.config) # update file info in silo. self.silo.update(event.src_path) - - type_ = 'directory' if event.is_directory else 'file' - logging.info("Modified %s: %s", type_, event.src_path) |