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]
Este cometimento está contido em:
@@ -96,8 +96,33 @@ def formatCsv(deviceList):
|
|||||||
""" Print out the JSON_DATA in CSV format """
|
""" Print out the JSON_DATA in CSV format """
|
||||||
global JSON_DATA
|
global JSON_DATA
|
||||||
jsondata = json.dumps(JSON_DATA)
|
jsondata = json.dumps(JSON_DATA)
|
||||||
|
outstr = jsondata
|
||||||
header = ['device']
|
# 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 = []
|
headerkeys = []
|
||||||
# Separate device-specific information from system-level information
|
# Separate device-specific information from system-level information
|
||||||
for dev in deviceList:
|
for dev in deviceList:
|
||||||
@@ -110,7 +135,10 @@ def formatCsv(deviceList):
|
|||||||
if len(header) <= 1:
|
if len(header) <= 1:
|
||||||
return ''
|
return ''
|
||||||
for dev in deviceList:
|
for dev in deviceList:
|
||||||
outStr += 'card%s,' % dev
|
if str(dev) != 'system':
|
||||||
|
outStr += 'card%s,' % dev
|
||||||
|
else:
|
||||||
|
outStr += 'system,'
|
||||||
for val in headerkeys:
|
for val in headerkeys:
|
||||||
try:
|
try:
|
||||||
if str(dev) != 'system':
|
if str(dev) != 'system':
|
||||||
|
|||||||
Criar uma nova questão referindo esta
Bloquear um utilizador