From 3b0fe82dfaf2d7c9816befc92e29196cfd67e42f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 15 Oct 2019 09:35:04 -0400 Subject: [PATCH] Fix Python3 incompatibility in DCMI DCMI uses ord on a buffer/memoryview. In python2 this makes sense but in python3 it does not work. Switch to use of bytearray which acts same under both. Change-Id: I83ad3ec087db820a44e09edf0376b6237af9ca87 --- pyghmi/ipmi/command.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index bd38e7ae..eec419be 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -1276,10 +1276,10 @@ class Command(object): def _chunkwise_dcmi_fetch(self, command): szdata = self.xraw_command( netfn=0x2c, command=command, data=(0xdc, 0, 0)) - totalsize = ord(szdata['data'][1]) + totalsize = bytearray(szdata['data'])[1] chksize = 0xf offset = 0 - retstr = '' + retstr = b'' while offset < totalsize: if (offset + chksize) > totalsize: chksize = totalsize - offset @@ -1287,6 +1287,8 @@ class Command(object): netfn=0x2c, command=command, data=(0xdc, offset, chksize)) retstr += chk['data'][2:] offset += chksize + if not isinstance(retstr, str): + retstr = retstr.decode('utf-8') return retstr def _chunkwise_dcmi_set(self, command, data):