MsRewards-Reborn/modules/Tools/tools.py

37 lines
1017 B
Python
Raw Normal View History

from time import sleep
2024-02-27 15:19:53 +01:00
from modules.Tools.logger import info, error
# return current page domain
def get_domain(driver):
return driver.current_url.split("/")[2]
def custom_sleep(temps):
try:
if True: # todo: change this awful condition
points = ["", "", "", "", "", "", "", ""]
passe = 0
2024-02-27 15:17:11 +01:00
for _ in range(int(temps)):
for i in range(8):
sleep(0.125)
passe += 0.125
print(f"{points[i]} - {round(float(temps) - passe, 3)}", end="\r")
print(" ", end="\r")
else:
sleep(temps)
except KeyboardInterrupt:
2024-02-27 15:18:45 +01:00
info("Wait canceled.")
except Exception as err:
error(err)
def format_error(e) -> str:
tb = e.__traceback__
txt = ""
while tb is not None:
txt = txt + f" -> {tb.tb_frame.f_code.co_name} ({tb.tb_lineno}) "
tb = tb.tb_next
return txt + "\n" + str(e)