| 19 | ] |
| 20 | |
| 21 | def parse_log(logname, mcu): |
| 22 | if mcu is None: |
| 23 | mcu = "mcu" |
| 24 | mcu_prefix = mcu + ":" |
| 25 | apply_prefix = { p: 1 for p in APPLY_PREFIX } |
| 26 | f = open(logname, 'r') |
| 27 | out = [] |
| 28 | for line in f: |
| 29 | parts = line.split() |
| 30 | if not parts or parts[0] not in ('Stats', 'INFO:root:Stats'): |
| 31 | #if parts and parts[0] == 'INFO:root:shutdown:': |
| 32 | # break |
| 33 | continue |
| 34 | prefix = "" |
| 35 | keyparts = {} |
| 36 | for p in parts[2:]: |
| 37 | if '=' not in p: |
| 38 | prefix = p |
| 39 | if prefix == mcu_prefix: |
| 40 | prefix = '' |
| 41 | continue |
| 42 | name, val = p.split('=', 1) |
| 43 | if name in apply_prefix: |
| 44 | name = prefix + name |
| 45 | keyparts[name] = val |
| 46 | if 'print_time' not in keyparts: |
| 47 | continue |
| 48 | keyparts['#sampletime'] = float(parts[1][:-1]) |
| 49 | out.append(keyparts) |
| 50 | f.close() |
| 51 | return out |
| 52 | |
| 53 | def setup_matplotlib(output_to_file): |
| 54 | global matplotlib |