python: reformat using black
Code cannot currently be submitted to this repo because it fails
in the unit-test phase. Attempt to reformat the code using `black`
to hopefully make pycodestyle happier.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I17aa506471ceade224bcab5b2fa0dc8cd7a88c0a
diff --git a/pyipmitest/ipmi_debug.py b/pyipmitest/ipmi_debug.py
index a8b1001..537bb19 100644
--- a/pyipmitest/ipmi_debug.py
+++ b/pyipmitest/ipmi_debug.py
@@ -11,28 +11,32 @@
import dbus.service
import dbus.mainloop.glib
-DBUS_NAME = 'org.openbmc.HostIpmi'
-OBJ_NAME = '/org/openbmc/HostIpmi/1'
+DBUS_NAME = "org.openbmc.HostIpmi"
+OBJ_NAME = "/org/openbmc/HostIpmi/1"
def header(seq, netfn, lun, cmd):
- return (
- 'seq: 0x%02x\nnetfn: 0x%02x\n\nlun: 0x%02d\ncmd: 0x%02x\n') % (
- seq, netfn, lun, cmd)
+ return ("seq: 0x%02x\nnetfn: 0x%02x\n\nlun: 0x%02d\ncmd: 0x%02x\n") % (
+ seq,
+ netfn,
+ lun,
+ cmd,
+ )
def print_request(seq, netfn, lun, cmd, data):
str = header(seq, netfn, lun, cmd)
- str += 'data: [%s]' % ', '.join(['0x%02x' % x for x in data])
- print str
+ str += "data: [%s]" % ", ".join(["0x%02x" % x for x in data])
+ print(str)
def print_response(seq, netfn, lun, cmd, cc, data):
str = header(seq, netfn, lun, cmd)
- str += 'cc: 0x%02x\ndata: [%s]' % (
- cc, ', '.join(['0x%02x' % x for x in data])
- )
- print str
+ str += "cc: 0x%02x\ndata: [%s]" % (
+ cc,
+ ", ".join(["0x%02x" % x for x in data]),
+ )
+ print(str)
class IpmiDebug(dbus.service.Object):
@@ -41,23 +45,23 @@
@dbus.service.signal(DBUS_NAME, "yyyyay")
def ReceivedMessage(self, seq, netfn, lun, cmd, data):
- print "IPMI packet from host:"
+ print("IPMI packet from host:")
print_request(seq, netfn, lun, cmd, data)
@dbus.service.method(DBUS_NAME, "yyyyyay", "x")
def sendMessage(self, seq, netfn, lun, cmd, ccode, data):
- print "IPMI packet sent to host:"
+ print("IPMI packet sent to host:")
print_response(seq, netfn, lun, cmd, ccode, data)
return 0
@dbus.service.method(DBUS_NAME)
def setAttention(self):
- print "IPMI SMS_ATN set"
+ print("IPMI SMS_ATN set")
class ConsoleReader(object):
def __init__(self, ipmi_obj):
- self.buffer = ''
+ self.buffer = ""
self.seq = 0
self.ipmi_obj = ipmi_obj
flags = fcntl.fcntl(sys.stdin.fileno(), fcntl.F_GETFL)
@@ -69,16 +73,16 @@
chunk = fd.read()
for char in chunk:
self.buffer += char
- if char == '\n':
+ if char == "\n":
self.line(self.buffer)
- self.buffer = ''
+ self.buffer = ""
return True
def line(self, data):
- s = data.split(' ')
+ s = data.split(" ")
if len(s) < 2:
- print "Not enough bytes to form a valid IPMI packet"
+ print("Not enough bytes to form a valid IPMI packet")
return
try:
data = [int(c, 16) for c in s]
@@ -98,12 +102,14 @@
obj.unmask_signals()
name = dbus.service.BusName(DBUS_NAME, bus)
- print ("Enter IPMI packet as hex values. First three bytes will be used"
- "as netfn and cmd.\nlun will be zero.")
+ print(
+ "Enter IPMI packet as hex values. First three bytes will be used"
+ "as netfn and cmd.\nlun will be zero."
+ )
mainloop.run()
-if __name__ == '__main__':
+if __name__ == "__main__":
sys.exit(main())
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4