always hide progress bar even when exceptions are thrown

This commit is contained in:
Nick Sweeting 2019-04-11 03:41:50 -04:00
parent 0272c9b8c0
commit d08978d66c

View file

@ -205,13 +205,17 @@ def write_links_index(links: List[Link], out_dir: str=OUTPUT_DIR, finished: bool
log_indexing_started(out_dir, 'index.json') log_indexing_started(out_dir, 'index.json')
timer = TimedProgress(TIMEOUT * 2, prefix=' ') timer = TimedProgress(TIMEOUT * 2, prefix=' ')
try:
write_json_links_index(links, out_dir=out_dir) write_json_links_index(links, out_dir=out_dir)
finally:
timer.end() timer.end()
log_indexing_finished(out_dir, 'index.json') log_indexing_finished(out_dir, 'index.json')
log_indexing_started(out_dir, 'index.html') log_indexing_started(out_dir, 'index.html')
timer = TimedProgress(TIMEOUT * 2, prefix=' ') timer = TimedProgress(TIMEOUT * 2, prefix=' ')
try:
write_html_links_index(links, out_dir=out_dir, finished=finished) write_html_links_index(links, out_dir=out_dir, finished=finished)
finally:
timer.end() timer.end()
log_indexing_finished(out_dir, 'index.html') log_indexing_finished(out_dir, 'index.html')
@ -247,13 +251,13 @@ def write_json_links_index(links: List[Link], out_dir: str=OUTPUT_DIR) -> None:
"""write the json link index to a given path""" """write the json link index to a given path"""
assert isinstance(links, List), 'Links must be a list, not a generator.' assert isinstance(links, List), 'Links must be a list, not a generator.'
assert isinstance(links[0].history, dict) assert not links or isinstance(links[0].history, dict)
assert isinstance(links[0].sources, list) assert not links or isinstance(links[0].sources, list)
if links[0].history.get('title'): if links and links[0].history.get('title'):
assert isinstance(links[0].history['title'][0], ArchiveResult) assert isinstance(links[0].history['title'][0], ArchiveResult)
if links[0].sources: if links and links[0].sources:
assert isinstance(links[0].sources[0], str) assert isinstance(links[0].sources[0], str)
path = os.path.join(out_dir, 'index.json') path = os.path.join(out_dir, 'index.json')