From 2d565b77bb7b5a4a28eb1d0bf263ee2c3507896d Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Thu, 15 Jul 2021 11:34:47 -0700 Subject: [PATCH] use python3.8 for timestamp generation instead of date + shell script.. This gives more precision, and a better idea when the stamps came in.. --- streaming | 11 ++++++++++- ts-util | 5 ----- 2 files changed, 10 insertions(+), 6 deletions(-) delete mode 100755 ts-util diff --git a/streaming b/streaming index 73f2b00..c4ce8b2 100644 --- a/streaming +++ b/streaming @@ -3,4 +3,13 @@ curl --no-buffer --digest -u installer:$(cat creds.inst.txt) http://$(read a b << EOF $(cat creds.txt) EOF -echo $a)/stream/meter 2>/dev/null | awk '$0 != "\r" { if ($1 == "data:") $1 = ""; print; fflush }' | ts-util > home.power.$(date +%Y%m%d%H%M).log +echo $a)/stream/meter 2>/dev/null | python3.8 -c 'import time; import sys +inp = sys.stdin +inp.reconfigure(line_buffering=True) +sys.stdout.reconfigure(line_buffering=True) +for i in inp: + i = i.strip() + if not i: + continue + i = i.split(maxsplit=1)[1] + print(time.time(), i)' > home.power.$(date +%Y%m%d%H%M).log diff --git a/ts-util b/ts-util deleted file mode 100755 index 3f12f5d..0000000 --- a/ts-util +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -while read l; do - echo $(TZ=UTC date +%Y-%m-%dT%H:%M:%SZ) $l -done