diff options
Diffstat (limited to 'timestamps')
-rwxr-xr-x | timestamps | 33 |
1 files changed, 31 insertions, 2 deletions
@@ -15,6 +15,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +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<ts>.*)$') build_ends = re.compile(r'^Build ends at (?P<ts>.*),') action_starts = re.compile(r'^Action starts at (?P<ts>.*):$') @@ -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 |