detecting errors at a higher level to avoid false "in progress" messages

pull/33/head
msramalho 2022-06-14 19:28:34 +02:00
rodzic 06e8781f0f
commit eca10023b0
1 zmienionych plików z 47 dodań i 42 usunięć

Wyświetl plik

@ -80,6 +80,7 @@ def process_sheet(c: Config):
if not is_retry: continue if not is_retry: continue
# All checks done - archival process starts here # All checks done - archival process starts here
try:
gw.set_cell(row, 'status', 'Archive in progress') gw.set_cell(row, 'status', 'Archive in progress')
url = expand_url(url) url = expand_url(url)
c.set_folder(gw.get_cell_or_default(row, 'folder', default_folder, when_empty_use_default=True)) c.set_folder(gw.get_cell_or_default(row, 'folder', default_folder, when_empty_use_default=True))
@ -102,12 +103,7 @@ def process_sheet(c: Config):
try: try:
result = archiver.download(url, check_if_exists=True) result = archiver.download(url, check_if_exists=True)
except KeyboardInterrupt: except KeyboardInterrupt as e: raise e # so the higher level catch can catch it
# catches keyboard interruptions to do a clean exit
logger.warning(f"caught interrupt for {archiver} on {row=}")
gw.set_cell(row, 'status', '')
c.destroy_webdriver()
exit()
except Exception as e: except Exception as e:
result = False result = False
logger.error(f'Got unexpected error in row {row} with {archiver.name} for {url=}: {e}\n{traceback.format_exc()}') logger.error(f'Got unexpected error in row {row} with {archiver.name} for {url=}: {e}\n{traceback.format_exc()}')
@ -127,7 +123,16 @@ def process_sheet(c: Config):
update_sheet(gw, row, result) update_sheet(gw, row, result)
else: else:
gw.set_cell(row, 'status', 'failed: no archiver') gw.set_cell(row, 'status', 'failed: no archiver')
logger.success(f'Finshed worksheet {wks.title}') except KeyboardInterrupt:
# catches keyboard interruptions to do a clean exit
logger.warning(f"caught interrupt on {row=}, {url=}")
gw.set_cell(row, 'status', '')
c.destroy_webdriver()
exit()
except Exception as e:
logger.error(f'Got unexpected error in row {row} for {url=}: {e}\n{traceback.format_exc()}')
gw.set_cell(row, 'status', 'failed: unexpected error (see logs)')
logger.success(f'Finished worksheet {wks.title}')
@logger.catch @logger.catch