Add Watcher.setup() method for datasync

This commit is contained in:
Lance Edgar 2016-04-18 09:49:15 -05:00
parent 9c487a7a33
commit 9d72f723e8
2 changed files with 8 additions and 0 deletions

View file

@ -92,6 +92,9 @@ def watch_for_changes(config, watcher):
""" """
from rattail.db import Session, model from rattail.db import Session, model
# Let watcher do any setup it needs.
watcher.setup()
# The 'last run' value is maintained as a naive UTC datetime. # The 'last run' value is maintained as a naive UTC datetime.
timefmt = '%Y-%m-%d %H:%M:%S' timefmt = '%Y-%m-%d %H:%M:%S'
lastrun_setting = 'rattail.datasync.{0}.watcher.lastrun'.format(watcher.key) lastrun_setting = 'rattail.datasync.{0}.watcher.lastrun'.format(watcher.key)

View file

@ -37,6 +37,11 @@ class DataSyncWatcher(object):
self.key = key self.key = key
self.delay = 1 # seconds self.delay = 1 # seconds
def setup(self):
"""
This method is called when the watcher thread is first started.
"""
def get_changes(self, lastrun): def get_changes(self, lastrun):
""" """
This must be implemented by the subclass. It should check the source This must be implemented by the subclass. It should check the source