Run continiously

This commit is contained in:
Hex
2025-02-27 08:05:32 -08:00
parent 58fa818128
commit 76669872ae
3 changed files with 69 additions and 17 deletions

View File

@@ -5,8 +5,10 @@ import json
import os
import datetime
import time
import random
import traceback
urls = {"NOC-PROV": "", "NOC-PROV-ADV" : "", "PROV-DSL" : "", "PROV-FIBER":"", "PROV-IPBB":"","PROV-MISC":"","FUS-PROV":"","TICKETS":""}
urls = {"NOC-PROV":"","NOC-PROV-ADV":"","CONSUMER-PROV":"","TICKETS":""}
tickets_sorted = False
@@ -47,25 +49,63 @@ def first_time_setup():
with open('team.json', 'w') as file:
json.dump(users, file)
def show_loading_bar(duration):
start_time = time.time()
while True:
elapsed_time = time.time() - start_time
progress = elapsed_time / duration
bar_length = 30
filled_length = int(progress * bar_length)
bar = '#' * filled_length + '-' * (bar_length - filled_length)
percent = round(progress * 100, 2)
remaining_time = round(duration - elapsed_time, 2)
remaining_hours = int(remaining_time / 3600)
remaining_minutes = int((remaining_time % 3600) / 60)
remaining_seconds = int(remaining_time % 60)
print(f"Waiting: [{bar}] {percent}% | Remaining Time: {remaining_hours}h {remaining_minutes}m {remaining_seconds}s", end='\r')
if elapsed_time >= duration:
break
time.sleep(0.5)
print("\nWait time complete!")
def main():
if os.path.exists('urls.json'):
print("Skipping first time setup")
else: first_time_setup()
driver = webdriver.Firefox()
with open('urls.json', 'r') as file:
urls = json.load(file)
with open('team.json', 'r') as file:
users = json.load(file)
while True:
with open('urls.json', 'r') as file:
urls = json.load(file)
with open('team.json', 'r') as file:
users = json.load(file)
current_time = datetime.datetime.now().time()
start_time = datetime.time(9, 0, 0)
start_time = datetime.time(7, 0, 0)
end_time = datetime.time(17, 0, 0)
if start_time <= current_time <= end_time:
AutoTicket.auto_ticket(urls, users, driver, tickets_sorted)
AutoColor2.tag_assist(urls, driver, users)
weekday = datetime.datetime.now().weekday()
if start_time <= current_time <= end_time and weekday < 5:
try:
AutoTicket.auto_ticket(urls, users, driver)
except Exception as e:
print("An error occurred in AutoTicket.py")
print(e)
print(traceback.format_exc())
try:
AutoColor2.tag_assist(urls, driver, users)
except Exception as e:
print("An error occurred in AutoColor2.py")
print(e)
else:
print("It's after hours. I'm not doing anything.")
time.sleep(7200) # Sleep for 2 hours
print("It's after hours or on the weekend. I'm not doing anything.")
current_time = datetime.datetime.now().time()
weekday = datetime.datetime.now().weekday()
if start_time <= current_time <= end_time and weekday < 5:
sleep_duration = random.uniform(5400, 7200) # Random amount of time between 1.5 hours and 2 hours
else:
next_start_time = datetime.datetime.combine(datetime.date.today(), start_time)
if current_time > end_time or weekday >= 5:
next_start_time += datetime.timedelta(days=1)
sleep_duration = (next_start_time - datetime.datetime.now()).total_seconds() + random.uniform(0, 5400) # Time until next start time + random amount between 0 and 1.5 hours
show_loading_bar(sleep_duration)
#driver.close()
main()