mirror of
https://github.com/skaringa/water-counter.git
synced 2024-11-23 18:04:25 +01:00
Avoid error when no data is available
This commit is contained in:
parent
dcd1ac89df
commit
05004cbac0
@ -73,14 +73,15 @@ def detect_pauses(data):
|
|||||||
def main():
|
def main():
|
||||||
#counter = read_fetch_output()
|
#counter = read_fetch_output()
|
||||||
counter = read_rrd()
|
counter = read_rrd()
|
||||||
pauses = detect_pauses(counter)
|
if len(counter) > 0:
|
||||||
if verbose:
|
pauses = detect_pauses(counter)
|
||||||
for p in pauses:
|
if verbose:
|
||||||
print("Pause starting at {0:%Y-%m-%d %H:%M:%S}: {1:.1f} hours"
|
for p in pauses:
|
||||||
.format(datetime.fromtimestamp(p['start']), p['duration']/3600.0))
|
print("Pause starting at {0:%Y-%m-%d %H:%M:%S}: {1:.1f} hours"
|
||||||
if len(pauses) == 0:
|
.format(datetime.fromtimestamp(p['start']), p['duration']/3600.0))
|
||||||
print("Possible leak detected! There is no break of at least {0} hours."
|
if len(pauses) == 0:
|
||||||
.format(min_pause/3600.0))
|
print("Possible leak detected! There is no break of at least {0} hours."
|
||||||
|
.format(min_pause/3600.0))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user