Handle csv output when the command is not based on the device

Fix the error only one csv line can be printed out when output
is not based on device.

Change-Id: Idacc5d98acc223e932fb3d46c888bfa04778b73c


[ROCm/amdsmi commit: 80d650b95a]
このコミットが含まれているのは:
Bill(Shuzhou) Liu committed 2023-07-26 15:28:18 -05:00
1 親 8c2266573f
コミット 1f2d0cefb3
1ファイル変更
+4 -13
+4 -13
ファイルの表示
@@ -112,19 +112,10 @@ def formatCsv(deviceList):
if outputType == 'system': if outputType == 'system':
jsonobj = json.loads(jsondata) jsonobj = json.loads(jsondata)
keylist = header keylist = header
for record in jsonobj: for record in jsonobj['system']:
my_string += str(record) my_string += "\"%s\", \"%s\"\n" % (record, jsonobj['system'][record])
for key in keylist: # add header
if key == 'system': my_string = "name, value\n" + my_string
tempstr = str(jsonobj[record])
tempstr = tempstr[tempstr.find('\'')+1:]
tempstr = tempstr[:tempstr.find('\'')]
# Force output device type to 'system'
my_string += ',%s\nsystem,%s' % (tempstr, jsonobj[record][tempstr])
my_string += '\n'
# Force output device type to 'system'
if my_string.startswith('system'):
my_string = 'device' + my_string[6:]
return my_string return my_string
headerkeys = [] headerkeys = []
# Separate device-specific information from system-level information # Separate device-specific information from system-level information