diff options
author | Dennis Eriksen <d@ennis.no> | 2023-11-02 12:49:02 +0100 |
---|---|---|
committer | Dennis Eriksen <d@ennis.no> | 2023-11-02 12:49:02 +0100 |
commit | b322330b000a6d566e99cde1c29429a23b5f2cb3 (patch) | |
tree | e6c6b646869e853de4dd9179d5c6f5a5ce5bc153 /scripts/common/__init__.py | |
parent | adding linting with ruff (diff) | |
download | energyscripts-b322330b000a6d566e99cde1c29429a23b5f2cb3.tar.gz |
adding formatting with ruff
Diffstat (limited to 'scripts/common/__init__.py')
-rw-r--r-- | scripts/common/__init__.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/scripts/common/__init__.py b/scripts/common/__init__.py index 83f1b66..e349610 100644 --- a/scripts/common/__init__.py +++ b/scripts/common/__init__.py @@ -1,12 +1,12 @@ #!/usr/bin/env python3 -''' common functions and stuff ''' +""" common functions and stuff """ import logging import os import sys from datetime import datetime -QUEUE = bool(os.environ.get('el_QUEUE', False)) +QUEUE = bool(os.environ.get("el_QUEUE", False)) name = os.path.splitext(os.path.split(sys.argv[0])[-1])[0] @@ -17,17 +17,17 @@ logging.basicConfig(format="%(name)s: %(levelname)s %(message)s") # Use queue or postgres if QUEUE is True: - log.debug('Importing dbi from queue') + log.debug("Importing dbi from queue") from .queue import dbi else: - log.debug('Importing dbi from postgres') + log.debug("Importing dbi from postgres") from .postgres import dbi # Insert state def statein(sensor, value, device_class, unit, **kwargs): - ''' Insert new state in db ''' - verbose = bool(kwargs['verbose']) if 'verbose' in kwargs else False + """Insert new state in db""" + verbose = bool(kwargs["verbose"]) if "verbose" in kwargs else False sql = """INSERT INTO states (sensor_id, @@ -38,10 +38,6 @@ def statein(sensor, value, device_class, unit, **kwargs): SELECT sensors.id, %s, %s, %s, %s FROM sensors WHERE sensors.name = %s;""" - values = (value, - device_class, - unit, - datetime.utcnow(), - sensor) - log.debug('dbi(' + sql + ',' + str(values) + ')') + values = (value, device_class, unit, datetime.utcnow(), sensor) + log.debug("dbi(" + sql + "," + str(values) + ")") dbi(sql, values, verbose=verbose) |