Skip to content

Instantly share code, notes, and snippets.

@gmlp
Created October 25, 2017 16:16
Show Gist options
  • Save gmlp/91559446359c711eddfffbd605c65b1c to your computer and use it in GitHub Desktop.
Save gmlp/91559446359c711eddfffbd605c65b1c to your computer and use it in GitHub Desktop.
asciinema_report.py
import os
import json
current_path = os.path.dirname(os.path.abspath(__file__))
user_times = {}
user_stdout = {}
for root, subdirs, files in os.walk(current_path):
for file in files:
data = {}
try:
with open(os.path.join(root, file)) as data_file:
data = json.load(data_file)
except Exception:
pass
if data:
user = os.path.basename(root)
if user not in user_times:
user_times[user] = []
if user not in user_stdout:
user_stdout[user] = []
user_times[user].append(data['duration'])
stdout = [l[1] for l in data['stdout']]
user_stdout[user].append(''.join(stdout))
#print user_times
for user, times in user_times.items():
print("===========================================================================================")
for stdout in user_stdout[user]:
print(stdout)
print("Total working time: %.2f minutes" % (sum(times)/60))
print("===========================================================================================")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment