def init(self): # Load all plugins from . import plugins self._log.debug("Plugins: Init plugin records") # script queue self._scriptqueue = queues.Queue(maxsize=100) # rules queue self._rulequeue = queues.Queue(maxsize=100) # script queue self._valuequeue = queues.Queue(maxsize=100) # delete plugin record if plugin NOT present in frozen firmware! tplugins = db.pluginTable.public() cnt = 0 for plugin in tplugins: # check if present in table if (not [ modplugin for modplugin in plugins.plugins if plugin['name'] + ";{}".format(plugin['pincnt']) in plugins.plugins.values() ]) and tplugins: if db.pluginTable.delete(plugin['timestamp']): self._log.debug("Plugins: Record delete succeeded: " + db.pluginTable.fname(plugin['timestamp'])) else: self._log.error("Plugins: Record delete failed: " + db.pluginTable.fname(plugin['timestamp'])) elif not tplugins: self._log.warning("Plugins: No plugin records found!") cnt = 0 else: self._log.debug("Plugins: Plugin record found: {}".format( plugin['name'])) if plugin['id'] > cnt: cnt = plugin['id'] cnt += 1 # get all frozen Plugins from __init__.py for modname, combi in plugins.plugins.items(): # split name, pincnt name, pincnt = combi.split(';') template = modname + ".html" # check if not present in table if not tplugins or (not [ plugin for plugin in tplugins if name in plugin['name'] ]): #new Plugins found: create new plugin table record self._log.debug("Plugins: Create missing plugin record: " + modname) try: cid = db.pluginTable.create(id=cnt, name=name, template=template, module=modname, pincnt=int(pincnt)) except OSError: self._log.error( "Plugins: Exception creating plugin record:" + modname) cnt += 1
def init(self): # Load all plugins import sys from . import plugins # script queue self._scriptqueue = queues.Queue(maxsize=100) # delete plugins records self._log.debug("Plugins: init plugin records") tplugins = db.pluginTable.public() for tplugin in tplugins: try: os.remove(db.pluginTable.fname(tplugin['timestamp'])) except KeyError: self._log.debug("Plugins: Record delete failed!") cnt = 1 # get all frozen plugins for k, v in plugins.plugins.items(): # load plugin module #print(k) #print(v) modname = k self._log.debug("Plugins: Register frozen plugin " + modname) self._mod[modname] = __import__("upyeasy.plugins." + modname, globals(), locals(), v) plugin = self._mod[modname] self._log.debug("Plugins: Create frozen plugin Record: " + modname) #create table record try: cid = db.pluginTable.create(id=cnt, name=plugin.name, dtype=plugin.dtype, stype=plugin.stype, valuecnt=plugin.valuecnt, senddata=plugin.senddata, formula=plugin.formula, sync=plugin.sync, timer=plugin.timer, pullup=plugin.pullup, inverse=plugin.inverse, port=plugin.port, template=plugin.template, pincnt=plugin.pincnt) except OSError: self._log.debug( "Plugins: Exception creating frozen plugin record:" + modname) cnt += 1 # unload plugin to save memory self._mod[plugin.name] = modname del plugin del self._mod[modname] del sys.modules["upyeasy.plugins." + modname]
def init(self, protocol): self._log.debug("Protocol " + name + ": Init") self._client_id = protocol['client_id'] self._server = protocol['hostname'] self._port = protocol['port'] self._user = protocol['user'] self._password = protocol['password'] self._queue = queues.Queue(maxsize=100) return self._queue
def init(self, protocol): self._log.debug("Protocol " + name + ": Init") self._client_id = protocol['client_id'] self._server = protocol['hostname'] self._port = protocol['port'] self._user = protocol['user'] self._password = protocol['password'] self._queue_out = protocol['publish'] self._queue_in = protocol['subscribe'] self._mq = MQTTClient(self._client_id, self._server, self._port, self._user, self._password) # Print diagnostic messages when retries/reconnects happens #self._mq.DEBUG = True self._queue = queues.Queue(maxsize=100) return self._queue
def __init__(self): self.uart6 = UART(6, 115200) self.acc = Accel() self.queue = queues.Queue(100)