def write_stage_alerts(stage, path, alerts_file="alerts.list"):
alerts = load_alerts()
out_file = os.path.join(path, alerts_file)
if not os.path.exists(path):
os.makedirs(path)
out_handle = open(out_file, "w")
keys = ["metric", "threshold", "compare", "action", "message"]
if not alerts.has_key(stage):
martian.throw("No alerts found for stage %s" % stage)
for alert in alerts[stage]:
out_handle.write("#\n")
out_handle.write(alert["metric"]+"\n")
out_handle.write(str(alert["threshold"])+"\n")
out_handle.write(alert["compare"]+"\n")
out_handle.write(alert["action"]+"\n")
out_handle.write(alert["message"]+"\n")
out_handle.close()
评论列表
文章目录