Skip to content

Commit 4c4f0bb

Browse files
committed
bug fixes - foil finish selector, closeBtn, more forgiving with filenames
1 parent 2cc4212 commit 4c4f0bb

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

autofill.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# To package up as executable, run this in command prompt:
1+
`# To package up as executable, run this in command prompt:
22
# pyinstaller --onefile --hidden-import=colorama --icon=favicon.ico autofill.py
33
import colorama
44
from webdriver_manager.chrome import ChromeDriverManager
@@ -108,7 +108,7 @@ def fill_cards(bar: tqdm, driver, root):
108108
# Switch the finish to foil if the user ordered foil cards
109109
if root[0][3].text == "true":
110110
foil_dropdown = Select(driver.find_element_by_id("dro_product_effect"))
111-
foil_dropdown.select_by_visible_text("Holographic (card front)")
111+
foil_dropdown.select_by_value("EF_055")
112112

113113
# Accept current settings and move to next step
114114
driver.execute_script(
@@ -140,7 +140,10 @@ def fill_cards(bar: tqdm, driver, root):
140140

141141
# Page over to the next step from "add text to fronts"
142142
wait(driver)
143-
driver.find_element_by_id("closeBtn").click()
143+
try:
144+
driver.find_element_by_id("closeBtn").click()
145+
except NoSuchElementException:
146+
pass
144147
driver.execute_script("javascript:oDesign.setNextStep();")
145148

146149
# Select "different images" for backs
@@ -305,7 +308,6 @@ def download_card(bar: tqdm, cardinfo):
305308

306309
except requests.exceptions.Timeout:
307310
# Failed to download image because of a timeout error - add it to error queue
308-
# print("timeout error")
309311
q_error.put("{}:\n {}".format(filename, "https://drive.google.com/uc?id=" + file_id + "&export=download"))
310312

311313
# Same check as before - if, after we've tried to download the image, the file doesn't exist or is empty,
@@ -388,15 +390,21 @@ def insert_card(driver, pid, slots):
388390
print("MPC Autofill initialising.")
389391
t = time.time()
390392

391-
# Parse XML doc
392-
try:
393-
tree = ET.parse(currdir + "/cards.xml")
394-
except FileNotFoundError:
393+
# people sometimes name the file different things - so the script will try all of these filenames
394+
# before whinging that it can't find an order file in the directory
395+
tree = None
396+
filenames = ["cards.xml", "cards.xml.txt", "cards.txt.xml", "cards.xml.xml"]
397+
for filename in filenames:
395398
try:
396-
tree = ET.parse(currdir + "/cards.xml.txt")
399+
tree = ET.parse(currdir + "/" + filename)
400+
break
397401
except FileNotFoundError:
398-
input("cards.xml not found in this directory. Press enter to exit.")
399-
sys.exit(0)
402+
pass
403+
404+
if not tree:
405+
input("cards.xml not found in this directory. Press enter to exit.")
406+
sys.exit(0)
407+
400408
root = tree.getroot()
401409

402410
# Extract information out of XML doc

0 commit comments

Comments
 (0)