(output)
| 447 | return (processor_brand, hz_brand, scale, vendor_id, stepping, model, family) |
| 448 | |
| 449 | def _parse_dmesg_output(output): |
| 450 | try: |
| 451 | # Get all the dmesg lines that might contain a CPU string |
| 452 | lines = output.split(' CPU0:')[1:] + \ |
| 453 | output.split(' CPU1:')[1:] + \ |
| 454 | output.split(' CPU:')[1:] + \ |
| 455 | output.split('\nCPU0:')[1:] + \ |
| 456 | output.split('\nCPU1:')[1:] + \ |
| 457 | output.split('\nCPU:')[1:] |
| 458 | lines = [l.split('\n')[0].strip() for l in lines] |
| 459 | |
| 460 | # Convert the lines to CPU strings |
| 461 | cpu_strings = [_parse_cpu_string(l) for l in lines] |
| 462 | |
| 463 | # Find the CPU string that has the most fields |
| 464 | best_string = None |
| 465 | highest_count = 0 |
| 466 | for cpu_string in cpu_strings: |
| 467 | count = sum([n is not None for n in cpu_string]) |
| 468 | if count > highest_count: |
| 469 | highest_count = count |
| 470 | best_string = cpu_string |
| 471 | |
| 472 | # If no CPU string was found, return {} |
| 473 | if not best_string: |
| 474 | return {} |
| 475 | |
| 476 | processor_brand, hz_actual, scale, vendor_id, stepping, model, family = best_string |
| 477 | |
| 478 | # Origin |
| 479 | if ' Origin=' in output: |
| 480 | fields = output[output.find(' Origin=') : ].split('\n')[0] |
| 481 | fields = fields.strip().split() |
| 482 | fields = [n.strip().split('=') for n in fields] |
| 483 | fields = [{n[0].strip().lower() : n[1].strip()} for n in fields] |
| 484 | #print('fields: ', fields) |
| 485 | for field in fields: |
| 486 | name = list(field.keys())[0] |
| 487 | value = list(field.values())[0] |
| 488 | #print('name:{0}, value:{1}'.format(name, value)) |
| 489 | if name == 'origin': |
| 490 | vendor_id = value.strip('"') |
| 491 | elif name == 'stepping': |
| 492 | stepping = int(value.lstrip('0x'), 16) |
| 493 | elif name == 'model': |
| 494 | model = int(value.lstrip('0x'), 16) |
| 495 | elif name in ['fam', 'family']: |
| 496 | family = int(value.lstrip('0x'), 16) |
| 497 | #print('FIELDS: ', (vendor_id, stepping, model, family)) |
| 498 | |
| 499 | # Features |
| 500 | flag_lines = [] |
| 501 | for category in [' Features=', ' Features2=', ' AMD Features=', ' AMD Features2=']: |
| 502 | if category in output: |
| 503 | flag_lines.append(output.split(category)[1].split('\n')[0]) |
| 504 | |
| 505 | flags = [] |
| 506 | for line in flag_lines: |
no test coverage detected
searching dependent graphs…