oulah qu'ai-je fait
This commit is contained in:
parent
e896d4b949
commit
adbb33aa0c
16
Flask/app.py
16
Flask/app.py
@ -141,7 +141,7 @@ def login():
|
|||||||
login_user(user)
|
login_user(user)
|
||||||
if password == "ChangeMe":
|
if password == "ChangeMe":
|
||||||
return(render_template("change_password.html"))
|
return(render_template("change_password.html"))
|
||||||
return(render_template("override.html"))
|
return(redirect('override'))
|
||||||
else:
|
else:
|
||||||
return abort(401)
|
return abort(401)
|
||||||
else:
|
else:
|
||||||
@ -456,6 +456,20 @@ def maxi(dict):
|
|||||||
return(m+1)
|
return(m+1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
from flask import Flask
|
||||||
|
from requests import get
|
||||||
|
|
||||||
|
app = Flask('__main__')
|
||||||
|
SITE_NAME = '192.168.1.32:3000'
|
||||||
|
|
||||||
|
@app.route('/proxytest', defaults={'path': ''})
|
||||||
|
@app.route('/proxytest')
|
||||||
|
def proxy(path):
|
||||||
|
return get(f'{SITE_NAME}').content
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
update_jobs()
|
update_jobs()
|
||||||
edit_version()
|
edit_version()
|
||||||
|
7
V6.py
7
V6.py
@ -611,11 +611,8 @@ def log_points(account="unknown"):
|
|||||||
|
|
||||||
if g.sql_enabled :
|
if g.sql_enabled :
|
||||||
try :
|
try :
|
||||||
add_to_database(account_name, points, g.sql_host, g.sql_usr, g.sql_pwd, g.sql_database)
|
add_to_database(account_name, points)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if g.database_error_override:
|
|
||||||
printf("database error.")
|
|
||||||
else :
|
|
||||||
log_error(e)
|
log_error(e)
|
||||||
|
|
||||||
|
|
||||||
@ -832,7 +829,7 @@ else :
|
|||||||
display = SmartDisplay(size=(1920, 1080))
|
display = SmartDisplay(size=(1920, 1080))
|
||||||
display.start()
|
display.start()
|
||||||
|
|
||||||
webhookFailure.send(f"Starting on this config", username="UPDATE", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
|
webhookFailure.send(f"Starting on this config", username="Check de lancement", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
|
||||||
|
|
||||||
if g.custom_start:
|
if g.custom_start:
|
||||||
CustomStart()
|
CustomStart()
|
||||||
|
@ -1,50 +1,47 @@
|
|||||||
import mysql.connector
|
import sqlite3
|
||||||
|
|
||||||
|
|
||||||
|
#Create a new row, for the account [compte] whith [points] points
|
||||||
|
#SQLITE
|
||||||
def add_row(compte, points, mycursor, mydb):
|
def add_row(compte, points, mycursor, mydb):
|
||||||
sql = "INSERT INTO daily (compte, points, date) VALUES (%s, %s, current_date())"
|
sql = "INSERT INTO daily (compte, points, date) VALUES (?, ?, date())"
|
||||||
val = (compte, points)
|
val = (compte, points)
|
||||||
mycursor.execute(sql, val)
|
mycursor.execute(sql, val)
|
||||||
mydb.commit()
|
mydb.commit()
|
||||||
#printf(mycursor.rowcount, "record created.")
|
#printf(mycursor.rowcount, "record created.")
|
||||||
|
|
||||||
|
|
||||||
|
#update the ammount of points for the account [compte]
|
||||||
|
#SQLITE
|
||||||
def update_row(compte, points, mycursor, mydb):
|
def update_row(compte, points, mycursor, mydb):
|
||||||
sql = f"UPDATE daily SET points = {points} WHERE compte = '{compte}' AND date = current_date() ;"
|
sql = f"UPDATE daily SET points = {points} WHERE compte = '{compte}' AND date = date() ;"
|
||||||
mycursor.execute(sql)
|
mycursor.execute(sql)
|
||||||
mydb.commit()
|
mydb.commit()
|
||||||
#printf(mycursor.rowcount, "record(s) updated")
|
#printf(mycursor.rowcount, "record(s) updated")
|
||||||
|
|
||||||
|
# update the value of last_pts for the table comptes
|
||||||
def update_last(compte, points, mycursor, mydb):
|
def update_last(compte, points, mycursor, mydb):
|
||||||
sql = f"UPDATE comptes SET last_pts = {points} WHERE compte = '{compte}';"
|
sql = f"UPDATE comptes SET last_pts = {points} WHERE compte = '{compte}';"
|
||||||
mycursor.execute(sql)
|
mycursor.execute(sql)
|
||||||
mydb.commit()
|
mydb.commit()
|
||||||
#printf(mycursor.rowcount, "record(s) updated")
|
#printf(mycursor.rowcount, "record(s) updated")
|
||||||
|
|
||||||
|
# if return if there already is a line in the database for the account [compte]. if same_point is enabled, the line must also have the same number of points
|
||||||
def get_row(compte, points, mycursor, same_points = True): #return if there is a line with the same ammount of point or with the same name as well as the same day
|
# SQLITE
|
||||||
|
def get_row(compte, points, mycursor, same_points = True):
|
||||||
if same_points :
|
if same_points :
|
||||||
mycursor.execute(f"SELECT * FROM daily WHERE points = {points} AND compte = '{compte}' AND date = current_date() ;")
|
mycursor.execute(f"SELECT * FROM daily WHERE points = {points} AND compte = '{compte}' AND date = date() ;")
|
||||||
else :
|
else :
|
||||||
mycursor.execute(f"SELECT * FROM daily WHERE compte = '{compte}' AND date = current_date() ;")
|
mycursor.execute(f"SELECT * FROM daily WHERE compte = '{compte}' AND date = date() ;")
|
||||||
myresult = mycursor.fetchall()
|
myresult = mycursor.fetchall()
|
||||||
return(len(myresult) == 1)
|
return(len(myresult) == 1)
|
||||||
|
|
||||||
|
|
||||||
def add_to_database(compte, points, sql_host,sql_usr,sql_pwd,sql_database, save_if_fail=True):
|
def add_to_database(compte, points, save_if_fail=True):
|
||||||
if points is None:
|
if points is None:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
try:
|
mydb = sqlite3.connect("MsRewards.db")
|
||||||
mydb = mysql.connector.connect(
|
|
||||||
host=sql_host,
|
|
||||||
user=sql_usr,
|
|
||||||
password=sql_pwd,
|
|
||||||
database = sql_database
|
|
||||||
)
|
|
||||||
mycursor = mydb.cursor()
|
mycursor = mydb.cursor()
|
||||||
|
|
||||||
if get_row(compte, points,mycursor, True): #check if the row exist with the same ammount of points and do nothind if it does
|
if get_row(compte, points,mycursor, True): #check if the row exist with the same ammount of points and do nothind if it does
|
||||||
#printf("les points sont deja bon")
|
#printf("les points sont deja bon")
|
||||||
#return(0)
|
#return(0)
|
||||||
@ -58,13 +55,9 @@ def add_to_database(compte, points, sql_host,sql_usr,sql_pwd,sql_database, save_
|
|||||||
#return(2) #printf("row added")
|
#return(2) #printf("row added")
|
||||||
if int(points) > 10 :
|
if int(points) > 10 :
|
||||||
update_last(compte, points, mycursor, mydb)
|
update_last(compte, points, mycursor, mydb)
|
||||||
|
|
||||||
mycursor.close()
|
mycursor.close()
|
||||||
mydb.close()
|
mydb.close()
|
||||||
except BaseException as e:
|
|
||||||
if save_if_fail:
|
|
||||||
print("\nLes points n'ont pas pu être ajoutés, enregistrement dans le fichier 'points.csv'\n")
|
|
||||||
with open("points.csv", "a") as file:
|
|
||||||
file.write(f"{compte},{points}\n")
|
|
||||||
raise e
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user