示例#1
0
def check_activity():

    last_played = db.select_newest_date()

    db_date = last_played.split("T")[0]

    if db_date != date.today().isoformat():
        send_notification(
            f"No new games were added today. Last game: {last_played}",
            'error')
        logging.warning(f"Have you been playing? Last game: {last_played}")
示例#2
0
    ratings_plot.axhline(y=100, color='darkgoldenrod', linestyle=':')
    ratings_plot.axhline(y=400, color='darkgoldenrod', linestyle=':')
    ratings_plot.axhline(y=700, color='darkgoldenrod', linestyle=':')

    ratings_plot.axhline(y=1000, color='gray')
    ratings_plot.axhline(y=1300, color='gray', linestyle=':')
    ratings_plot.axhline(y=1600, color='gray', linestyle=':')

    ratings_plot.axhline(y=1900, color='gold', linestyle='--')

    ratings_plot.set_xlabel('battles')
    ratings_plot.set_ylabel('rating')
    power_plot.set_ylabel('power')
    plt.title('Rating over time')

    # plt.show()
    plt.savefig(os.path.join(DATA_PATH, 'ratings_graph.png'))


if __name__ == "__main__":
    try:
        generate_lists()
        generate_graph()
    except BaseException:
        import sys
        logging.critical(sys.exc_info()[0])
        import traceback
        logging.critical(traceback.format_exc())

        send_notification("Graph creation ecountered an ERROR.", 'error')
示例#3
0
    # Loading the JSON string data into a dictionary
    quest_data = json.loads(sl_response.text)[0]

    # extract datetime object our of the string
    quest_time = datetime.fromisoformat(
        quest_data['created_date'].replace('Z', ''))

    quest_time += timedelta(hours=25)

    # set the task to the time of next quest
    for job in my_cron:
        if job.comment == 'sl_quest_notifier':
            job.setall((quest_time.minute), quest_time.hour, "*", "*", "*")
            my_cron.write()

            break

    logging.info(
        f"Changed times to {quest_time.hour}:{str(quest_time.minute).zfill(2)}.")


if __name__ == "__main__":
    try:
        update_cron()
    except:
        send_notification("Quest Checker encountered an error.", 'error')
        import sys
        logging.critical(sys.exc_info()[0])
        import traceback
        logging.critical(traceback.format_exc())
示例#4
0
                   player_2_rating_final=battle["player_2_rating_final"],
                   details=battle["details"],
                   player_1=battle["player_1"],
                   player_2=battle["player_2"],
                   created_date=battle["created_date"],
                   match_type=battle["match_type"],
                   mana_cap=battle["mana_cap"],
                   current_streak=battle["current_streak"],
                   ruleset=battle["ruleset"],
                   inactive=battle["inactive"],
                   settings=battle["settings"],
                   block_num=battle["block_num"],
                   rshares=battle["rshares"],
                   dec_info=battle["dec_info"],
                   leaderboard=battle["leaderboard"],
                   power=current_power))

    db.add_battles(battles_to_add)


if __name__ == '__main__':
    try:
        update_json()
    except BaseException:
        import sys
        logging.critical(sys.exc_info()[0])
        import traceback
        logging.critical(traceback.format_exc())

        send_notification("Downloader encountered an Error.", 'error')
示例#5
0
                       ON DUPLICATE KEY UPDATE battles=battles+1, battles_won=battles_won+{winner};")

    print("commiting ...")
    db.commit()


@DeprecationWarning
def _get_first_enemies():

    db, cursor = open_conn()

    # get from db
    cursor.execute("SELECT player_1, player_2, winner FROM Battles;")

    add_enemies(cursor.fetchall(), db, cursor)

    close_conn(db, cursor)


# run only once to initialize
if __name__ == '__main__':
    try:
        _get_first_enemies()
    except BaseException:
        import sys
        print(sys.exc_info()[0])
        import traceback
        print(traceback.format_exc())

        send_notification("An Error occured in enemies.", 'error')