Example #1
0
    async def updateMatchweek(self):
        """
        Task that checks the current JPL matchweek & changes the dict value
        """
        matchweek = getMatchweek()

        if matchweek is None:
            return

        # Change the setting in the config
        config("jpl_day", int(matchweek))
Example #2
0
def dl_connect():
    configuration = config()
    link = configuration['Datalogger']['ip'] + configuration['Datalogger'][
        'key']

    try:
        # When the session is expired, this link returns an error
        # To fix it, BTicino requires us to connect to the home page ('/')
        # and only after that we can connect to the link with the PUB key
        conn = requests.get(link)
    except Exception:
        conn = requests.get(configuration['Datalogger']['ip'])
        conn = requests.get(link)

    key = str(conn.text)

    key = key[5:29]

    i = ConvertiChiave(key)
    d = configuration['Datalogger']['password']
    l = 1
    o = Calcola(d, i)
    W1 = o[0:24]
    W2 = o[24:48]

    link = configuration['Datalogger']['ip'] + configuration['Datalogger'][
        'key_send'] + "?W1=" + W1 + "&W2=" + W2
    conn = requests.get(link)

    return conn
Example #3
0
 async def set(self, ctx, category, value):
     if config.config(category, value):
         await ctx.message.add_reaction("✅")
Example #4
0
import mysql.connector
from mysql.connector import Error
from functions.config import config

config = config()


# Establishes and returns a connection to the database
def connect(date):
    try:
        conn = mysql.connector.connect(host=config['Database']['ip'],
                                       database=config['Database']['db'],
                                       user=config['Database']['user'],
                                       password=config['Database']['password'])
        if conn.is_connected():
            print(f'{date} Connected to MySQL database')
            return conn

    except Error as e:
        print(f"Error while connecting to the database: '{e}'")
        raise Exception