fix: task slicing limit calculation
This commit is contained in:
@@ -283,9 +283,9 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
||||
flow.append(Skip)
|
||||
|
||||
sp.set('actions', lambda: flow.capabilities())
|
||||
sp.set('cancel', lambda: flow.do(Cancel, force=True))
|
||||
sp.set('close', lambda: flow.do(Close, force=True))
|
||||
sp.set('skip', lambda: flow.do(Skip, force=True))
|
||||
sp.set('cancel', lambda: flow.queue(Cancel))
|
||||
sp.set('close', lambda: flow.queue(Close))
|
||||
sp.set('skip', lambda: flow.queue(Skip))
|
||||
|
||||
def loads(name: str, b64: str):
|
||||
from base64 import b64decode
|
||||
@@ -353,9 +353,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
||||
|
||||
while True:
|
||||
try:
|
||||
flow.allow(Wait)
|
||||
flow.do(Wait)
|
||||
flow.react()
|
||||
flow.react(Wait)
|
||||
progress.clear()
|
||||
driver.switch_to.window(driver.window_handles[1])
|
||||
subject = get_subject()
|
||||
@@ -377,16 +375,13 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
||||
logger.info('Timezone: %s', locale.timezone)
|
||||
|
||||
progress['done'] = 0
|
||||
progress['skip'] = 0
|
||||
progress['subject'] = subject
|
||||
logger.info('Done')
|
||||
except Cancel:
|
||||
status = Status.IDLE
|
||||
driver.switch_to.window(driver.window_handles[0])
|
||||
continue
|
||||
except StopIteration:
|
||||
logger.error('Invalid locale: %s', options.get('locale'))
|
||||
status = Status.IDLE
|
||||
continue
|
||||
except Exception as e:
|
||||
logger.error('Error while loading data', exc_info=e)
|
||||
status = Status.IDLE
|
||||
@@ -399,8 +394,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
||||
|
||||
while index <= limit:
|
||||
try:
|
||||
flow.do(Wait)
|
||||
flow.react()
|
||||
flow.react(Wait)
|
||||
attempts += 1
|
||||
name = cell(index, column.recipient).value
|
||||
email = cell(index, column.email).value
|
||||
@@ -447,8 +441,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
||||
|
||||
flow.allow(Cancel)
|
||||
flow.allow(Skip)
|
||||
flow.do(Wait)
|
||||
flow.react()
|
||||
flow.react(Wait)
|
||||
progress['email'] = str(email)
|
||||
progress['recipient'] = str(name)
|
||||
logger.info('[%d/%d] Sending to %s', index-1, limit-1, email)
|
||||
@@ -464,8 +457,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
||||
if error is not None and not options.get('force'):
|
||||
raise error
|
||||
|
||||
flow.do(Wait)
|
||||
flow.react()
|
||||
flow.react(Wait)
|
||||
click("ul.classic-toolbar button[aria-label='Edit copy']")
|
||||
until(ready)
|
||||
locate("div.io-ox-mail-compose-window iframe", condition=EC.frame_to_be_available_and_switch_to_it)
|
||||
@@ -495,8 +487,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
||||
clean = target.text == hello
|
||||
|
||||
driver.switch_to.default_content()
|
||||
flow.do(Wait)
|
||||
flow.react()
|
||||
flow.react(Wait)
|
||||
click("div.io-ox-mail-compose-window div[data-extension-id='to'] > div.mail-input")
|
||||
box = locate("div.io-ox-mail-compose-window div[data-extension-id='to'] > div.mail-input input.token-input.tt-input[tabindex='0']")
|
||||
box.send_keys(str(email) + Keys.ENTER)
|
||||
@@ -514,8 +505,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
||||
target.send_keys(template)
|
||||
clean = target.get_attribute('value') == template
|
||||
|
||||
flow.do(Wait)
|
||||
flow.react()
|
||||
flow.react(Wait)
|
||||
box = locate("div.io-ox-mail-compose-window .mail-input .tokenfield .token")
|
||||
recipient = box.get_attribute('innerText').strip()
|
||||
|
||||
@@ -527,10 +517,10 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
||||
logger.warning('Malformed email content detected; retrying (%d)...', attempts)
|
||||
continue
|
||||
|
||||
flow.do(Wait)
|
||||
flow.react()
|
||||
flow.react(Wait)
|
||||
click("div.io-ox-mail-compose-window button[data-action='send']")
|
||||
except Skip:
|
||||
progress['skip'] += 1
|
||||
index += 1
|
||||
attempts = 0
|
||||
continue
|
||||
@@ -566,13 +556,11 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
||||
|
||||
if options.get('writable'):
|
||||
try:
|
||||
logger.info('Saving document...')
|
||||
status = Status.CLOSING
|
||||
flow.allow(Wait, False)
|
||||
flow.allow(Timeout)
|
||||
flow.allow(Close)
|
||||
logger.info('Saving document...')
|
||||
flow.do(Timeout, force=True)
|
||||
flow.react()
|
||||
flow.react(Timeout)
|
||||
except Close:
|
||||
pass
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user