diff --git a/main.py b/main.py index 1ce1ca4..c6fe317 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ import re import trio import trio_websocket as ws -from selenium.common.exceptions import StaleElementReferenceException, TimeoutException, InvalidSessionIdException +from selenium.common.exceptions import StaleElementReferenceException, TimeoutException from selenium.webdriver import Chrome, ChromeOptions from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.by import By @@ -349,7 +349,8 @@ def main(driver: WebDriver): axis = index[current] occurrence = occurrences.setdefault(code, [0]) if code else [0] - outbox.put(Command('setProgress', cursor, name, recipient, sent, warnings, errors)) + try: outbox.put(Command('setProgress', cursor, name, recipient, sent, warnings, errors)) + except ShutDown: break if (remarks := frame.loc[axis, cs]) is not None and str(remarks).strip(): tell(f'已跳过项目 {recipient}') @@ -363,10 +364,10 @@ def main(driver: WebDriver): while status.isactive(): try: + tell('正在发送:%s (%.2f %%)' % (recipient, current / limit * 100)) clean = True attempt += 1 request = get_request() - tell('正在发送:%s (%.2f %%)' % (recipient, current / limit * 100)) if (target := get_address()) != address: exception = Exception(f'邮件发件地址与设定不一致\n>> {address}\n>> {target}')