(cpu_string)
| 401 | return input |
| 402 | |
| 403 | def _parse_cpu_string(cpu_string): |
| 404 | # Get location of fields at end of string |
| 405 | fields_index = cpu_string.find('(', cpu_string.find('@')) |
| 406 | #print(fields_index) |
| 407 | |
| 408 | # Processor Brand |
| 409 | processor_brand = cpu_string |
| 410 | if fields_index != -1: |
| 411 | processor_brand = cpu_string[0 : fields_index].strip() |
| 412 | #print('processor_brand: ', processor_brand) |
| 413 | |
| 414 | fields = None |
| 415 | if fields_index != -1: |
| 416 | fields = cpu_string[fields_index : ] |
| 417 | #print('fields: ', fields) |
| 418 | |
| 419 | # Hz |
| 420 | scale, hz_brand = _get_hz_string_from_brand(processor_brand) |
| 421 | |
| 422 | # Various fields |
| 423 | vendor_id, stepping, model, family = (None, None, None, None) |
| 424 | if fields: |
| 425 | try: |
| 426 | fields = fields.rsplit('(', 1)[1].split(')')[0].split(',') |
| 427 | fields = [f.strip().lower() for f in fields] |
| 428 | fields = [f.split(':') for f in fields] |
| 429 | fields = [{f[0].strip() : f[1].strip()} for f in fields] |
| 430 | #print('fields: ', fields) |
| 431 | for field in fields: |
| 432 | name = list(field.keys())[0] |
| 433 | value = list(field.values())[0] |
| 434 | #print('name:{0}, value:{1}'.format(name, value)) |
| 435 | if name == 'origin': |
| 436 | vendor_id = value.strip('"') |
| 437 | elif name == 'stepping': |
| 438 | stepping = int(value.lstrip('0x'), 16) |
| 439 | elif name == 'model': |
| 440 | model = int(value.lstrip('0x'), 16) |
| 441 | elif name in ['fam', 'family']: |
| 442 | family = int(value.lstrip('0x'), 16) |
| 443 | except: |
| 444 | #raise |
| 445 | pass |
| 446 | |
| 447 | return (processor_brand, hz_brand, scale, vendor_id, stepping, model, family) |
| 448 | |
| 449 | def _parse_dmesg_output(output): |
| 450 | try: |
no test coverage detected
searching dependent graphs…