sensor_mgr: pep8 fixes
Change-Id: I67dbe7831e63ffa7729bead55eae01aa2e9d8371
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/pysensormgr/sensor_manager2.py b/pysensormgr/sensor_manager2.py
index 45c1b92..c1a3204 100644
--- a/pysensormgr/sensor_manager2.py
+++ b/pysensormgr/sensor_manager2.py
@@ -1,7 +1,5 @@
-#!/usr/bin/python -u
+#!/usr/bin/env python
-import sys
-import os
import gobject
import dbus
import dbus.service
@@ -14,53 +12,51 @@
OBJ_PATH = '/org/openbmc/sensors'
-class SensorManager(DbusProperties,DbusObjectManager):
- def __init__(self,bus,name):
- DbusProperties.__init__(self)
- DbusObjectManager.__init__(self)
- dbus.service.Object.__init__(self,bus,name)
+class SensorManager(DbusProperties, DbusObjectManager):
+ def __init__(self, bus, name):
+ DbusProperties.__init__(self)
+ DbusObjectManager.__init__(self)
+ dbus.service.Object.__init__(self, bus, name)
- @dbus.service.method(DBUS_NAME,
- in_signature='ss', out_signature='')
- def register(self,object_name,obj_path):
- if (self.objects.has_key(obj_path) == False):
- print "Register: "+object_name+" : "+obj_path
- sensor = eval('obmc.sensors.'+object_name+'(bus,obj_path)')
- self.add(obj_path,sensor)
+ @dbus.service.method(
+ DBUS_NAME, in_signature='ss', out_signature='')
+ def register(self, object_name, obj_path):
+ if obj_path not in self.objects:
+ print "Register: "+object_name+" : "+obj_path
+ sensor = eval('obmc.sensors.'+object_name+'(bus,obj_path)')
+ self.add(obj_path, sensor)
- @dbus.service.method(DBUS_NAME,
- in_signature='s', out_signature='')
- def delete(self,obj_path):
- if (self.objects.has_key(obj_path) == True):
- print "Delete: "+obj_path
- self.remove(obj_path)
-
- def SensorChange(self,value,path=None):
- if (self.objects.has_key(path)):
- self.objects[path].setValue(value)
- else:
- print "ERROR: Sensor not found: "+path
-
+ @dbus.service.method(
+ DBUS_NAME, in_signature='s', out_signature='')
+ def delete(self, obj_path):
+ if obj_path in self.objects:
+ print "Delete: "+obj_path
+ self.remove(obj_path)
+
+ def SensorChange(self, value, path=None):
+ if path in self.objects:
+ self.objects[path].setValue(value)
+ else:
+ print "ERROR: Sensor not found: "+path
+
if __name__ == '__main__':
- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- bus = get_dbus()
- root_sensor = SensorManager(bus,OBJ_PATH)
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+ bus = get_dbus()
+ root_sensor = SensorManager(bus, OBJ_PATH)
+ ## instantiate non-polling sensors
+ ## these don't need to be in seperate process
+ for (id, the_sensor) in System.MISC_SENSORS.items():
+ sensor_class = the_sensor['class']
+ obj_path = System.ID_LOOKUP['SENSOR'][id]
+ sensor_obj = getattr(obmc.sensors, sensor_class)(bus, obj_path)
+ if 'os_path' in the_sensor:
+ sensor_obj.sysfs_attr = the_sensor['os_path']
+ root_sensor.add(obj_path, sensor_obj)
- ## instantiate non-polling sensors
- ## these don't need to be in seperate process
- for (id, the_sensor) in System.MISC_SENSORS.items():
- sensor_class = the_sensor['class']
- obj_path = System.ID_LOOKUP['SENSOR'][id]
- sensor_obj = getattr(obmc.sensors, sensor_class)(bus, obj_path)
- if 'os_path' in the_sensor:
- sensor_obj.sysfs_attr = the_sensor['os_path']
- root_sensor.add(obj_path, sensor_obj)
+ mainloop = gobject.MainLoop()
- mainloop = gobject.MainLoop()
-
- root_sensor.unmask_signals()
- name = dbus.service.BusName(DBUS_NAME,bus)
- print "Starting sensor manager"
- mainloop.run()
-
+ root_sensor.unmask_signals()
+ name = dbus.service.BusName(DBUS_NAME, bus)
+ print "Starting sensor manager"
+ mainloop.run()