Ultima attività 8 hours ago

yuanpeng's Avatar yuanpeng ha revisionato questo gist 8 hours ago. Vai alla revisione

1 file changed, 22 insertions

msg_to_slack.py(file creato)

@@ -0,0 +1,22 @@
1 + #!/SNS/users/y8z/miniconda/envs/slack/bin/python
2 + # -*- coding: utf-8 -*-
3 + from slack_sdk import WebClient
4 + import json
5 +
6 + calib_file = "/SNS/PG3/shared/CALIBRATION/cal_config.json"
7 +
8 + with open(calib_file, "r") as f:
9 + calib_config = json.load(f)
10 +
11 + dia_file = calib_config["Diamond"]
12 + out_dir = calib_config["OutputDir"]
13 +
14 + slack_msg = f"Calibration file generated for diamond run `{dia_file}`\n"
15 + slack_msg += f"Check the calibration H5 file "
16 + slack_msg += f"at, `{out_dir}`.\n"
17 + slack_msg += "If not seeing the calibration file, "
18 + slack_msg += "log in Analysis and run `pg3_cal` to "
19 + slack_msg += "prepare the calibration file."
20 + sltk = "xoxb-......" # <= Slack token starting with 'xoxb' goes here
21 + client = WebClient(token=sltk)
22 + client.chat_postMessage(channel="powgen-monitor", text=slack_msg)
Più nuovi Più vecchi