aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/common/queue.py
diff options
context:
space:
mode:
authorDennis Eriksen <d@ennis.no>2023-04-03 12:23:40 +0200
committerDennis Eriksen <d@ennis.no>2023-04-03 12:23:40 +0200
commit50f62d0b6a17677104f0e4d39c5ff7223c5239b2 (patch)
tree40fba651452a6a5fd4cc46603abaccaca9c53426 /scripts/common/queue.py
parentadding service for esphomeapi, and allowing run.sh to take arguments (diff)
downloadenergyscripts-50f62d0b6a17677104f0e4d39c5ff7223c5239b2.tar.gz
adding function to insert state without defining sql
Diffstat (limited to 'scripts/common/queue.py')
-rw-r--r--scripts/common/queue.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/scripts/common/queue.py b/scripts/common/queue.py
index cb90423..b4fa369 100644
--- a/scripts/common/queue.py
+++ b/scripts/common/queue.py
@@ -3,20 +3,26 @@
import os
import pickle
+import logging
from litequeue import SQLQueue
QUEUE_DB = os.environ.get('el_QUEUE_db', 'litequeue.db')
+log = logging.getLogger(__name__)
+
# Initialize queue
q = SQLQueue(QUEUE_DB, maxsize=None)
def dbi(sql,values,**kwargs):
''' insert into queue '''
+ log.debug('function dbi()')
verbose = bool(kwargs['verbose']) if 'verbose' in kwargs else False
+ log.debug('Inserting into sqlite-queue')
q.put(pickle.dumps([sql, values]))
if verbose is True:
+ log.debug('verbose = True')
table = sql.split(' ')[2]
num = 1 if isinstance(values, tuple) else len(values)
- print("Inserted", num, "item(s) into queue for", table)
+ print("Inserted " + str(num) + " item(s) into queue for " + str(table))
return True