summaryrefslogtreecommitdiffstats
path: root/pystatemgr
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2016-08-30 20:12:12 -0400
committerPatrick Williams <patrick@stwcx.xyz>2016-09-06 12:46:19 +0000
commit291ae8302912a71bb28b33cdc39f98bf8eff2b96 (patch)
treea9c002923279f43ffee63bc4a7a652708d999986 /pystatemgr
parent985b2a51ee2e3005330d874c1da46c639f85261c (diff)
downloadtalos-skeleton-291ae8302912a71bb28b33cdc39f98bf8eff2b96.tar.gz
talos-skeleton-291ae8302912a71bb28b33cdc39f98bf8eff2b96.zip
discover_system_state: pep8 fixes
Change-Id: I8ef7c3024c2330acffa7603aee4c7ef295aea1b0 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'pystatemgr')
-rw-r--r--pystatemgr/discover_system_state.py96
1 files changed, 48 insertions, 48 deletions
diff --git a/pystatemgr/discover_system_state.py b/pystatemgr/discover_system_state.py
index 84bc4c0..5596f43 100644
--- a/pystatemgr/discover_system_state.py
+++ b/pystatemgr/discover_system_state.py
@@ -1,76 +1,76 @@
-#!/usr/bin/python
+#!/usr/bin/env python
-import sys
-import gobject
import dbus
-import dbus.service
-import dbus.mainloop.glib
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'
},
- 'chassis' : {
- 'bus_name' : 'org.openbmc.control.Chassis',
- 'object_name' : '/org/openbmc/control/chassis0',
- 'interface_name' : 'org.openbmc.control.Chassis'
+ 'chassis': {
+ 'bus_name': 'org.openbmc.control.Chassis',
+ 'object_name': '/org/openbmc/control/chassis0',
+ 'interface_name': 'org.openbmc.control.Chassis'
},
- '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'
},
}
-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'])
-def getProperty(bus,objs,key,prop):
- obj = bus.get_object(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)
+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'])
+
+
+def getProperty(bus, objs, key, prop):
+ obj = bus.get_object(
+ 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)
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')
+ 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_state = settings_intf.Get("org.openbmc.settings.Host","system_state")
- power_policy = settings_intf.Get("org.openbmc.settings.Host","power_policy")
+ settings_intf = getInterface(bus, dbus_objects, 'settings')
+ system_state = settings_intf.Get(
+ "org.openbmc.settings.Host", "system_state")
+ power_policy = settings_intf.Get(
+ "org.openbmc.settings.Host", "power_policy")
print "Last System State: "+system_state+"; Power Policy: "+power_policy
- chassis_intf = getInterface(bus,dbus_objects,'chassis')
+ chassis_intf = getInterface(bus, dbus_objects, 'chassis')
if (power_policy == "ALWAYS_POWER_ON" or
- (power_policy == "RESTORE_LAST_STATE" and
- system_state =="HOST_POWERED_ON")):
+ (power_policy == "RESTORE_LAST_STATE" and
+ system_state == "HOST_POWERED_ON")):
chassis_intf.powerOn()
-
-
OpenPOWER on IntegriCloud