Skip to content

Commit

Permalink
fix: debug mode in database
Browse files Browse the repository at this point in the history
  • Loading branch information
jbokser committed Feb 24, 2025
1 parent cc29e13 commit 0026efa
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions moc_prices_source/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@
sys.path.insert(0, dirname(base_dir))

from moc_prices_source.conf import get
from moc_prices_source.my_logging import make_log, INFO, DEBUG, VERBOSE
from moc_prices_source.my_logging import make_log

sys.path = bkpath


DEBUG = False

DEBUG_MODE = False
ENABLED_COIRRECTION_TO_GMT = True

to_gmt = int(round(float((datetime.datetime.utcnow() -
datetime.datetime.now()).seconds)/3600))
if to_gmt==24:
to_gmt=0


to_gmt=0
if ENABLED_COIRRECTION_TO_GMT:
to_gmt = int(round(float((datetime.datetime.utcnow() -
datetime.datetime.now()).seconds)/3600))
if to_gmt==24:
to_gmt=0


db_conf = None
Expand Down Expand Up @@ -59,7 +64,7 @@ def __init__(self, name, **kargs):
str_kargs = ', '.join( [f"{k}: {v}" for k, v in kargs.items()])
self._log.info(f'Try to connect to InfluxDB... ({str_kargs})')

if not DEBUG:
if not DEBUG_MODE:
try:
self.client = InfluxDBClient(**kargs)
if not self.name in [ d['name'] for d in self.client.get_list_database() ]:
Expand Down Expand Up @@ -97,7 +102,7 @@ def write(self, measurement, fields, tags={}, time_ = None):
body = []
body.append(item)

if DEBUG:
if DEBUG_MODE:
return

out = self.client.write_points(body, time_precision='s')
Expand Down

0 comments on commit 0026efa

Please sign in to comment.