|
17 | 17 | import argparse
|
18 | 18 | import atexit
|
19 | 19 | import json
|
| 20 | +import math |
20 | 21 | import os
|
21 | 22 | import platform
|
22 | 23 | import re
|
@@ -769,12 +770,11 @@ def get_cpu_info():
|
769 | 770 | logical_cores = int(check_output(['sysctl', '-n', 'machdep.cpu.thread_count']).strip())
|
770 | 771 | frequency = int(check_output(['sysctl', '-n', 'hw.cpufrequency']).strip()) // 1000000
|
771 | 772 | elif LINUX:
|
772 |
| - all_info = check_output(['cat', '/proc/cpuinfo']).strip() |
773 |
| - for line in all_info.split("\n"): |
| 773 | + for line in open('/proc/cpuinfo').readlines(): |
774 | 774 | if 'model name' in line:
|
775 | 775 | cpu_name = re.sub('.*model name.*:', '', line, count=1).strip()
|
776 | 776 | lscpu = check_output(['lscpu'])
|
777 |
| - frequency = int(float(re.search('CPU MHz: (.*)', lscpu).group(1).strip()) + 0.5) |
| 777 | + frequency = math.ceil(float(re.search('CPU (max )?MHz: (.*)', lscpu).group(2).strip())) |
778 | 778 | sockets = int(re.search(r'Socket\(s\): (.*)', lscpu).group(1).strip())
|
779 | 779 | physical_cores = sockets * int(re.search(r'Core\(s\) per socket: (.*)', lscpu).group(1).strip())
|
780 | 780 | logical_cores = physical_cores * int(re.search(r'Thread\(s\) per core: (.*)', lscpu).group(1).strip())
|
@@ -1391,7 +1391,8 @@ def get_system_info(format_json):
|
1391 | 1391 | else:
|
1392 | 1392 | cpu = get_cpu_info()
|
1393 | 1393 | gpus = get_gpu_info()
|
1394 |
| - info = 'Computer name: ' + socket.gethostname() + '\n' # http://stackoverflow.com/questions/799767/getting-name-of-windows-computer-running-python-script |
| 1394 | + # http://stackoverflow.com/questions/799767/getting-name-of-windows-computer-running-python-script |
| 1395 | + info = 'Computer name: ' + socket.gethostname() + '\n' |
1395 | 1396 | info += 'Model: ' + get_computer_model() + '\n'
|
1396 | 1397 | info += 'OS: ' + get_os_version() + ' with ' + str(get_system_memory() // 1024 // 1024) + ' MB of System RAM\n'
|
1397 | 1398 | info += 'CPU: ' + cpu['model'] + ', ' + str(cpu['frequency']) + ' MHz, ' + str(cpu['physicalCores']) + ' physical cores, ' + str(cpu['logicalCores']) + ' logical cores\n'
|
|
0 commit comments