major pep8 cleanup.

funneled scope of imports where possible
fixed #59
Added fstrings where possible
added logging both temporarily and in secondary places
This commit is contained in:
Nicholas St. Germain 2018-12-17 19:12:37 -06:00
parent 47f2f61082
commit 61fcf3b80c
13 changed files with 131 additions and 121 deletions

View file

@ -1,8 +1,6 @@
import logging
from logging import getLogger
from influxdb import InfluxDBClient
logger = logging.getLogger('varken')
class DBManager(object):
def __init__(self, server):
@ -10,12 +8,16 @@ class DBManager(object):
self.influx = InfluxDBClient(self.server.url, self.server.port, self.server.username, self.server.password,
'varken')
databases = [db['name'] for db in self.influx.get_list_database()]
self.logger = getLogger()
if 'varken' not in databases:
self.logger.info("Creating varken database")
self.influx.create_database('varken')
self.logger.info("Creating varken retention policy (30d/1h)")
self.influx.create_retention_policy('varken 30d/1h', '30d', '1', 'varken', False, '1h')
def write_points(self, data):
d = data
logger.debug('Writing Data to InfluxDB %s', d)
self.logger.debug('Writing Data to InfluxDB %s', d)
self.influx.write_points(d)