def get_server_storedvar(name): """Fetches a ServerStoredVar() object, or None.""" # lookup by name, not client ID try: row = pls.db.fetchone("SELECT name FROM {table} WHERE name=?".format(table=ServerStoredVar.TABLENAME), name) except Exception as inst: # May fail if e.g. no storedvar table created yet logger.error(str(inst)) return None if row is None or row[0] is None: return None return ServerStoredVar(name)
def get_device_storedvar(device, name, era): """Fetches a DeviceStoredVar() object, or None.""" # lookup by name, not client ID try: row = pls.db.fetchone( """ SELECT _pk FROM {table} WHERE _current AND _device=? AND name=? AND _era=? """.format( table=DeviceStoredVar.TABLENAME ), device, name, era, ) except Exception as inst: # May fail if e.g. no storedvar table created yet logger.error(str(inst)) return None if row is None or row[0] is None: return None return DeviceStoredVar(row[0])
def report_error(self, msg): logger.error("RecipientDefinition: {}".format(msg))