[dpdk-dev] tools: fix json output of pmdinfo

Message ID 1472217332-26077-1-git-send-email-olivier.matz@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Commit Message

Olivier Matz Aug. 26, 2016, 1:15 p.m. UTC
  Using dpdk-pmdinfo with the '-r' flag does not produce a json output as
documented. Instead, the python representation of the json object is
shown, which is nearly the same, but cannot be properly parsed by a json
parser.

python repr (before):
  {u'pci_ids': [[5549, 1968, 65535, 65535]], u'name': u'vmxnet3'}
json (after):
  {"pci_ids": [[5549, 1968, 65535, 65535]], "name": "vmxnet3"}

Fixes: c67c9a5c646a ("tools: query binaries for HW and other support information")

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 tools/dpdk-pmdinfo.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon Oct. 4, 2016, 9:52 a.m. UTC | #1
2016-08-26 15:15, Olivier Matz:
> Using dpdk-pmdinfo with the '-r' flag does not produce a json output as
> documented. Instead, the python representation of the json object is
> shown, which is nearly the same, but cannot be properly parsed by a json
> parser.
> 
> python repr (before):
>   {u'pci_ids': [[5549, 1968, 65535, 65535]], u'name': u'vmxnet3'}
> json (after):
>   {"pci_ids": [[5549, 1968, 65535, 65535]], "name": "vmxnet3"}
> 
> Fixes: c67c9a5c646a ("tools: query binaries for HW and other support information")
> 
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks
  

Patch

diff --git a/tools/dpdk-pmdinfo.py b/tools/dpdk-pmdinfo.py
index dcc8db8..3db9819 100755
--- a/tools/dpdk-pmdinfo.py
+++ b/tools/dpdk-pmdinfo.py
@@ -319,7 +319,7 @@  class ReadElf(object):
         pmdinfo = json.loads(mystring)
 
         if raw_output:
-            print(pmdinfo)
+            print(json.dumps(pmdinfo))
             return
 
         print("PMD NAME: " + pmdinfo["name"])