add yaml dependency, cli colors and translation file
This commit is contained in:
54
main.py
54
main.py
@@ -1,46 +1,70 @@
|
||||
import sys
|
||||
from src.adischeck import (
|
||||
get_mednr_exempl,
|
||||
enter_print_mode,
|
||||
exit_print_mode,
|
||||
is_adis_running,
|
||||
)
|
||||
from src.adischeck_online import run, work_on_page
|
||||
import pyautogui
|
||||
from src.database import Database
|
||||
from src.colors import bcolors
|
||||
import time
|
||||
import yaml
|
||||
|
||||
|
||||
INACTIVITY_LIMIT = 5 * 60 # 5 minutes
|
||||
catalogue_pid = None
|
||||
print_pid = None
|
||||
|
||||
database = Database()
|
||||
lang = input("Enter language (de/en): ").strip().lower()
|
||||
if lang not in ["de", "en"]:
|
||||
print("Invalid language. Defaulting to English.")
|
||||
lang = "en"
|
||||
with open("lang.txt", "w", encoding="utf-8") as f:
|
||||
f.write(lang)
|
||||
sys_messages = yaml.safe_load(open(f"translation.yaml", "r", encoding="utf-8"))
|
||||
print(bcolors.BOLD + bcolors.OKGREEN + sys_messages["start"][lang] + bcolors.ENDC)
|
||||
adis_launch = time.time()
|
||||
page = run()
|
||||
|
||||
|
||||
def start_instructions():
|
||||
print(bcolors.OKBLUE + sys_messages["adis_running"][lang] + bcolors.ENDC)
|
||||
time.sleep(1)
|
||||
print(bcolors.OKCYAN + sys_messages["log_in"][lang] + bcolors.ENDC)
|
||||
time.sleep(1)
|
||||
print(bcolors.OKCYAN + sys_messages["goto_exemplar"][lang] + bcolors.ENDC)
|
||||
time.sleep(1)
|
||||
print(bcolors.OKCYAN + sys_messages["ready_to_continue"][lang] + bcolors.ENDC)
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
def main():
|
||||
print("Starting the script...")
|
||||
while not is_adis_running():
|
||||
print(sys_messages["waiting_for_adis"][lang], end="\r")
|
||||
time.sleep(5)
|
||||
start_instructions()
|
||||
print(bcolors.WARNING + sys_messages["important"][lang] + bcolors.ENDC)
|
||||
|
||||
print(sys_messages["explanation"][lang])
|
||||
input(sys_messages["start_run"][lang])
|
||||
while True:
|
||||
mednr = get_mednr_exempl()
|
||||
print("Mednr:", mednr)
|
||||
|
||||
pyautogui.hotkey("alt", "s")
|
||||
work_on_page(page, mednr)
|
||||
page_alive = work_on_page(page, mednr)
|
||||
if page_alive is False:
|
||||
print(bcolors.FAIL + sys_messages["page_dead"][lang] + bcolors.ENDC)
|
||||
sys.exit(1)
|
||||
enter_print_mode()
|
||||
pyautogui.press("space")
|
||||
time.sleep(1)
|
||||
exit_print_mode()
|
||||
# keyboard.wait('space')
|
||||
|
||||
# time.sleep(5)
|
||||
# text = adis_get_signature()
|
||||
# new = database.insert_ma(text)
|
||||
# clipboard.copy(new) # Copy the new signature to clipboard
|
||||
# print(text, new)
|
||||
# pyautogui.hotkey('ctrl', 'v') # Select all text
|
||||
# mednr = adis_save_and_enter_exemplar(new) # Example usage with a new signature
|
||||
# print("finished main work, printing new signature")
|
||||
# time.sleep(1)
|
||||
# print_new_signature(catalogue_pid, print_pid, mednr)
|
||||
# new_search()
|
||||
print(bcolors.WARNING + sys_messages["timeout"][lang] + bcolors.ENDC)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user