fix: skipping empty email addresses

This commit is contained in:
2026-06-17 18:15:43 +08:00
parent 1166ee2e9e
commit 397bc4cd95
2 changed files with 8 additions and 6 deletions
+6 -4
View File
@@ -393,12 +393,14 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
try:
flow.react(Wait)
attempts += 1
email = cell(index, column.email).value
try: code = str(cell(index, column.code).value)
except ValueError: code = None
occurrence.setdefault(code, 0)
if (target := cell(index, column.email).value) is None or not (email := str(target).strip()):
logger.warning("[%d/%d] Not an email address; skipping", index-1, limit-1)
raise Skip()
if attempts > parameters['attempts']:
logger.warning("[%d/%d] Exhausted all allowed attempts; skipping", index-1, limit-1)
raise Skip()
@@ -416,7 +418,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
case o if o is None:
pass
case o if o > 0 and code is None:
logger.error("Column '%s' contains invalid ID; could not enforce spam control", column.code)
logger.error("Column '%s' cannot be used for spam control", column.code)
raise Cancel()
case o if o > 0 and occurrence[code] >= o:
logger.info("[%d/%d] No Spam! Skipping '%s'", index-1, limit-1, email)
@@ -432,7 +434,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
click(mails[0].find_element(By.CSS_SELECTOR, "button[data-action='close']"), wait=False)
click("div.modal-footer button[data-action='delete']", wait=False)
except Exception as e:
logger.warning('Unable to close off email compose windows', exc_info=e)
logger.debug('Unable to close off email compose windows', exc_info=e)
break
flow.allow(Cancel)