# tb = traceback.format_exc() # logger.log("Exception in waithForThread():\n%s" %tb) # # def stop(self): # # Stop the server and wait for the threads to die. # self.server.shutdown() # self.waitForThread() ####################### # MAIN EXECUTION BODY # ####################### if __name__ == '__main__': # Create the shared logger. logger = sensLog.sensLog(sensConfig['logMode']) logger.log("Sensor service starting.") # Flag the data worker as not started. dataWorkerStarted = False # Create the shared queue. clientQ = Queue.Queue() # Set up empty thread list. threadList = [] # See if we have any data sources listed... if len(sensConfig['endpoints']) < 1: # If not, complain and die.
except Exception as e: # If we explode just fire the exception. raise e else: raise RuntimeError("Unable to run thermalNetwork in %s mode. Valid modes are 'worker' and 'continuous'." %mode) # If we're being independently executed... if __name__ == '__main__': # Do a late import from sensLog import sensLog # Logger logger = sensLog() # Create minder instance thermalNet = thermalNetwork(logger) # Set debuggging. thermalNet.setDebug(True) # Generic device metadata for a DS18B20... ds18b20Meta = { 'sensor': 'DS18B20', 'cap': 'temp', 'accuracy': '0.5', 'unit': 'C', 'min': -55, 'max': 125,
def stop(self): # Stop the server and wait for the threads to die. self.server.shutdown() self.waitForThread() ####################### # MAIN EXECUTION BODY # ####################### if __name__ == '__main__': # COnfiguration file here. snConfig = config.config # Create the logger. logger = sensLog(snConfig['logMode']) # Create instace of the thermal network handler. thermalNet = thermalNetwork(logger) # Set debuggging. thermalNet.setDebug(snConfig['debug']) try: # Register each configured sensor. for sensor in snConfig['sensors']: try: # Register each sensor. thermalNet.registerSensor(sensor, snConfig['sensors'][sensor]['loc'], snConfig['sensors'][sensor]['locDetail'], snConfig['sensors'][sensor]['sensorMeta']) except: