Mercurial > p > roundup > code
diff scripts/dump_dbm_sessions_db.py @ 6638:e1588ae185dc issue2550923_computed_property
merge from default branch. Fix travis.ci so CI builds don't error out
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 21 Apr 2022 16:54:17 -0400 |
| parents | 61481d7bbb07 |
| children | 1188bb423f92 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/dump_dbm_sessions_db.py Thu Apr 21 16:54:17 2022 -0400 @@ -0,0 +1,35 @@ +#! /usr/bin/env python3 +"""Usage: dump_dbm_sessions_db.py [filename] + +Simple script to dump the otks and sessions dbm databases. Dumps +sessions db in current directory if no argument is given. + +Dump format: + + key: <timestamp> data + +where <timestamp> is the human readable __timestamp decoded from the +data object. + +""" + +import dbm, marshal, sys +from datetime import datetime + +try: + file = sys.argv[1] +except IndexError: + file="sessions" + +try: + db = dbm.open(file) +except Exception: + print("Unable to open database: %s"%file) + exit(1) + +k = db.firstkey() +while k is not None: + d = marshal.loads(db[k]) + t = datetime.fromtimestamp(d['__timestamp']) + print("%s: %s %s"%(k, t, d)) + k = db.nextkey(k)
