def initialize(self): db._sess = db.openDB() self._db = db.BioMapUser(db._sess)
# the next line replaces the currently-running process with the sudo os.execlpe('sudo', *args) logger.initLogger(settings.LOG_FILENAME) # Init signal handler, because otherwise Ctrl-C does not work signal.signal(signal.SIGINT, signal_handler) # Make the following devices accessable for user os.system("sudo chmod 666 %s" % settings.SERIAL_PORT_DEVICE_BASE) # Give Home Assistant and Mosquitto the time to startup time.sleep(1) # Get MQTT Topics for input pins cur = db.openDB() cur.execute("SELECT * FROM GPIOpins ORDER BY pin ASC") gpioTopicsTabel = cur.fetchall() for pinNr, topic in gpioTopicsTabel: gpioTopics[pinNr] = topic pinStatus[topic] = 0 # Only create, value will be set leater print("pinNr: %d, Topic: %s" % (pinNr, topic)) # First start the MQTT client client = mqtt_client.Client() client.message_callback_add(settings.MQTT_TOPIC_OUT, on_message_output) client.message_callback_add(settings.MQTT_TOPIC_COMMAND, on_message_command) client.message_callback_add(settings.MQTT_TOPIC_CHECK, serviceReport.on_message_check) client.on_connect = on_connect
def initialize(self): db._sess = db.openDB() self._db = db.BioMapSighting(db._sess)
deleteFiles = [] entries = db.selectAll() while len(entries) > 0: for nextEntry in entries: if not nextEntry[1] in files: logger.debug("Marking file {} for removal from database".format(nextEntry[1])) deleteFiles.append(nextEntry[0]) entries = db.fetchNext() db.deleteSet(deleteFiles) acquireLock() db.openDB() try: if args.listFiles: db.listFiles() if args.deleteEntry: db.deleteIndex(args.deleteEntry) if args.directory: processDir() cleanDB() finally: releaseLock() db.closeDB()