mirror of
https://opendev.org/x/pyghmi
synced 2026-05-16 19:34:21 +00:00
Fix KCS on python 2
In python2, cannot directly copy a memoryview to a ctypes string. Catch and try with a copy of the memoryview data for python2. Change-Id: I6dc0183921e4e888aca131fe7968d820b25dc5d5
This commit is contained in:
@@ -121,9 +121,12 @@ class Session(object):
|
||||
self.req.addr = ctypes.pointer(self.addr)
|
||||
self.req.msg.netfn = netfn
|
||||
self.req.msg.cmd = command
|
||||
data = memoryview(bytearray(data))
|
||||
if data:
|
||||
self.databuffer[:len(data)] = data[:len(data)]
|
||||
data = memoryview(bytearray(data))
|
||||
try:
|
||||
self.databuffer[:len(data)] = data[:len(data)]
|
||||
except ValueError:
|
||||
self.databuffer[:len(data)] = data[:len(data)].tobytes()
|
||||
self.req.msg.data_len = len(data)
|
||||
fcntl.ioctl(self.ipmidev, IPMICTL_SEND_COMMAND, self.req)
|
||||
self.await_reply()
|
||||
|
||||
Reference in New Issue
Block a user