Example #1
0
                for row in result:
                    if row["value"] not in self.tracked_worlds_list:
                        self.tracked_worlds_list.append(row["value"])
                    tibia_servers_dict_temp[int(
                        row["server_id"])] = row["value"]

            self.tracked_worlds.clear()
            self.tracked_worlds.update(tibia_servers_dict_temp)
        finally:
            c.close()


nabbot = None

if __name__ == "__main__":
    init_database()

    print("Loading config...")
    config.parse()

    nabbot = NabBot()

    # List of tracked worlds for NabBot
    nabbot.reload_worlds()
    # List of all Tibia worlds
    nabbot.loop.run_until_complete(populate_worlds())

    if len(tibia_worlds) == 0:
        print(
            "Critical information was not available: NabBot can not start without the World List."
        )
import time
import urllib.request
import pathlib
import json
from utils import database as db_utils
from dotenv import load_dotenv
load_dotenv()

server_ip = os.getenv("BACKEND_LIVE_SRV_IP")
server_port = os.getenv("BACKEND_LIVE_SRV_PORT")
server_url = "http://" + server_ip + ":" + server_port + "/"
counter = 0  # Count to 60min, save when counter at 3600

project_path = pathlib.Path(__file__).parent.absolute().parent
db_path = str(project_path) + "/resources/weather.db"
db = db_utils.init_database(db_path)

temp_data = []
humidity_data = []
pressure_data = []
air_quality_data = []

while True:
	try:
		with urllib.request.urlopen(server_url, timeout=2) as url:
			data = json.loads(url.read().decode())
			cur_temperature = data["temperature"]
			cur_humidity = data["humidity"]
			cur_pressure = data["pressure"]
			cur_air_quality = data["airQuality"]