2
0
mirror of https://opendev.org/x/pyghmi synced 2025-03-20 02:17:46 +00:00

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
This commit is contained in:
Jarrod Johnson 2019-10-15 09:35:04 -04:00
parent c4a61ca3c8
commit 3b0fe82dfa

View File

@ -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):