25 lines
1.4 KiB
Python
25 lines
1.4 KiB
Python
"""Grille de toutes les stations sur une fenêtre, par pas de P min (défaut 15) : M = au moins une mesure, s = une synchronisation
|
|||
|
|
(last_sync) sans mesure, . = rien ; puis par heure BusVoltage présent (V) et DB_not_uploaded.
|
||
|
|
Usage : python3 grille.py DEBUT FIN [P] (UTC, AAAA-MM-JJTHH:MM ; lancé depuis la racine)"""
|
||
|
|
import ast, sys, os
|
||
|
|
from datetime import timedelta
|
||
|
|
exec(open(os.path.join(os.path.dirname(__file__), 'trous.py')).read().split('tous = {}')[0])
|
||
|
|
a, b = UTC(sys.argv[1]), UTC(sys.argv[2]); P = int(sys.argv[3]) if len(sys.argv) > 3 else 15
|
||
|
|
cases = []; t = a
|
||
|
|
while t < b: cases.append(t); t += timedelta(minutes=P)
|
||
|
|
print(' ' * 12 + ''.join(f'{c:%H}'[1] if c.minute == 0 else ' ' for c in cases))
|
||
|
|
for st in LOTS:
|
||
|
|
ts = [x for x in instants(st, a, b) if a <= x < b]
|
||
|
|
ls = metrique(st, 'last_sync', a, b); syncs = set()
|
||
|
|
for v in ls.values():
|
||
|
|
try: syncs |= {UTC(s) for s in ast.literal_eval(v)}
|
||
|
|
except Exception: pass
|
||
|
|
bv, nu = metrique(st, 'BusVoltage', a, b), metrique(st, 'DB_not_uploaded', a, b)
|
||
|
|
lig = ''
|
||
|
|
for c in cases:
|
||
|
|
f = c + timedelta(minutes=P)
|
||
|
|
lig += 'M' if any(c <= x < f for x in ts) else 's' if any(c <= x < f for x in syncs) else '.'
|
||
|
|
print(f'{st:<12}{lig}')
|
||
|
|
hrs = [c for c in cases if c.minute == 0]
|
||
|
|
print(f'{" BV":<12}' + ''.join(('V' if c in bv else '-') + ' ' for c in hrs))
|
||
|
|
if nu: print(f'{" notupl":<12}' + ''.join(f'{str(nu.get(c, "-"))[:3]:<4}' for c in hrs))
|