ROCm SMI CLI: Fix formatCsv Bug
Fixes a bug in the 'formatCsv' function which mishandles json
data conversion for 'system' data types.
Signed-off-by: Ori Messinger <Ori.Messinger@amd.com>
Change-Id: I705060409bf5ae75b994ffda270843065ca12321
[ROCm/amdsmi commit: e800cbf161]
Этот коммит содержится в:
@@ -96,8 +96,33 @@ def formatCsv(deviceList):
|
||||
""" Print out the JSON_DATA in CSV format """
|
||||
global JSON_DATA
|
||||
jsondata = json.dumps(JSON_DATA)
|
||||
|
||||
header = ['device']
|
||||
outstr = jsondata
|
||||
# Check if the first json data element is 'system' or 'device'
|
||||
outputType = outstr[outstr.find('\"')+1:]
|
||||
outputType = outputType[:outputType.find('\"')]
|
||||
header = []
|
||||
my_string = ''
|
||||
if outputType != 'system':
|
||||
header.append('device')
|
||||
else:
|
||||
header.append('system')
|
||||
if outputType == 'system':
|
||||
jsonobj = json.loads(jsondata)
|
||||
keylist = header
|
||||
for record in jsonobj:
|
||||
my_string += str(record)
|
||||
for key in keylist:
|
||||
if key == 'system':
|
||||
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
|
||||
headerkeys = []
|
||||
# Separate device-specific information from system-level information
|
||||
for dev in deviceList:
|
||||
@@ -110,7 +135,10 @@ def formatCsv(deviceList):
|
||||
if len(header) <= 1:
|
||||
return ''
|
||||
for dev in deviceList:
|
||||
outStr += 'card%s,' % dev
|
||||
if str(dev) != 'system':
|
||||
outStr += 'card%s,' % dev
|
||||
else:
|
||||
outStr += 'system,'
|
||||
for val in headerkeys:
|
||||
try:
|
||||
if str(dev) != 'system':
|
||||
|
||||
Ссылка в новой задаче
Block a user