def dump_via_slack(args, stats): slack_msg = Slack(MSG_HOOK) slack_msg.add_header(f"{args.run_name}") slack_msg.add_block(f"Anvill Version: ```{VERSION}```") slack_msg.add_divider() with StringIO() as stat_msg: stats.print_stats(stat_msg) slack_msg.add_block(stat_msg.getvalue()) slack_msg.add_divider() with StringIO() as fail_msg: max_num_fails = 10 slack_msg.add_block(f"Top {max_num_fails}:") stats.print_fails(fail_count=max_num_fails, output=fail_msg) fail_output = fail_msg.getvalue() if fail_output: slack_msg.add_block(fail_output) else: slack_msg.add_block("<None>") slack_msg.post()
for _ in p.imap_unordered(apply_rellic, enumerate(sources)): pbar.update() rellic_stats.set_stat("end_time", str(datetime.now())) max_num_fails = 10 outpath = dest_path.joinpath("stats.json") rellic_stats.save_json(outpath) rellic_stats.print_stats() rellic_stats.print_fails(fail_count=max_num_fails) # validity of msg_hook checked earlier if args.slack_notify: slack_msg = Slack(msg_hook) slack_msg.add_header(f"{args.run_name}") slack_msg.add_block(f"Rellic Version: ```{version}```") slack_msg.add_divider() with StringIO() as stat_msg: rellic_stats.print_stats(stat_msg) slack_msg.add_block(stat_msg.getvalue()) slack_msg.add_divider() with StringIO() as fail_msg: slack_msg.add_block(f"Top {max_num_fails}:") rellic_stats.print_fails(fail_count=max_num_fails, output=fail_msg) slack_msg.add_block(fail_msg.getvalue()) slack_msg.post()