Naposledy aktivní 7 hours ago

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