def recover_restart(self): access_token = self.vault_client.get_secret(path="access_token") bot_token = self.vault_client.get_secret(path="bot_token") if access_token and bot_token: self.slack_client = Client(access_token=access_token, bot_token=bot_token) release_tracker = ReleaseTracker(slack_client=self.slack_client, db_client=self.db_client, vault_client=self.vault_client) release_tracker.restart_tracking(self.polling_time)
def handle_release_track_callback(self, request_form=None): payload = json.loads(request_form.get("payload")) release_id = payload["actions"][0]["selected_options"][0]["value"] release_tracker = ReleaseTracker(slack_client=self.slack_client, db_client=self.db_client, vault_client=self.vault_client) release_tracker.send_release_track_message(user=payload["user"], channel=payload["channel"], release_id=release_id, ts=payload["message_ts"]) tracker_thread = threading.Thread(target=release_tracker.track_release, args=(payload["user"], payload["channel"], release_id, self.polling_time)) tracker_thread.start()
def handle_track_release_command(self, request_form=None): user_id = request_form.get('user_id') channel_id = request_form.get('channel_id') release_tracker = ReleaseTracker(slack_client=self.slack_client, db_client=self.db_client, vault_client=self.vault_client) try: release_tracker.show_releases(user_id=user_id, channel_id=channel_id) except Exception: self.logger.exception("Can not retrieve releases.") self.slack_client.post_ephemeral( channel=request_form.get('channel_id'), user=request_form.get('user_id'), kwargs=get_general_error())
def recover_restart(self): self.logger.info("Enter recover_restart") try: access_token = self.vault_client.get_secret(path="access_token") self.logger.debug("recover_restart access_token = %s" % access_token) bot_token = self.vault_client.get_secret(path="bot_token") self.logger.debug("recover_restart bot_token = %s" % bot_token) except: self.logger.error("recover_restart -> Missing Property") return if access_token and bot_token: self.slack_client = Client(access_token=access_token, bot_token=bot_token) release_tracker = ReleaseTracker(slack_client=self.slack_client, db_client=self.db_client, vault_client=self.vault_client) release_tracker.restart_tracking(self.polling_time)
def handle_track_release_command(self, request_form=None): user_id = request_form.get('user_id') channel_id = request_form.get('channel_id') release_tracker = ReleaseTracker(slack_client=self.slack_client, db_client=self.db_client, vault_client=self.vault_client) try: release_tracker.show_releases(user_id=user_id, channel_id=channel_id) except Exception: self.logger.exception("Can not retrieve releases.") msg = get_general_error() msg['token'] = self.vault_client.get_secret(path="bot_access_token") msg['channel'] = request_form.get('channel_id') msg['user'] = request_form.get('user_id') msg['attachments'] = [] if "text" not in msg: msg["text"] = "Can not retrieve releases." self.slack_client.post_ephemeral(message=msg)
def handle_release_create_callback(self, request_form=None): payload = json.loads(request_form.get("payload")) release_helper = ReleaseHelper(slack_client=self.slack_client, db_client=self.db_client, vault_client=self.vault_client) release = release_helper.create_release(user=payload["user"], channel=payload["channel"], data=payload["submission"]) if release.status_code == 200: release_data = release.json() release_tracker = ReleaseTracker(slack_client=self.slack_client, db_client=self.db_client, vault_client=self.vault_client) tracker_thread = threading.Thread(target=release_tracker.track_release, args=(payload["user"], payload["channel"], release_data["id"], self.polling_time)) tracker_thread.start()