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/pychassisctl/chassis_control.py b/pychassisctl/chassis_control.py
index fbe0f72..b5528c8 100644
--- a/pychassisctl/chassis_control.py
+++ b/pychassisctl/chassis_control.py
@@ -10,11 +10,11 @@
import dbus.mainloop.glib
from obmc.dbuslib.bindings import get_dbus, DbusProperties, DbusObjectManager
-DBUS_NAME = 'org.openbmc.control.Chassis'
-OBJ_NAME = '/org/openbmc/control/chassis0'
-CONTROL_INTF = 'org.openbmc.Control'
+DBUS_NAME = "org.openbmc.control.Chassis"
+OBJ_NAME = "/org/openbmc/control/chassis0"
+CONTROL_INTF = "org.openbmc.Control"
-MACHINE_ID = '/etc/machine-id'
+MACHINE_ID = "/etc/machine-id"
POWER_OFF = 0
POWER_ON = 1
@@ -27,8 +27,8 @@
uuid = ""
try:
with open(MACHINE_ID) as f:
- data = f.readline().rstrip('\n')
- if (len(data) == 32):
+ data = f.readline().rstrip("\n")
+ if len(data) == 32:
uuid = data
else:
print("ERROR: UUID is not formatted correctly: " + data)
@@ -38,25 +38,23 @@
return uuid
def __init__(self, bus, name):
- super(ChassisControlObject, self).__init__(
- conn=bus,
- object_path=name)
+ super(ChassisControlObject, self).__init__(conn=bus, object_path=name)
# load utilized objects
self.dbus_objects = {
- 'power_control': {
- 'bus_name': 'org.openbmc.control.Power',
- 'object_name': '/org/openbmc/control/power0',
- 'interface_name': 'org.openbmc.control.Power'
+ "power_control": {
+ "bus_name": "org.openbmc.control.Power",
+ "object_name": "/org/openbmc/control/power0",
+ "interface_name": "org.openbmc.control.Power",
},
- 'host_services': {
- 'bus_name': 'org.openbmc.HostServices',
- 'object_name': '/org/openbmc/HostServices',
- 'interface_name': 'org.openbmc.HostServices'
+ "host_services": {
+ "bus_name": "org.openbmc.HostServices",
+ "object_name": "/org/openbmc/HostServices",
+ "interface_name": "org.openbmc.HostServices",
},
- 'systemd': {
- 'bus_name': 'org.freedesktop.systemd1',
- 'object_name': '/org/freedesktop/systemd1',
- 'interface_name': 'org.freedesktop.systemd1.Manager'
+ "systemd": {
+ "bus_name": "org.freedesktop.systemd1",
+ "object_name": "/org/freedesktop/systemd1",
+ "interface_name": "org.freedesktop.systemd1.Manager",
},
}
@@ -64,59 +62,62 @@
self.Set(DBUS_NAME, "uuid", self.getUuid())
self.Set(DBUS_NAME, "reboot", 0)
- bus.add_signal_receiver(self.power_button_signal_handler,
- dbus_interface="org.openbmc.Button",
- signal_name="Released",
- path="/org/openbmc/buttons/power0")
- bus.add_signal_receiver(self.long_power_button_signal_handler,
- dbus_interface="org.openbmc.Button",
- signal_name="PressedLong",
- path="/org/openbmc/buttons/power0")
- bus.add_signal_receiver(self.softreset_button_signal_handler,
- dbus_interface="org.openbmc.Button",
- signal_name="Released",
- path="/org/openbmc/buttons/reset0")
+ bus.add_signal_receiver(
+ self.power_button_signal_handler,
+ dbus_interface="org.openbmc.Button",
+ signal_name="Released",
+ path="/org/openbmc/buttons/power0",
+ )
+ bus.add_signal_receiver(
+ self.long_power_button_signal_handler,
+ dbus_interface="org.openbmc.Button",
+ signal_name="PressedLong",
+ path="/org/openbmc/buttons/power0",
+ )
+ bus.add_signal_receiver(
+ self.softreset_button_signal_handler,
+ dbus_interface="org.openbmc.Button",
+ signal_name="Released",
+ path="/org/openbmc/buttons/reset0",
+ )
- bus.add_signal_receiver(self.host_watchdog_signal_handler,
- dbus_interface="org.openbmc.Watchdog",
- signal_name="WatchdogError")
-
+ bus.add_signal_receiver(
+ self.host_watchdog_signal_handler,
+ dbus_interface="org.openbmc.Watchdog",
+ signal_name="WatchdogError",
+ )
def getInterface(self, name):
o = self.dbus_objects[name]
- obj = bus.get_object(o['bus_name'], o['object_name'], introspect=False)
- return dbus.Interface(obj, o['interface_name'])
+ obj = bus.get_object(o["bus_name"], o["object_name"], introspect=False)
+ return dbus.Interface(obj, o["interface_name"])
- @dbus.service.method(DBUS_NAME,
- in_signature='', out_signature='')
+ @dbus.service.method(DBUS_NAME, in_signature="", out_signature="")
def powerOn(self):
print("Turn on power and boot")
self.Set(DBUS_NAME, "reboot", 0)
- intf = self.getInterface('systemd')
- f = getattr(intf, 'StartUnit')
- f.call_async('obmc-host-start@0.target', 'replace')
+ intf = self.getInterface("systemd")
+ f = getattr(intf, "StartUnit")
+ f.call_async("obmc-host-start@0.target", "replace")
return None
- @dbus.service.method(DBUS_NAME,
- in_signature='', out_signature='')
+ @dbus.service.method(DBUS_NAME, in_signature="", out_signature="")
def powerOff(self):
print("Turn off power")
- intf = self.getInterface('systemd')
- f = getattr(intf, 'StartUnit')
- f.call_async('obmc-chassis-hard-poweroff@0.target', 'replace')
+ intf = self.getInterface("systemd")
+ f = getattr(intf, "StartUnit")
+ f.call_async("obmc-chassis-hard-poweroff@0.target", "replace")
return None
- @dbus.service.method(DBUS_NAME,
- in_signature='', out_signature='')
+ @dbus.service.method(DBUS_NAME, in_signature="", out_signature="")
def softPowerOff(self):
print("Soft off power")
- intf = self.getInterface('systemd')
- f = getattr(intf, 'StartUnit')
- f.call_async('obmc-host-shutdown@0.target', 'replace')
+ intf = self.getInterface("systemd")
+ f = getattr(intf, "StartUnit")
+ f.call_async("obmc-host-shutdown@0.target", "replace")
return None
- @dbus.service.method(DBUS_NAME,
- in_signature='', out_signature='')
+ @dbus.service.method(DBUS_NAME, in_signature="", out_signature="")
def reboot(self):
print("Rebooting")
if self.getPowerState() != POWER_OFF:
@@ -124,8 +125,7 @@
self.powerOff()
return None
- @dbus.service.method(DBUS_NAME,
- in_signature='', out_signature='')
+ @dbus.service.method(DBUS_NAME, in_signature="", out_signature="")
def softReboot(self):
print("Soft Rebooting")
if self.getPowerState() != POWER_OFF:
@@ -133,18 +133,16 @@
self.softPowerOff()
return None
- @dbus.service.method(DBUS_NAME,
- in_signature='', out_signature='')
+ @dbus.service.method(DBUS_NAME, in_signature="", out_signature="")
def quiesce(self):
- intf = self.getInterface('systemd')
- f = getattr(intf, 'StartUnit')
- f.call_async('obmc-host-quiesce@0.target', 'replace')
+ intf = self.getInterface("systemd")
+ f = getattr(intf, "StartUnit")
+ f.call_async("obmc-host-quiesce@0.target", "replace")
return None
- @dbus.service.method(DBUS_NAME,
- in_signature='', out_signature='i')
+ @dbus.service.method(DBUS_NAME, in_signature="", out_signature="i")
def getPowerState(self):
- intf = self.getInterface('power_control')
+ intf = self.getInterface("power_control")
return intf.getPowerState()
# Signal handler
@@ -169,7 +167,7 @@
self.quiesce()
-if __name__ == '__main__':
+if __name__ == "__main__":
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = get_dbus()