YEAH
This commit is contained in:
parent
08b593eeb9
commit
4e939bec2f
54
Flask/app.py
54
Flask/app.py
|
@ -28,19 +28,46 @@ if secret == "":
|
|||
scheduler = BackgroundScheduler()
|
||||
scheduler.start()
|
||||
|
||||
trigger = CronTrigger(
|
||||
year="*", month="*", day="*", hour="2", minute="25", second="25"
|
||||
)
|
||||
|
||||
def start_ms():
|
||||
subprocess.Popen(["python3", "./V6.py", "-v", "2345"])
|
||||
def start_ms(i):
|
||||
print("\033[32m" + f"Starting config {i}" + "\033[0m")
|
||||
subprocess.Popen(["python3", "./V6.py", "-c", i])
|
||||
|
||||
|
||||
scheduler.add_job(
|
||||
start_ms,
|
||||
trigger=trigger,
|
||||
#args=["hello world"],
|
||||
name="Daily start",
|
||||
)
|
||||
TriggerDict = {}
|
||||
def update_jobs():
|
||||
with open("./user_data/configs.json", "r") as inFile:
|
||||
configs = json.load(inFile)
|
||||
|
||||
for i in configs:
|
||||
h, m = configs[i]["time"].split(":")
|
||||
print("\033[36m" + f"config {i} : {h}:{m}" + "\033[0m")
|
||||
TriggerDict[i] = CronTrigger(
|
||||
year="*", month="*", day="*", hour=h, minute=m, second="0"
|
||||
)
|
||||
if configs[i]["enabled"]:
|
||||
try :
|
||||
scheduler.remove_job(i) # on reset le job
|
||||
except Exception as e:
|
||||
print(f"\033[33merror with deleting config {i} : {e}\033[0m")
|
||||
|
||||
try :
|
||||
scheduler.add_job( # on relance le job
|
||||
start_ms, # ---
|
||||
trigger=TriggerDict[i], # ---
|
||||
args=[i], # ---
|
||||
name="Daily start", # ---
|
||||
id=i # ---
|
||||
)
|
||||
print("\033[36m" + f"successfully created config {i}" + "\033[0m")
|
||||
except Exception as e:
|
||||
print(f"\033[33merror with creating config {i} : {e}\033[0m")
|
||||
else :
|
||||
try :
|
||||
scheduler.remove_job(i)
|
||||
except Exception as e :
|
||||
print(f"\033[33merror with deleting config {i} : {e}\033[0m")
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -245,7 +272,7 @@ def override_get():
|
|||
|
||||
|
||||
@app.route("/override/", methods=["post"])
|
||||
def override():
|
||||
def override_post():
|
||||
with open("./user_data/configs.json", "r") as inFile:
|
||||
configs = json.load(inFile)
|
||||
|
||||
|
@ -262,7 +289,7 @@ def override():
|
|||
|
||||
with open("./user_data/configs.json", "w") as inFile:
|
||||
json.dump(configs, inFile)
|
||||
|
||||
update_jobs()
|
||||
return(render_template("override.html", data=configs))
|
||||
|
||||
|
||||
|
@ -338,7 +365,6 @@ def config_post():
|
|||
return(render_template("config.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=maxi(configs)))
|
||||
|
||||
|
||||
|
||||
def maxi(dict):
|
||||
m = 0
|
||||
for i in dict :
|
||||
|
|
|
@ -47,10 +47,10 @@
|
|||
<tr>
|
||||
<td>{{data[i]['name']}}</td>
|
||||
<td>
|
||||
<input type="time" id="{{i}}" name="time{{i}}" value="{{data[i]['time']}}">
|
||||
<input type="time" id="{{i}}" name="time{{i}}" value="{{data[i]['time']}}" required>
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" id="switch{{i}}" name="switch{{i}}" {{ "checked" if data[i]['enabled'] == True else "" }}/>
|
||||
<input type="checkbox" id="switch{{i}}" name="switch{{i}}" {{ "checked" if data[i]['enabled'] == True else "" }} />
|
||||
<label for="switch{{i}}">
|
||||
Toggle
|
||||
</label>
|
||||
|
|
Loading…
Reference in New Issue