mirror of
https://github.com/mtan93/cachet-url-monitor.git
synced 2026-03-08 05:31:58 +00:00
Exposing the configuration to avoid the current parsing problems. #20
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import abc
|
import abc
|
||||||
|
import copy
|
||||||
import logging
|
import logging
|
||||||
import time
|
|
||||||
|
|
||||||
import status as st
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import time
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
import status as st
|
||||||
|
from yaml import dump
|
||||||
from yaml import load
|
from yaml import load
|
||||||
|
|
||||||
# This is the mandatory fields that must be in the configuration file in this
|
# This is the mandatory fields that must be in the configuration file in this
|
||||||
@@ -61,6 +63,9 @@ class Configuration(object):
|
|||||||
self.config_file = config_file
|
self.config_file = config_file
|
||||||
self.data = load(file(self.config_file, 'r'))
|
self.data = load(file(self.config_file, 'r'))
|
||||||
|
|
||||||
|
# Exposing the configuration to confirm it's parsed as expected.
|
||||||
|
self.print_out()
|
||||||
|
|
||||||
# We need to validate the configuration is correct and then validate the component actually exists.
|
# We need to validate the configuration is correct and then validate the component actually exists.
|
||||||
self.validate()
|
self.validate()
|
||||||
|
|
||||||
@@ -149,6 +154,16 @@ class Configuration(object):
|
|||||||
if status > self.status:
|
if status > self.status:
|
||||||
self.status = status
|
self.status = status
|
||||||
self.message = expectation.get_message(self.request)
|
self.message = expectation.get_message(self.request)
|
||||||
|
self.logger.info(self.message)
|
||||||
|
|
||||||
|
def print_out(self):
|
||||||
|
self.logger.info('Current configuration:\n%s' % (self.__repr__()))
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
temporary_data = copy.deepcopy(self.data)
|
||||||
|
# Removing the token so we don't leak it in the logs.
|
||||||
|
del temporary_data['cachet']['token']
|
||||||
|
return dump(temporary_data, default_flow_style=False)
|
||||||
|
|
||||||
def push_status(self):
|
def push_status(self):
|
||||||
"""Pushes the status of the component to the cachet server. It will update the component
|
"""Pushes the status of the component to the cachet server. It will update the component
|
||||||
|
|||||||
Reference in New Issue
Block a user