(format_json)
| 1368 | |
| 1369 | |
| 1370 | def 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 |
no test coverage detected