Skip to content

Commit

Permalink
Do not print all crawler names in case of errors.
Browse files Browse the repository at this point in the history
Also move the error notification to the end so that we can print the
exceptions in a nicer format.
  • Loading branch information
m-appel committed Sep 3, 2024
1 parent c71463b commit a0eafdf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion autodeploy/autodeploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def check_log(config: dict, date: datetime):
return False
body = r.content
last_line = body.decode().split('\n')[-1]
if 'Errors:' in last_line:
if 'errors' in last_line:
logging.error(f'There were errors from create_db found in logs for {log_url}')
sys.exit(1)
return True
Expand Down
13 changes: 9 additions & 4 deletions create_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

NEO4J_VERSION = '5.16.0'

STATUS_OK = 'OK'


def main():
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -131,7 +133,7 @@ def __init__(self, message):
if not passed:
error_message = f'Did not receive data from crawler {name}'
raise RelationCountError(error_message)
status[module_name] = 'OK'
status[module_name] = STATUS_OK
logging.info(f'end {module}')
except RelationCountError as relation_count_error:
no_error = False
Expand All @@ -155,7 +157,7 @@ def __init__(self, message):
post = module.PostProcess()
post.run()
post.close()
status[module_name] = 'OK'
status[module_name] = STATUS_OK
logging.info(f'end {module}')

except Exception as e:
Expand Down Expand Up @@ -200,14 +202,17 @@ def __init__(self, message):
# TODO send an email

# Add the log line to indicate to autodeploy that there were errors
final_words = f'\nErrors: {" ".join((k for k in status))}'
logging.error('There were errors!')
final_words = '\nErrors: '
for module, status in status.items():
if status != STATUS_OK:
final_words += f'\n{module}: {status}'
else:
final_words = 'No error :)'
# Delete tmp file in cron job
# shutil.rmtree(tmp_dir)

logging.info(f'Finished: {sys.argv} {final_words}')
logging.error('There were errors!')

if args.archive:
# Push the dump and log to ihr archive
Expand Down

0 comments on commit a0eafdf

Please sign in to comment.