fix: 'common' version
This commit is contained in:
@@ -257,17 +257,12 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
selection = 0
|
selection = 0
|
||||||
|
|
||||||
sp.set('actions', lambda: flow.capabilities())
|
sp.set('actions', lambda: flow.capabilities())
|
||||||
sp.set('cancel', lambda: flow.do(Cancel, force=True))
|
sp.set('cancel', lambda: flow.queue(Cancel))
|
||||||
sp.set('skip', lambda: flow.do(Skip, force=True))
|
sp.set('skip', lambda: flow.queue(Skip))
|
||||||
sp.set('progress', lambda: progress)
|
sp.set('progress', lambda: progress)
|
||||||
|
|
||||||
while True:
|
while not flow.react(Wait):
|
||||||
try:
|
try:
|
||||||
flow.allow(Wait)
|
|
||||||
flow.allow(Sleep)
|
|
||||||
flow.do(Wait)
|
|
||||||
flow.react()
|
|
||||||
|
|
||||||
for i in range(len(driver.window_handles), 1, -1):
|
for i in range(len(driver.window_handles), 1, -1):
|
||||||
driver.switch_to.window(driver.window_handles[i-1])
|
driver.switch_to.window(driver.window_handles[i-1])
|
||||||
driver.close()
|
driver.close()
|
||||||
@@ -319,9 +314,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
|
|
||||||
logger.info('Downloading invoices (%d)', page)
|
logger.info('Downloading invoices (%d)', page)
|
||||||
data.extend(result)
|
data.extend(result)
|
||||||
flow.do(Wait)
|
flow.react(Wait, Sleep)
|
||||||
flow.do(Sleep)
|
|
||||||
flow.react()
|
|
||||||
except Skip:
|
except Skip:
|
||||||
pass
|
pass
|
||||||
except Cancel:
|
except Cancel:
|
||||||
@@ -385,8 +378,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
for i, item in enumerate(data, 1):
|
for i, item in enumerate(data, 1):
|
||||||
flow.do(Wait)
|
flow.react(Wait)
|
||||||
flow.react()
|
|
||||||
number: str = item['number']
|
number: str = item['number']
|
||||||
logger.info('[%d/%d] Preprocessing data for %s', i, len(data), number)
|
logger.info('[%d/%d] Preprocessing data for %s', i, len(data), number)
|
||||||
progress['number'] = number
|
progress['number'] = number
|
||||||
@@ -462,8 +454,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
filename = f'Order-Import-{profile.name}-{datetime.now().strftime('%Y%m%d-%H%M%S-%f')}.xlsx'
|
filename = f'Order-Import-{profile.name}-{datetime.now().strftime('%Y%m%d-%H%M%S-%f')}.xlsx'
|
||||||
file = Path(parameters['directory']).joinpath(filename)
|
file = Path(parameters['directory']).joinpath(filename)
|
||||||
logger.info('Saving excel file to %s', str(file))
|
logger.info('Saving excel file to %s', str(file))
|
||||||
flow.do(Wait)
|
flow.react(Wait)
|
||||||
flow.react()
|
|
||||||
workbook.save(file)
|
workbook.save(file)
|
||||||
except Skip:
|
except Skip:
|
||||||
pass
|
pass
|
||||||
@@ -487,8 +478,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
click(".product-import-img-box .mm-selector-rendered")
|
click(".product-import-img-box .mm-selector-rendered")
|
||||||
click(".mm-outside.mm-select-dropdown ul li:nth-child(%d) span" % (1 if options.get('draft') else 6))
|
click(".mm-outside.mm-select-dropdown ul li:nth-child(%d) span" % (1 if options.get('draft') else 6))
|
||||||
|
|
||||||
flow.do(Wait)
|
flow.react(Wait)
|
||||||
flow.react()
|
|
||||||
locate(".big-file-upload input", wait=False).send_keys(str(file))
|
locate(".big-file-upload input", wait=False).send_keys(str(file))
|
||||||
click(".product-import-img-footer button")
|
click(".product-import-img-footer button")
|
||||||
click(".product-import-img-footer button.mm-button__primary")
|
click(".product-import-img-footer button.mm-button__primary")
|
||||||
@@ -498,8 +488,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
innerText = driver.find_element(By.CSS_SELECTOR, ".img-box-result-title").get_attribute('innerText')
|
innerText = driver.find_element(By.CSS_SELECTOR, ".img-box-result-title").get_attribute('innerText')
|
||||||
if innerText == '导入完成': break
|
if innerText == '导入完成': break
|
||||||
except:
|
except:
|
||||||
flow.do(Sleep)
|
flow.react(Sleep)
|
||||||
flow.react()
|
|
||||||
|
|
||||||
click(".mm-notification-container .mm-icon-close")
|
click(".mm-notification-container .mm-icon-close")
|
||||||
click(".product-import-img-footer button.mm-button__primary")
|
click(".product-import-img-footer button.mm-button__primary")
|
||||||
@@ -508,12 +497,10 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
if err.get_attribute('disabled') is None:
|
if err.get_attribute('disabled') is None:
|
||||||
logger.warning('Incomplete import detected; downloaded 1 related document')
|
logger.warning('Incomplete import detected; downloaded 1 related document')
|
||||||
err.click()
|
err.click()
|
||||||
flow.do(Sleep)
|
flow.react(Sleep)
|
||||||
flow.react()
|
|
||||||
|
|
||||||
click(".mm-tbody table tbody tr:nth-child(1) td:nth-child(3) a")
|
click(".mm-tbody table tbody tr:nth-child(1) td:nth-child(3) a")
|
||||||
flow.do(Sleep)
|
flow.react(Sleep)
|
||||||
flow.react()
|
|
||||||
logger.info('Done')
|
logger.info('Done')
|
||||||
except Skip:
|
except Skip:
|
||||||
pass
|
pass
|
||||||
@@ -579,8 +566,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
progress['index'] = index
|
progress['index'] = index
|
||||||
flow.allow(Cancel)
|
flow.allow(Cancel)
|
||||||
flow.allow(Skip)
|
flow.allow(Skip)
|
||||||
flow.do(Wait)
|
flow.react(Wait)
|
||||||
flow.react()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for page in count(1):
|
for page in count(1):
|
||||||
@@ -598,21 +584,17 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
'array_flag': 0
|
'array_flag': 0
|
||||||
}])
|
}])
|
||||||
driver.get(url.encode())
|
driver.get(url.encode())
|
||||||
flow.do(Wait)
|
flow.react(Wait, Sleep)
|
||||||
flow.do(Sleep)
|
|
||||||
flow.react()
|
|
||||||
url = Parse(driver.current_url)
|
url = Parse(driver.current_url)
|
||||||
if url.get('page') != page: raise Exception(number)
|
if url.get('page') != page: raise Exception(number)
|
||||||
|
|
||||||
flow.do(Sleep)
|
flow.react(Sleep)
|
||||||
flow.react()
|
|
||||||
link = locate(".virtual-list-wrap .vue-recycle-scroller .vue-recycle-scroller__item-wrapper > div:nth-child(1) .cell[data-cci='1'] a", wait=False)
|
link = locate(".virtual-list-wrap .vue-recycle-scroller .vue-recycle-scroller__item-wrapper > div:nth-child(1) .cell[data-cci='1'] a", wait=False)
|
||||||
if link.text != number: continue
|
if link.text != number: continue
|
||||||
logger.info('[%d/%d] Processing %s...', index+1, len(data), number)
|
logger.info('[%d/%d] Processing %s...', index+1, len(data), number)
|
||||||
link.click()
|
link.click()
|
||||||
driver.switch_to.window(driver.window_handles[3])
|
driver.switch_to.window(driver.window_handles[3])
|
||||||
flow.do(Wait)
|
flow.react(Wait)
|
||||||
flow.react()
|
|
||||||
click(".sticky .okki-space-item:nth-child(1) button")
|
click(".sticky .okki-space-item:nth-child(1) button")
|
||||||
break
|
break
|
||||||
except Skip:
|
except Skip:
|
||||||
@@ -636,9 +618,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
driver.switch_to.new_window('tab')
|
driver.switch_to.new_window('tab')
|
||||||
url = Parse(WEBURL % 'crm/business/list')
|
url = Parse(WEBURL % 'crm/business/list')
|
||||||
driver.get(url.encode({ 'mode': 'list' }))
|
driver.get(url.encode({ 'mode': 'list' }))
|
||||||
flow.do(Wait)
|
flow.react(Wait, Sleep)
|
||||||
flow.do(Sleep)
|
|
||||||
flow.react()
|
|
||||||
|
|
||||||
try: click(".new-wrapper .paas-next-invoice-list-filter-line-wrapper .okki-btn-background-ghost", wait=False)
|
try: click(".new-wrapper .paas-next-invoice-list-filter-line-wrapper .okki-btn-background-ghost", wait=False)
|
||||||
except: pass
|
except: pass
|
||||||
@@ -650,14 +630,11 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
url.set('curPage', page)
|
url.set('curPage', page)
|
||||||
url.set('pageSize', 1)
|
url.set('pageSize', 1)
|
||||||
driver.get(url.encode({ 'keyword': match, 'search_field': 'serial_keyword' }))
|
driver.get(url.encode({ 'keyword': match, 'search_field': 'serial_keyword' }))
|
||||||
flow.do(Wait)
|
flow.react(Wait, Sleep)
|
||||||
flow.do(Sleep)
|
|
||||||
flow.react()
|
|
||||||
url = Parse(driver.current_url)
|
url = Parse(driver.current_url)
|
||||||
if url.get('curPage') != page: raise Exception(match)
|
if url.get('curPage') != page: raise Exception(match)
|
||||||
|
|
||||||
flow.do(Sleep)
|
flow.react(Sleep)
|
||||||
flow.react()
|
|
||||||
cell = locate(".virtual-list-wrap .vue-recycle-scroller .row-item > .cell:nth-child(3) .ow-serial-read-pretty_ellipsis", wait=False)
|
cell = locate(".virtual-list-wrap .vue-recycle-scroller .row-item > .cell:nth-child(3) .ow-serial-read-pretty_ellipsis", wait=False)
|
||||||
if cell.text != match: continue
|
if cell.text != match: continue
|
||||||
link = locate(".virtual-list-wrap .vue-recycle-scroller .row-item > .cell:nth-child(6) a", wait=False)
|
link = locate(".virtual-list-wrap .vue-recycle-scroller .row-item > .cell:nth-child(6) a", wait=False)
|
||||||
@@ -681,8 +658,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
|
|
||||||
if opportunity is not None:
|
if opportunity is not None:
|
||||||
try:
|
try:
|
||||||
flow.do(Wait)
|
flow.react(Wait)
|
||||||
flow.react()
|
|
||||||
dropdown = locate("#rc_select_1")
|
dropdown = locate("#rc_select_1")
|
||||||
dropdown.clear()
|
dropdown.clear()
|
||||||
dropdown.send_keys(opportunity)
|
dropdown.send_keys(opportunity)
|
||||||
@@ -716,8 +692,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
for page in count(1):
|
for page in count(1):
|
||||||
hits = 0
|
hits = 0
|
||||||
iteration = 0
|
iteration = 0
|
||||||
flow.do(Wait)
|
flow.react(Wait)
|
||||||
flow.react()
|
|
||||||
|
|
||||||
while hits < pagination and iteration < parameters['attempts']:
|
while hits < pagination and iteration < parameters['attempts']:
|
||||||
iteration += 1
|
iteration += 1
|
||||||
@@ -727,8 +702,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
rows = wrapper.find_elements(By.CSS_SELECTOR, ".row-item")
|
rows = wrapper.find_elements(By.CSS_SELECTOR, ".row-item")
|
||||||
|
|
||||||
for row in reversed(rows) if iteration > 1 else rows:
|
for row in reversed(rows) if iteration > 1 else rows:
|
||||||
flow.do(Wait)
|
flow.react(Wait)
|
||||||
flow.react()
|
|
||||||
driver.execute_script("arguments[0].scrollIntoView({ block: 'center' });", wrapper)
|
driver.execute_script("arguments[0].scrollIntoView({ block: 'center' });", wrapper)
|
||||||
driver.execute_script("arguments[0].scrollTo(0, arguments[1]);", wrapper, height)
|
driver.execute_script("arguments[0].scrollTo(0, arguments[1]);", wrapper, height)
|
||||||
serial = row.text.split('\n', 1)[0].strip()
|
serial = row.text.split('\n', 1)[0].strip()
|
||||||
@@ -740,8 +714,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
driver.execute_script("arguments[0].scroll(400, 0);", wrapper)
|
driver.execute_script("arguments[0].scroll(400, 0);", wrapper)
|
||||||
driver.execute_script("arguments[0].scrollIntoView({ block: 'center' });", row)
|
driver.execute_script("arguments[0].scrollIntoView({ block: 'center' });", row)
|
||||||
driver.execute_script("arguments[0].scrollIntoView({ block: 'center' });", wrapper)
|
driver.execute_script("arguments[0].scrollIntoView({ block: 'center' });", wrapper)
|
||||||
flow.do(Sleep)
|
flow.react(Sleep)
|
||||||
flow.react()
|
|
||||||
target = row.find_element(By.CSS_SELECTOR, ".cell[data-cci='6'] input")
|
target = row.find_element(By.CSS_SELECTOR, ".cell[data-cci='6'] input")
|
||||||
|
|
||||||
if (target.get_attribute('value') == '0'):
|
if (target.get_attribute('value') == '0'):
|
||||||
@@ -755,8 +728,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
button = locate(".text-right li.okki-pagination-next button", condition=None)
|
button = locate(".text-right li.okki-pagination-next button", condition=None)
|
||||||
if button.get_attribute('disabled') is not None and len(ids) < len(positions):
|
if button.get_attribute('disabled') is not None and len(ids) < len(positions):
|
||||||
raise Exception('Product list imcomplete; expected %d, got %d' % (len(positions), len(ids)))
|
raise Exception('Product list imcomplete; expected %d, got %d' % (len(positions), len(ids)))
|
||||||
flow.do(Wait)
|
flow.react(Wait)
|
||||||
flow.react()
|
|
||||||
click(button)
|
click(button)
|
||||||
except Skip:
|
except Skip:
|
||||||
index += 1
|
index += 1
|
||||||
@@ -771,19 +743,16 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
click(".ow-box button.okki-btn-round", wait=False)
|
click(".ow-box button.okki-btn-round", wait=False)
|
||||||
flow.do(Sleep)
|
flow.react(Sleep)
|
||||||
flow.react()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning('Unable to unset additional fees; skipping', exc_info=e)
|
logger.warning('Unable to unset additional fees; skipping', exc_info=e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
flow.do(Wait)
|
flow.react(Wait)
|
||||||
flow.react()
|
|
||||||
flow.allow(Cancel, False)
|
flow.allow(Cancel, False)
|
||||||
flow.allow(Skip, False)
|
flow.allow(Skip, False)
|
||||||
click(".sticky.bottom-0 button.okki-btn-primary", condition=None)
|
click(".sticky.bottom-0 button.okki-btn-primary", condition=None)
|
||||||
flow.do(Sleep)
|
flow.react(Sleep)
|
||||||
flow.react()
|
|
||||||
except Skip:
|
except Skip:
|
||||||
pass
|
pass
|
||||||
except Cancel:
|
except Cancel:
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user