File: dump-stats.py

package info (click to toggle)
magic-wormhole 0.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,716 kB
  • sloc: python: 17,148; javascript: 840; makefile: 30; sh: 23
file content (18 lines) | stat: -rwxr-xr-x 383 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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)