import os
import json
import time
import subprocess
import shutil
from datetime import datetime
from zoneinfo import ZoneInfo
import concurrent.futures
import argparse
import json

# Set the timezone to "America/Monterrey"
os.environ['TZ'] = 'America/Monterrey'
tz=ZoneInfo("America/Monterrey")
os.system("")  # enables ansi escape characters in terminal
STOP_WHILE = False

RESET = "\033[0m"
BOLD = "\033[1m"
GREEN = "\033[92m"
RED = "\033[91m"
CYAN = "\033[96m"
WHILE_RUNNER_EMPTY = False
WHILE_RUNNER_MAKER = False
WHILE_RUNNER_ALL = False
WHILE_RUNNER_ZERO = False
while True:
  cur_time = datetime.now(tz).time()
  
  if cur_time.hour == 3 and cur_time.minute > 00:
    if not WHILE_RUNNER_EMPTY:
      WHILE_RUNNER_EMPTY = True
      # subprocess.run(["python", "everything.py"]) 
      print("Running everything")
  if cur_time.hour == int(4) and cur_time.minute > 30:
    if not WHILE_RUNNER_ALL:
      WHILE_RUNNER_ALL = True
      subprocess.run(["python", "everything.py", "-f=zero_mpab"])
      print("Running everything - zero_mpab")
  if cur_time.hour == int(6) and cur_time.minute > 00:
    if not WHILE_RUNNER_MAKER:
      WHILE_RUNNER_MAKER = True
      subprocess.run(["python", "_.py"]) 
      print("Running maker zero")
  if cur_time.hour == int(6) and cur_time.minute > 5:
    if not WHILE_RUNNER_ZERO:
      WHILE_RUNNER_ZERO = True
      subprocess.run(["python", "iniciar_empty.py"]) 
      print("Running iniciar_empty")
      
  if WHILE_RUNNER_ALL and WHILE_RUNNER_EMPTY and WHILE_RUNNER_MAKER and WHILE_RUNNER_ZERO:
    print("FINISHED EVERYTHING !!!!")
    break
  print("Waiting To Run script")
  time.sleep(30)