I need a better solution

This commit is contained in:
piair338
2022-10-25 08:03:24 +00:00
parent 0af267e628
commit c665144b28
2 changed files with 95 additions and 100 deletions

View File

@ -8,8 +8,9 @@ from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAd
)
from modules.config import *
global _mail
_mail = "undefined"
"""
send_keys_wait([selenium element:element, str:keys]) send the different keys to the field element, with a random time between each press to simulate human action.
keys can be an string, but alos selenium keys
@ -22,7 +23,8 @@ def send_keys_wait(element, keys):
else :
sleep(uniform(0.1, 0.3))
def LogError(message, driver,_mail, log=FULL_LOG):
def LogError(message, driver, _mail, log=FULL_LOG):
print(f"\n\n\033[93m Erreur : {str(message)} \033[0m\n\n")
if DISCORD_ENABLED_ERROR:
with open("page.html", "w") as f:
@ -50,19 +52,17 @@ def LogError(message, driver,_mail, log=FULL_LOG):
# add the time arround the text given in [text]
# [text] : string
def Timer(text="undefined"):
def Timer(text="undefined", mail=_mail):
return(f"[{_mail} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text))
# replace the function print, with more options
# [txt] : string, [driver] : selenium wbdriver
def printf(txt, LOG = LOG):
def printf(txt, mail = _mail, LOG = LOG):
if LOG:
print(Timer(txt))
print(Timer(txt, _mail))