Adding better documentation and more tests, but still missing tests for Scheduler

This commit is contained in:
Mitsuo Takaki
2016-05-01 00:41:33 -07:00
parent f254bddd0f
commit 072aed1024
5 changed files with 80 additions and 4 deletions

View File

@@ -20,6 +20,8 @@ class Configuration(object):
self.data = load(file(self.config_file, 'r'))
self.expectations = [Expectaction.create(expectation) for expectation
in self.data['endpoint']['expectation']]
for expectation in self.expectations:
self.logger.info('Registered expectation: %s' % (expectation,))
def evaluate(self):
"""Sends the request to the URL set in the configuration and executes

View File

@@ -30,11 +30,12 @@ class Scheduler(object):
self.logger = logging.getLogger('cachet_url_monitor.scheduler.Scheduler')
self.configuration = Configuration(config_file)
self.agent = Agent(self.configuration)
self.stop = False
def start(self):
self.agent.start()
self.logger.info('Starting monitor agent...')
while True:
while not self.stop:
schedule.run_pending()
time.sleep(self.configuration.data['frequency'])
@@ -42,6 +43,8 @@ class Scheduler(object):
if __name__ == "__main__":
FORMAT = "%(levelname)9s [%(asctime)-15s] %(name)s - %(message)s"
logging.basicConfig(format=FORMAT, level=logging.INFO)
for handler in logging.root.handlers:
handler.addFilter(logging.Filter('cachet_url_monitor'))
if len(sys.argv) <= 1:
logging.fatal('Missing configuration file argument')