Wrap GPU names into multiple lines

This commit is contained in:
2018-08-10 10:43:29 +02:00
parent 1defd9395a
commit a2d7fd1b37

View File

@@ -351,13 +351,19 @@ def correct_device_name(name):
return "AMD " + name;
return name
def construct_gpu_string(system_info):
def get_gpu_names(system_info):
gpu_names = []
for device in system_info["devices"]:
if device["type"] == "CPU":
continue
gpu_names.append(correct_device_name(device["name"]))
return ", " . join(gpu_names)
return gpu_names
def indent_gpu_names(gpu_names):
indented_names = []
for name in gpu_names:
indented_names.append("- " + name)
return indented_names
def construct_platform_string(system_info):
"""
@@ -368,9 +374,13 @@ def construct_platform_string(system_info):
system_info["bitness"])
result += "\nCPU: {}" . format(
string_strip_trademark(system_info["cpu_brand"]))
gpus = construct_gpu_string(system_info)
if gpus:
result += "\nGPU(s): {}" . format(gpus)
gpu_names = get_gpu_names(system_info)
num_gpus = len(gpu_names)
if num_gpus:
if num_gpus == 1:
result += "\nGPU: {}" . format(gpu_names[0])
else:
result += "\nGPUs:\n{}" . format("\n" . join(indent_gpu_names(gpu_names)))
return result
def convert_result_to_json_dict(ctx, results):