From 31be12a4be21eabc1d9e9a7d0bf5e8b854427603 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 26 Jun 2016 11:30:50 -0700 Subject: [PATCH] misc/dump-stats.py: tool to show stats.json validity Run like 'watch python misc/dump-stats.py' against a 'wormhole-server start --stats-file=stats.json' --- misc/dump-stats.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 misc/dump-stats.py diff --git a/misc/dump-stats.py b/misc/dump-stats.py new file mode 100755 index 0000000..878a399 --- /dev/null +++ b/misc/dump-stats.py @@ -0,0 +1,19 @@ +from __future__ import print_function +import time, json + +# Run this as 'watch python misc/dump-stats.py' against a 'wormhole-server +# start --stats-file=stats.json' + +with open("stats.json") as f: + data_s = f.read() + +now = time.time() +data = json.loads(data_s) +if now < data["valid_until"]: + valid = "valid" +else: + valid = "EXPIRED" +age = now - data["created"] + +print("age: %d (%s)" % (age, valid)) +print(data_s)