Exemplo n.º 1
0
def get_web():
    """
    Get the refresh time from the DB.
    return : int from DB
    """
    web_only = False
    web_app = False
    logging.info("start get_Web")
    iRv = config_functions.check_if_config_entry_exists("""
            SELECT COUNT(*) FROM CFG_WEB
            """)
    if iRv > 0:
        web_only_read = sqlite3db.TExecSqlReadMany(DBNAME, """
                                SELECT web_only FROM CFG_WEB
                                """)
        web_app_read = sqlite3db.TExecSqlReadMany(DBNAME, """
                                SELECT web_app FROM CFG_WEB
                                """)
        if web_only_read[0][0] == 1:
            web_only = True
        if web_app_read[0][0] == 1:
            web_app = True

    web = web_only, web_app
    return web
Exemplo n.º 2
0
    def run(self):
        """
        Cycle function to update the Overlay every minute
        """
        global start_threading
        while 1:
            refresh_rate = config_functions.get_refresh()
            sleep(refresh_rate)
            try:
                name = sqlite3db.TExecSqlReadMany(
                    DBNAME, """
                                    SELECT name FROM CFG_FACEIT_NAME
                                    """)
                if name:
                    if start_threading == 1:
                        refreshSymbol = config_functions.get_refresh_sign()
                        logging.info("Get stats and refresh them")
                        winLoss = config_functions.get_win_loss()
                        if winLoss[0][0] == "1":
                            mode = 0
                        else:
                            mode = 1
                        if refreshSymbol in "True":
                            core.configure_item("##reload_same_line",
                                                show=True)
                            core.configure_item("##reload_image", show=True)
                        self.iElo, self.acEloToday, self.iRank, \
                        self.acResult, self.acScore, self.acKd, \
                        self.acMap, self.iStreak, self.iMatches, \
                        self.iMatchesWon, self.acEloDiff, self.iKills, \
                        self.iDeath, self.iWin, self.iLoss = faceit_api.get_faceit_data_from_api(mode)
                        core.set_value("elotoday##", f"{self.acEloToday}")
                        core.set_value("streak##", f"{self.iStreak}")
                        core.set_value("map##", f"\t{self.acMap}:")
                        core.set_value("result##", f"{self.acResult}")
                        core.set_value("elo##", f"{self.iElo}")
                        core.set_value("rank##", f"{self.iRank}")
                        core.set_value("score##", f"{self.acScore}")
                        core.set_value("matches##", f"{self.iMatches}")
                        core.set_value("matcheswon##", f"{self.iMatchesWon}")
                        core.set_value("elodiffmap##", f"{self.acEloDiff}")
                        core.set_value("kill##", f"{self.iKills}")
                        core.set_value("death##", f"{self.iDeath}")
                        core.set_value("kd##", f"{self.acKd}")
                        core.set_value("Win/LossperDay##",
                                       f"{self.iWin} / {self.iLoss}")
                        core.set_value("Win/LossperWeek##",
                                       f"{self.iWin} / {self.iLoss}")
                        if core.does_item_exist("##reload_same_line"):
                            core.configure_item("##reload_same_line",
                                                show=False)
                            core.configure_item("##reload_image", show=False)

            except:
                self.run()
Exemplo n.º 3
0
def get_faceit_name_from_db():
    """
    Get faceit name from database and return the name
    """
    logging.info("start get_faceit_name_from_db")
    name = sqlite3db.TExecSqlReadMany(
        DBNAME, """
                        SELECT name FROM CFG_FACEIT_NAME
                        """)
    if name:
        name = functions.listToStringWithoutBracketsAndAT(name[0])
    return name
Exemplo n.º 4
0
def get_elo_goal_from_db():
    """
    Get the Elo Goal from database and return the Value
    """
    logging.info("start get_elo_goal_from_db")
    acEloGoal = sqlite3db.TExecSqlReadMany(
        DBNAME, """
                        SELECT TARGET FROM CFG_FACEIT_TARGET_ELO
                        """)
    if acEloGoal:
        acEloGoal = functions.listToStringWithoutBracketsAndAT(acEloGoal[0])
    else:
        return ""
    return acEloGoal
Exemplo n.º 5
0
def get_win_loss():
    """
    Get the refresh time from the DB.
    return : int from DB
    """
    logging.info("start get_win_loss")
    iRv = check_if_config_entry_exists("""
            SELECT COUNT(*) FROM CFG_WIN_LOSS
            """)
    if iRv > 0:
        win_loss = sqlite3db.TExecSqlReadMany(
            DBNAME, """
                                SELECT * FROM CFG_WIN_LOSS
                                """)
        return win_loss
    return False, False
Exemplo n.º 6
0
def get_web_parameters():
    """
    Get the refresh time from the DB.
    return : int from DB
    """
    logging.info("start get_win_loss")
    iRv = config_functions.check_if_config_entry_exists("""
            SELECT COUNT(*) FROM WEB_PARAMETERS
            """)
    if iRv > 0:
        web_parameters = sqlite3db.TExecSqlReadMany(DBNAME, """
                                SELECT * FROM WEB_PARAMETERS
                                """)
        return web_parameters
    else:
        web_parameters = [[64, "", ""]]
    return web_parameters
Exemplo n.º 7
0
def get_refresh():
    """
    Get the refresh time from the DB.
    return : int from DB
    """
    logging.info("start get_refresh")
    iRv = check_if_config_entry_exists("""
            SELECT COUNT(*) FROM CFG_REFRESH
            """)
    if iRv > 0:
        refresh = sqlite3db.TExecSqlReadMany(
            DBNAME, """
                                SELECT * FROM CFG_REFRESH
                                """)
        return functions.ConvertToInt(refresh[0])
    else:
        refresh = 60
    return refresh
Exemplo n.º 8
0
def get_refresh_sign():
    """
    Get the refresh sign from the DB.
    return : int from DB
    """
    logging.info("start get_refresh_sign")
    iRv = check_if_config_entry_exists("""
            SELECT COUNT(*) FROM CFG_REFRESH
            """)
    if iRv > 0:
        refresh = sqlite3db.TExecSqlReadMany(
            DBNAME, """
                                SELECT * FROM CFG_REFRESH_SIGN
                                """)
        return functions.listToStringWithoutBracketsAndAT(refresh)
    else:
        refresh = True
    return refresh
Exemplo n.º 9
0
def add_last_game(acMap, acResult, acScore, acKd, acEloDiff, iKills, iDeath):
    """
    Check all Checkboxes and add the active to the Overlay
    """
    nI = -1
    list_matches = sqlite3db.TExecSqlReadMany(
        DBNAME, """
                                            SELECT * FROM CFG_STATS_MATCH
                                             """)
    core.add_button("\t\t LAST GAME\t\t  ", callback=switch_back_to_menu)
    for i in list_matches[0]:
        nI = nI + 1
        if i == str(1) and nI == 0:
            logging.info("Add Map, result, score")
            core.add_text("map##", default_value=f"\t{acMap}: ")
            core.add_same_line(xoffset=115)
        if i == str(1) and nI == 1:
            core.add_same_line(xoffset=115)
            core.add_text("result##", default_value=f"{acResult}")
        if i == str(1) and nI == 2:
            core.add_same_line(xoffset=130)
            core.add_text("score##", default_value=f"{acScore}")
        if i == str(1) and nI == 3:
            logging.info("Add K/D")
            core.add_text("\tK/D")
            core.add_same_line(xoffset=130)
            core.add_text("kd##", default_value=f"{acKd}")
        if i == str(1) and nI == 4:
            logging.info("Add Elo Diff")
            core.add_text("\tElo Diff")
            core.add_same_line(xoffset=130)
            core.add_text("elodiffmap##", default_value=f"{acEloDiff}")
        if i == str(1) and nI == 5:
            logging.info("Add Kills")
            core.add_text("\tKills:")
            core.add_same_line(xoffset=130)
            core.add_text("kill##", default_value=f"{iKills}")
        if i == str(1) and nI == 6:
            logging.info("Add Deaths")
            core.add_text("\tDeaths:")
            core.add_same_line(xoffset=130)
            core.add_text("death##", default_value=f"{iDeath}")
Exemplo n.º 10
0
def get_scale():
    """
    Get the scale from the DB.
    return : Float from DB
             Default Float 1.00
    """
    logging.info("start get_scale")
    iRv = check_if_config_entry_exists("""
            SELECT COUNT(*) FROM CFG_SCALE
            """)
    if iRv > 0:
        scale = sqlite3db.TExecSqlReadMany(
            DBNAME, """
                                SELECT * FROM CFG_SCALE
                                """)
        scale = functions.ConvertToFloat(scale[0])
        return scale
    else:
        scale = 1.00
    return scale
Exemplo n.º 11
0
def get_color():
    """
    Get the colors from the DB.
    If no color entry exists return the default values
    return : List with saved colors
             List with default colors
    """
    logging.info("start get_color")
    iRv = check_if_config_entry_exists("""
            SELECT COUNT(*) FROM CFG_COLORS
            """)
    if iRv > 0:
        colors = sqlite3db.TExecSqlReadMany(
            DBNAME, """
                                SELECT * FROM CFG_COLORS
                                """)
    else:
        colors = (66, 150, 250, 255, 'Header'), \
                 (255, 255, 255, 255, 'Text'), \
                 (15, 135, 250, 255, 'ButtonActive'), \
                 (15, 15, 15, 255, 'Background'), \
                 (255, 255, 255, 255, 'Outline')
    return colors
Exemplo n.º 12
0
def check_for_layout():
    """
    Check which Checkboxes are active and set the height of the overlay
    """
    logging.info("start check_for_layout")
    iCountFaceit = 0
    iCountMatch = 0
    heigh = 0
    list_faceit = sqlite3db.TExecSqlReadMany(
        DBNAME, """
                                            SELECT * FROM CFG_STATS_FACEIT
                                             """)
    list_matches = sqlite3db.TExecSqlReadMany(
        DBNAME, """
                                            SELECT * FROM CFG_STATS_MATCH
                                             """)
    acEloGoal = sqlite3db.TExecSqlReadCount(
        DBNAME, """
                                            SELECT COUNT(*) FROM CFG_FACEIT_TARGET_ELO"""
    )
    WinLoss = get_win_loss()
    if WinLoss[0][0] == "1":
        iCountFaceit = iCountFaceit + 1
    if WinLoss[0][1] == "1":
        iCountFaceit = iCountFaceit + 1
    for i in list_faceit[0]:
        if i == str(1):
            iCountFaceit = iCountFaceit + 1
    if acEloGoal:
        iCountFaceit = iCountFaceit + 1
    nI = 0
    for i in list_matches[0]:
        if i == str(1):
            if nI > 1:
                iCountMatch = iCountMatch + 1
        nI = nI + 1
    iCount = iCountFaceit + iCountMatch
    print(iCount)
    if iCount == 14:
        heigh = 345
    if iCount == 13:
        heigh = 330
    if iCount == 12:
        heigh = 305
    if iCount == 11:
        heigh = 285
    if iCount == 10:
        heigh = 265
    if iCount == 9:
        heigh = 250
    if iCount == 8:
        heigh = 230
    if iCount == 7:
        heigh = 210
    if iCount == 6:
        heigh = 195
    if iCount == 5:
        heigh = 170
    if iCount == 4:
        heigh = 155
    if iCount == 3:
        heigh = 150
    if iCount == 2:
        heigh = 130
    if iCount == 1:
        heigh = 120
    return heigh, iCountMatch, iCountFaceit
Exemplo n.º 13
0
def startup():
    """
    Get all data from the Database. If no Database entry exists, set everything on default.
    """
    logging.info("Get startup values")
    acEloGoal = config_functions.get_elo_goal_from_db()
    iRv = config_functions.check_if_dbfile_exists()
    FACEIT_List = []
    MATCH_List = []
    nameFACEIT = ""

    if iRv > 0:
        iRv = config_functions.check_if_config_entry_exists("""
            SELECT COUNT(*) FROM CFG_REFRESH
            """)
        if iRv <= 0:
            sqlite3db.TExecSql(
                DBNAME, """
                                     INSERT INTO CFG_REFRESH
                                     VALUES (?)
                                     """, 60)
        iRv = config_functions.check_if_config_entry_exists("""
            SELECT COUNT(*) FROM CFG_REFRESH_SIGN
            """)
        if iRv <= 0:
            sqlite3db.TExecSql(
                DBNAME, """
                               INSERT INTO CFG_REFRESH_SIGN
                               VALUES (?)
                               """, "True")
        iRv = config_functions.check_if_config_entry_exists("""
            SELECT COUNT(*) FROM CFG_WEB
            """)
        if iRv <= 0:
            ins = 'False', 'False'
            sqlite3db.TExecSql(
                DBNAME, """
                               INSERT INTO CFG_WEB
                               VALUES (?,?)
                               """, ins)
        iRv = config_functions.check_if_config_entry_exists("""
            SELECT COUNT(*) FROM CFG_WIN_LOSS
            """)
        if iRv <= 0:
            Initial_Load = (False, False)
            sqlite3db.TExecSql(
                DBNAME, """
                                     INSERT INTO CFG_WIN_LOSS
                                     VALUES (?, ?)
                                     """, Initial_Load)
        iRv = config_functions.check_if_config_entry_exists("""
            SELECT COUNT(*) FROM CFG_STATS_FACEIT
            """)
        if iRv > 0:
            list_faceit = sqlite3db.TExecSqlReadMany(
                DBNAME, """
                                                    SELECT * FROM CFG_STATS_FACEIT
                                                     """)
            list_matches = sqlite3db.TExecSqlReadMany(
                DBNAME, """
                                                    SELECT * FROM CFG_STATS_MATCH
                                                     """)
            nameFACEIT = config_functions.get_faceit_name_from_db()
            for i in list_faceit[0]:
                if i == str(0):
                    FACEIT_List.append(False)
                else:
                    FACEIT_List.append(True)
            for i in list_matches[0]:
                if i == str(0):
                    MATCH_List.append(False)
                else:
                    MATCH_List.append(True)
            return FACEIT_List, MATCH_List, nameFACEIT, acEloGoal
        else:
            for x in range(0, 6):
                FACEIT_List.append(True)
            for x in range(0, 7):
                MATCH_List.append(True)
            return FACEIT_List, MATCH_List, nameFACEIT, acEloGoal
    else:
        for x in range(0, 6):
            FACEIT_List.append(True)
        for x in range(0, 7):
            MATCH_List.append(True)
        return FACEIT_List, MATCH_List, nameFACEIT, acEloGoal
Exemplo n.º 14
0
def add_faceit(iElo, iRank, acEloToday, iStreak, iMatches, iMatchesWon, iWin,
               iLoss):
    """
    Check all Checkboxes and add the active to the Overlay
    """
    nI = -1
    skipacEloGoal = 0

    list_faceit = sqlite3db.TExecSqlReadMany(
        DBNAME, """
                                            SELECT * FROM CFG_STATS_FACEIT
                                             """)
    acEloGoal = config_functions.get_elo_goal_from_db()
    winLoss = config_functions.get_win_loss()
    logging.info("Building Faceit stats")
    core.add_button("\t\tFACEIT STATS\t\t", callback=switch_back_to_menu)
    core.add_same_line(name="##reload_same_line", show=False)
    core.add_image("##reload_image",
                   value="resources/ref.png",
                   width=16,
                   height=16,
                   show=False)
    for i in list_faceit[0]:
        nI = nI + 1
        if i == str(1) and nI == 0:
            logging.info("Add Current Elo")
            core.add_text("\tCurrent Elo")
            core.add_same_line(xoffset=130)
            core.add_text("elo##", default_value=f"{iElo}")
        if acEloGoal and skipacEloGoal == 0:
            core.add_text("\tElo Goal")
            core.add_same_line(xoffset=130)
            core.add_text("eloGoal##", default_value=f"{acEloGoal}")
            skipacEloGoal = 1
        if i == str(1) and nI == 1:
            logging.info("Add Rank")
            core.add_text("\tRank")
            core.add_same_line(xoffset=130)
            core.add_text("rank##", default_value=f"{iRank}")
        if i == str(1) and nI == 2:
            logging.info("Add Elo Today")
            core.add_text("\tElo Today")
            core.add_same_line(xoffset=130)
            core.add_text("elotoday##", default_value=f"{acEloToday}")
        if i == str(1) and nI == 3:
            logging.info("Add Win Streak")
            core.add_text("\tWin Streak")
            core.add_same_line(xoffset=130)
            core.add_text("streak##", default_value=f"{iStreak}")
        if i == str(1) and nI == 4:
            logging.info("Add Tot. Matches")
            core.add_text("\tTot. Matches")
            core.add_same_line(xoffset=130)
            core.add_text("matches##", default_value=f"{iMatches}")
        if i == str(1) and nI == 5:
            logging.info("Add Matches Won")
            core.add_text("\tMatches Won")
            core.add_same_line(xoffset=130)
            core.add_text("matcheswon##", default_value=f"{iMatchesWon}")
    if int(winLoss[0][0]) == 1:
        core.add_text("\tWin/Loss per Day")
        core.add_same_line(xoffset=130)
        core.add_text("Win/LossperDay##", default_value=f"{iWin} / {iLoss}")
    if int(winLoss[0][1]) == 1:
        core.add_text("\tWin/Loss per Week")
        core.add_same_line(xoffset=130)
        core.add_text("Win/LossperWeek##", default_value=f"{iWin} / {iLoss}")