Bugfix: don't use jsonutils.load, use loads() 33/29533/3
authorRoss Brattain <ross.b.brattain@intel.com>
Wed, 1 Mar 2017 06:50:40 +0000 (22:50 -0800)
committerRoss Brattain <ross.b.brattain@intel.com>
Wed, 8 Mar 2017 07:53:24 +0000 (07:53 +0000)
commit7541c9613e62ca0b295f6111c67b0956c2fd7403
treea12de8b9fa6657233355b8cb876ed6e6a93e35e9
parent3410e13b059e0b86ce89a791608ce90753009906
Bugfix: don't use jsonutils.load, use loads()

It looks like jsonutils.load uses a codec reader
to read from the file, but we already are using
Python 3.5 open() which should already do the UTF-8
decode itself.

    return json.load(codecs.getreader(encoding)(fp), **kwargs)C

When we use jsonutils.load() we get a TypeErorr when concating
str and bytes

2017-02-28 16:42:38,431 yardstick.cmd.commands.task task.py:61 ERROR
Traceback (most recent call last):
  File "yardstick/yardstick/cmd/commands/task.py", line 58, in do_start
    self._finish()
  File "yardstick/yardstick/cmd/commands/task.py", line 69, in _finish
    result = read_json_from_file(self.output_file).get('result')
  File "yardstick/yardstick/common/utils.py", line 136, in read_json_from_file
    return jsonutils.load(f)
  File "yardstick_venv3/lib/python3.5/site-packages/oslo_serialization/jsonutils.py", line 241, in load
    return json.load(codecs.getreader(encoding)(fp), **kwargs)
  File "/usr/lib/python3.5/json/__init__.py", line 265, in load
    return loads(fp.read(),
  File "yardstick_venv3/lib/python3.5/codecs.py", line 497, in read
    data = self.bytebuffer + newdata
TypeError: can't concat bytes to str

So switch back to jsonutils.loads() which does nothing if the
bytes are already decoded.

JIRA: YARDSTICK-584

Change-Id: I36acfda3df2b46d16a87f2741a04fe7ee8e8d89b
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
yardstick/common/utils.py