From 48bd18b6d94e5902cd71cd4a914cda7c5e0c988a Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 25 Jun 2018 21:51:50 +0300 Subject: Change: indicate what each action was in timestamps output --- timestamps | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'timestamps') diff --git a/timestamps b/timestamps index 32f1a30..6184e41 100755 --- a/timestamps +++ b/timestamps @@ -15,6 +15,7 @@ # along with this program. If not, see . +import json import re import sys @@ -35,6 +36,19 @@ def parse_ts(ts): return hour * 3600 + minute * 60 + second +def step_summary(step): + if 'action' in step: + return step['action'] + if 'shell' in step: + return 'shell' + if 'python' in step: + return 'python' + if 'debootstrap' in step: + return 'debootstrap' + if 'archive' in step: + return 'archive' + return str(step) + build_starts = re.compile(r'^Build starts at (?P.*)$') build_ends = re.compile(r'^Build ends at (?P.*),') action_starts = re.compile(r'^Action starts at (?P.*):$') @@ -63,19 +77,34 @@ names = { action_starts: 'Action', } -durations = [] +step = '' +read_action = False +action = '' for line in sys.stdin: + if read_action: + action += line + if line.rstrip() == '}': + action_obj = json.loads(action) + step = action_obj.get('step') + read_action = False + action = '' + for pat in patterns: m = pat.match(line) if m is None: continue ts = m.group('ts') + read_action = pat == action_starts if pat in started: started[pat] = parse_ts(ts) else: ended = parse_ts(ts) start_pat = pairs[pat] - print(names[start_pat], ended - started[start_pat]) + print( + names[start_pat], + ended - started[start_pat], + step_summary(step)) + step = '' break -- cgit v1.2.1