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/pystatemgr/discover_system_state.py b/pystatemgr/discover_system_state.py
index 9324eba..8c39e8b 100644
--- a/pystatemgr/discover_system_state.py
+++ b/pystatemgr/discover_system_state.py
@@ -4,103 +4,117 @@
dbus_objects = {
- 'power': {
- 'bus_name': 'org.openbmc.control.Power',
- 'object_name': '/org/openbmc/control/power0',
- 'interface_name': 'org.openbmc.control.Power'
+ "power": {
+ "bus_name": "org.openbmc.control.Power",
+ "object_name": "/org/openbmc/control/power0",
+ "interface_name": "org.openbmc.control.Power",
},
- 'occstatus0': {
- 'bus_name': 'org.openbmc.Sensors',
- 'object_name': '/org/openbmc/sensors/host/cpu0/OccStatus',
- 'interface_name': 'org.openbmc.SensorValue'
+ "occstatus0": {
+ "bus_name": "org.openbmc.Sensors",
+ "object_name": "/org/openbmc/sensors/host/cpu0/OccStatus",
+ "interface_name": "org.openbmc.SensorValue",
},
- 'occstatus1': {
- 'bus_name': 'org.openbmc.Sensors',
- 'object_name': '/org/openbmc/sensors/host/cpu1/OccStatus',
- 'interface_name': 'org.openbmc.SensorValue'
+ "occstatus1": {
+ "bus_name": "org.openbmc.Sensors",
+ "object_name": "/org/openbmc/sensors/host/cpu1/OccStatus",
+ "interface_name": "org.openbmc.SensorValue",
},
- 'bootprogress': {
- 'bus_name': 'org.openbmc.Sensors',
- 'object_name': '/org/openbmc/sensors/host/BootProgress',
- 'interface_name': 'org.openbmc.SensorValue'
+ "bootprogress": {
+ "bus_name": "org.openbmc.Sensors",
+ "object_name": "/org/openbmc/sensors/host/BootProgress",
+ "interface_name": "org.openbmc.SensorValue",
},
- 'host': {
- 'bus_name': 'xyz.openbmc_project.State.Host',
- 'object_name': '/xyz/openbmc_project/state/host0',
- 'interface_name': 'xyz.openbmc_project.State.Host'
+ "host": {
+ "bus_name": "xyz.openbmc_project.State.Host",
+ "object_name": "/xyz/openbmc_project/state/host0",
+ "interface_name": "xyz.openbmc_project.State.Host",
},
- 'settings': {
- 'bus_name': 'org.openbmc.settings.Host',
- 'object_name': '/org/openbmc/settings/host0',
- 'interface_name': 'org.freedesktop.DBus.Properties'
+ "settings": {
+ "bus_name": "org.openbmc.settings.Host",
+ "object_name": "/org/openbmc/settings/host0",
+ "interface_name": "org.freedesktop.DBus.Properties",
},
- 'system': {
- 'bus_name': 'org.openbmc.managers.System',
- 'object_name': '/org/openbmc/managers/System',
- 'interface_name': 'org.freedesktop.DBus.Properties'
+ "system": {
+ "bus_name": "org.openbmc.managers.System",
+ "object_name": "/org/openbmc/managers/System",
+ "interface_name": "org.freedesktop.DBus.Properties",
},
- 'powersupplyredundancy': {
- 'bus_name': 'org.openbmc.Sensors',
- 'object_name': '/org/openbmc/sensors/host/PowerSupplyRedundancy',
- 'interface_name': 'org.openbmc.SensorValue'
+ "powersupplyredundancy": {
+ "bus_name": "org.openbmc.Sensors",
+ "object_name": "/org/openbmc/sensors/host/PowerSupplyRedundancy",
+ "interface_name": "org.openbmc.SensorValue",
},
- 'turboallowed': {
- 'bus_name': 'org.openbmc.Sensors',
- 'object_name': '/org/openbmc/sensors/host/TurboAllowed',
- 'interface_name': 'org.openbmc.SensorValue'
+ "turboallowed": {
+ "bus_name": "org.openbmc.Sensors",
+ "object_name": "/org/openbmc/sensors/host/TurboAllowed",
+ "interface_name": "org.openbmc.SensorValue",
},
- 'powersupplyderating': {
- 'bus_name': 'org.openbmc.Sensors',
- 'object_name': '/org/openbmc/sensors/host/PowerSupplyDerating',
- 'interface_name': 'org.openbmc.SensorValue'
+ "powersupplyderating": {
+ "bus_name": "org.openbmc.Sensors",
+ "object_name": "/org/openbmc/sensors/host/PowerSupplyDerating",
+ "interface_name": "org.openbmc.SensorValue",
},
}
def getInterface(bus, objs, key):
obj = bus.get_object(
- objs[key]['bus_name'], objs[key]['object_name'], introspect=False)
- return dbus.Interface(obj, objs[key]['interface_name'])
+ objs[key]["bus_name"], objs[key]["object_name"], introspect=False
+ )
+ return dbus.Interface(obj, objs[key]["interface_name"])
def getProperty(bus, objs, key, prop):
obj = bus.get_object(
- objs[key]['bus_name'], objs[key]['object_name'], introspect=False)
+ objs[key]["bus_name"], objs[key]["object_name"], introspect=False
+ )
intf = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
- return intf.Get(objs[key]['interface_name'], prop)
+ return intf.Get(objs[key]["interface_name"], prop)
def setProperty(bus, objs, key, prop, prop_value):
- obj = bus.get_object(
- objs[key]['bus_name'], objs[key]['object_name'])
+ obj = bus.get_object(objs[key]["bus_name"], objs[key]["object_name"])
intf = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
- return intf.Set(objs[key]['interface_name'], prop, prop_value)
+ return intf.Set(objs[key]["interface_name"], prop, prop_value)
bus = dbus.SystemBus()
-pgood = getProperty(bus, dbus_objects, 'power', 'pgood')
+pgood = getProperty(bus, dbus_objects, "power", "pgood")
-if (pgood == 1):
- intf = getInterface(bus, dbus_objects, 'bootprogress')
+if pgood == 1:
+ intf = getInterface(bus, dbus_objects, "bootprogress")
intf.setValue("FW Progress, Starting OS")
- intf = getInterface(bus, dbus_objects, 'occstatus0')
+ intf = getInterface(bus, dbus_objects, "occstatus0")
intf.setValue("Enabled")
- intf = getInterface(bus, dbus_objects, 'occstatus1')
+ intf = getInterface(bus, dbus_objects, "occstatus1")
intf.setValue("Enabled")
else:
# Power is off, so check power policy
- settings_intf = getInterface(bus, dbus_objects, 'settings')
- system_intf = getInterface(bus, dbus_objects, 'system')
- system_last_state = system_intf.Get("org.openbmc.managers.System",
- "system_last_state")
- power_policy = settings_intf.Get("org.openbmc.settings.Host",
- "power_policy")
- print "Last System State:"+system_last_state+"Power Policy:"+power_policy
+ settings_intf = getInterface(bus, dbus_objects, "settings")
+ system_intf = getInterface(bus, dbus_objects, "system")
+ system_last_state = system_intf.Get(
+ "org.openbmc.managers.System", "system_last_state"
+ )
+ power_policy = settings_intf.Get(
+ "org.openbmc.settings.Host", "power_policy"
+ )
+ print(
+ "Last System State:"
+ + system_last_state
+ + "Power Policy:"
+ + power_policy
+ )
- if (power_policy == "ALWAYS_POWER_ON" or
- (power_policy == "RESTORE_LAST_STATE" and
- system_last_state == "HOST_POWERED_ON")):
- setProperty(bus, dbus_objects, 'host', 'RequestedHostTransition',
- 'xyz.openbmc_project.State.Host.Transition.On')
+ if power_policy == "ALWAYS_POWER_ON" or (
+ power_policy == "RESTORE_LAST_STATE"
+ and system_last_state == "HOST_POWERED_ON"
+ ):
+ setProperty(
+ bus,
+ dbus_objects,
+ "host",
+ "RequestedHostTransition",
+ "xyz.openbmc_project.State.Host.Transition.On",
+ )
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4