Add lead checking
This commit is contained in:
@@ -17,9 +17,9 @@ def assign_urls(dictionary):
|
||||
value = input(f"Enter url for '{key}': ")
|
||||
dictionary[key] = value
|
||||
|
||||
def get_team():
|
||||
def get_team(name):
|
||||
user_list = []
|
||||
print("What are the usernames?")
|
||||
print(f"List {name} members.")
|
||||
while True:
|
||||
user_input = input("Add to list (Press Enter to finish): ")
|
||||
if user_input:
|
||||
@@ -45,9 +45,12 @@ def first_time_setup():
|
||||
assign_urls(urls)
|
||||
with open('urls.json', 'w') as file:
|
||||
json.dump(urls, file)
|
||||
users = get_team()
|
||||
users = get_team("users")
|
||||
leads = get_team("leads")
|
||||
with open('team.json', 'w') as file:
|
||||
json.dump(users, file)
|
||||
with open('leads.json', 'w') as file:
|
||||
json.dump(leads, file)
|
||||
|
||||
def show_loading_bar(duration):
|
||||
start_time = time.time()
|
||||
@@ -83,12 +86,20 @@ def main():
|
||||
end_time = datetime.time(17, 0, 0)
|
||||
weekday = datetime.datetime.now().weekday()
|
||||
if start_time <= current_time <= end_time and weekday < 5:
|
||||
while len(driver.window_handles) > 1:
|
||||
driver.switch_to.window(driver.window_handles[1])
|
||||
driver.close()
|
||||
driver.switch_to.window(driver.window_handles[0])
|
||||
try:
|
||||
AutoTicket.auto_ticket(urls, users, driver)
|
||||
except Exception as e:
|
||||
print("An error occurred in AutoTicket.py")
|
||||
print(e)
|
||||
print(traceback.format_exc())
|
||||
while len(driver.window_handles) > 1:
|
||||
driver.switch_to.window(driver.window_handles[1])
|
||||
driver.close()
|
||||
driver.switch_to.window(driver.window_handles[0])
|
||||
try:
|
||||
AutoColor2.tag_assist(urls, driver, users)
|
||||
except Exception as e:
|
||||
|
||||
@@ -4,7 +4,7 @@ from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.common.action_chains import ActionChains
|
||||
import datetime
|
||||
import json
|
||||
import random
|
||||
|
||||
# Condensed string finder for lists of strings
|
||||
@@ -34,12 +34,12 @@ def next_string(list_of_strings):
|
||||
|
||||
|
||||
# Assign steps in order of queue list without checking tag_count
|
||||
def dumb_make_tags(queues,tags,driver):
|
||||
def dumb_make_tags(queues,users,tags,driver):
|
||||
ac = ActionChains(driver)
|
||||
original_window = driver.current_window_handle
|
||||
next_queue = next_string(queues)
|
||||
for tag in tags:
|
||||
if found_string(queues, tag.text.lower()) == False:
|
||||
if found_string(users, tag.text.lower()) == False:
|
||||
driver.execute_script("arguments[0].scrollIntoView(true);", tag)
|
||||
tag_href = tag.find_element(By.TAG_NAME, "a").get_attribute("href")
|
||||
driver.execute_script("window.open(arguments[0]);", tag_href)
|
||||
@@ -121,12 +121,12 @@ def find_lowest_and_increment(dictionary):
|
||||
return min_key
|
||||
|
||||
# Check which queue has the least number of assigned workflows.
|
||||
def smart_make_tags(queues,tags,driver):
|
||||
def smart_make_tags(queues,users,tags,driver):
|
||||
ac = ActionChains(driver)
|
||||
original_window = driver.current_window_handle
|
||||
tag_count = count_tags(queues,tags)
|
||||
for tag in tags:
|
||||
if found_string(queues, tag.text.lower()) == False:
|
||||
if found_string(users, tag.text.lower()) == False:
|
||||
lowest_queue = find_lowest_and_increment(tag_count)
|
||||
driver.execute_script("arguments[0].scrollIntoView(true);", tag)
|
||||
tag_href = tag.find_element(By.TAG_NAME, "a").get_attribute("href")
|
||||
@@ -179,13 +179,13 @@ def filter_steps_manip(driver):
|
||||
filter_steps_manip()
|
||||
|
||||
|
||||
def automation_picker(queues,tags,driver,choice):
|
||||
def automation_picker(queues,users,tags,driver,choice):
|
||||
if choice.lower() == "smart":
|
||||
print("Okay, I'll make you proud (> O ω O)>✎")
|
||||
smart_make_tags(queues,tags,driver)
|
||||
smart_make_tags(queues,users,tags,driver)
|
||||
elif choice.lower() == "dumb":
|
||||
print("Okay, I make thing go now ─=≡Σ((( つ><)つ")
|
||||
dumb_make_tags(queues,tags,driver)
|
||||
dumb_make_tags(queues,users,tags,driver)
|
||||
else:
|
||||
print("Skipping...")
|
||||
|
||||
@@ -193,6 +193,10 @@ def tag_assist(urls,driver,users):
|
||||
print("This is someone's automation tool. If you don't know what you're doing, please abort.")
|
||||
urllist = urls
|
||||
urllist.popitem()
|
||||
with open('leads.json', 'r') as file:
|
||||
leads = json.load(file)
|
||||
#create a list that includes both users and leads
|
||||
elevatedusers = users + leads
|
||||
for key, url in urllist.items():
|
||||
print("Working on ",key)
|
||||
driver.get(url)
|
||||
@@ -208,9 +212,9 @@ def tag_assist(urls,driver,users):
|
||||
tags = driver.find_elements(By.CSS_SELECTOR, "td.tag")
|
||||
random.shuffle(users)
|
||||
if "NOC" in key:
|
||||
automation_picker(users,tags,driver,"smart")
|
||||
automation_picker(users,elevatedusers,tags,driver,"smart")
|
||||
else:
|
||||
automation_picker(users,tags,driver,"dumb")
|
||||
automation_picker(users,elevatedusers,tags,driver,"dumb")
|
||||
print("Done! ✧⋆٩(ᵔ ᗜ ᵔ )و ♡✧")
|
||||
print("Goodbye! ヾ(˶ᵔ ᗜ ᵔ˶)")
|
||||
|
||||
Reference in New Issue
Block a user