Commit 5838bc61 authored by Tom Hartley's avatar Tom Hartley

Started rewriting code in order to make it more modular

parent 9e0c7bb1
#This file takes in inputs from a variety of sensor files, and outputs information to a variety of services
import ConfigParser
import time
import importlib
import inspect
from sys import exit
def get_subclasses(mod,cls):
for name, obj in inspect.getmembers(mod):
if hasattr(obj, "__bases__" and cls in obj.__bases__:
return obj
sensorPlugins = []
if not os.path.isfile('sensors.cfg'):
print "Unable to access config file: sensors.cfg"
sensorConfig = ConfigParser.SafeConfigParser()'sensors.cfg')
sensorNames = sensorConfig.sections()
for i in sensorNames:
filename = sensorConfig.get(i,"filename")
enabled = sensorConfig.getboolean(i,"enabled")
#if enabled, load the plugin
mod = importlib.import_module(filename,"sensors")
except: #add specific exception for missing module
print("Could not import module " + filename")
import sensor
requiredData = ["Metric","I2CPort"]
optionalData = ["Altitude","MLSP",]
class Bmp085(Sensor):
def __init__(data):
def getVal():
return 0
class Sensor():
def __init__(data):
raise NotImplementedError
def getData():
raise NotImplementedError
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment