MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / get_system_info

Function get_system_info

emrun.py:1370–1418  ·  view source on GitHub ↗
(format_json)

Source from the content-addressed store, hash-verified

1368
1369
1370def get_system_info(format_json):
1371 if emrun_options.android:
1372 if format_json:
1373 return json.dumps({'model': get_android_model(),
1374 'os': get_android_os_version(),
1375 'ram': get_system_memory(),
1376 'cpu': get_android_cpu_infoline(),
1377 }, indent=2)
1378 else:
1379 info = 'Model: ' + get_android_model() + '\n'
1380 info += 'OS: ' + get_android_os_version() + ' with ' + str(get_system_memory() // 1024 // 1024) + ' MB of System RAM\n'
1381 info += 'CPU: ' + get_android_cpu_infoline() + '\n'
1382 return info.strip()
1383 else:
1384 try:
1385 with open(os.path.expanduser('~/.emrun.generated.guid'), encoding='utf-8') as fh:
1386 unique_system_id = fh.read().strip()
1387 except Exception:
1388 import uuid
1389 unique_system_id = str(uuid.uuid4())
1390 try:
1391 with open(os.path.expanduser('~/.emrun.generated.guid'), 'w', encoding='utf-8') as f:
1392 f.write(unique_system_id)
1393 except Exception as e:
1394 logv(e)
1395
1396 if format_json:
1397 return json.dumps({'name': socket.gethostname(),
1398 'model': get_computer_model(),
1399 'os': get_os_version(),
1400 'ram': get_system_memory(),
1401 'cpu': get_cpu_info(),
1402 'gpu': get_gpu_info(),
1403 'uuid': unique_system_id}, indent=2)
1404 else:
1405 cpu = get_cpu_info()
1406 gpus = get_gpu_info()
1407 # http://stackoverflow.com/questions/799767/getting-name-of-windows-computer-running-python-script
1408 info = 'Computer name: ' + socket.gethostname() + '\n'
1409 info += 'Model: ' + get_computer_model() + '\n'
1410 info += 'OS: ' + get_os_version() + ' with ' + str(get_system_memory() // 1024 // 1024) + ' MB of System RAM\n'
1411 info += 'CPU: ' + cpu['model'] + ', ' + str(cpu['frequency']) + ' MHz, ' + str(cpu['physicalCores']) + ' physical cores, ' + str(cpu['logicalCores']) + ' logical cores\n'
1412 if len(gpus) == 1:
1413 info += 'GPU: ' + gpus[0]['model'] + ' with ' + str(gpus[0]['ram'] // 1024 // 1024) + " MB of VRAM\n"
1414 elif len(gpus) > 1:
1415 for i in range(len(gpus)):
1416 info += 'GPU' + str(i) + ": " + gpus[i]['model'] + ' with ' + str(gpus[i]['ram'] // 1024 // 1024) + ' MBs of VRAM\n'
1417 info += 'UUID: ' + unique_system_id
1418 return info.strip()
1419
1420
1421# Be resilient to quotes and whitespace

Callers 3

do_POSTMethod · 0.85
runFunction · 0.85
GetNumberOfCPUsFunction · 0.85

Calls 13

get_android_modelFunction · 0.85
get_android_os_versionFunction · 0.85
get_system_memoryFunction · 0.85
get_android_cpu_infolineFunction · 0.85
logvFunction · 0.85
get_computer_modelFunction · 0.85
get_os_versionFunction · 0.85
get_cpu_infoFunction · 0.85
get_gpu_infoFunction · 0.85
openFunction · 0.50
rangeFunction · 0.50
readMethod · 0.45

Tested by

no test coverage detected