From 7779fd2c287cd1709ea2bb02f8cd2fcd3f723012 Mon Sep 17 00:00:00 2001 From: Andreas Lundquist Date: Tue, 6 Jun 2023 12:59:58 +0200 Subject: [PATCH 1/4] Moved from deprecated slack to slack_sdk. --- requirements.txt | 1 + src/util/slack_client.py | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index f90342f..53f9ce8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ slackclient==2.5.0 ansicolors==1.1.8 pytest flake8==5.0.4 +slack_sdk diff --git a/src/util/slack_client.py b/src/util/slack_client.py index a742638..6d4fa55 100644 --- a/src/util/slack_client.py +++ b/src/util/slack_client.py @@ -1,10 +1,11 @@ from src.util.logger import get_logger -import slack -from asyncio import TimeoutError +from slack_sdk import WebClient +from slack_sdk.errors import SlackApiError, SlackClientError import config import socket from src.util.token_config import TokenConfiguredClient, TokenExpiredError + logger = get_logger() hostname = socket.gethostname() @@ -16,7 +17,7 @@ class SlackTokenExpiredError(TokenExpiredError): class SlackClient(TokenConfiguredClient): def __init__(self, token_path, channel_id, timeout=1, token=None): - self.client = slack.WebClient(token, timeout=timeout) + self.client = WebClient(token, timeout=timeout) self.token_path = token_path self.channel_id = channel_id if token: @@ -36,11 +37,9 @@ def _post_message(self, msg): link_names=True) if not response['ok']: logger.error(f'Slack error, response = {response}') - except TimeoutError: - logger.error("Slack request timed out.") - except slack.errors.SlackApiError as e: + except SlackApiError as e: raise SlackTokenExpiredError(str(e)) - except slack.errors.SlackClientError as e: + except SlackClientError as e: logger.exception(f'Slack error, error = {e}') @TokenConfiguredClient.require_configured_factory() From c4f35e8f3b092de92c7276c01171cc0c3be9b4ae Mon Sep 17 00:00:00 2001 From: Erasmus Cedernaes Date: Wed, 7 Jun 2023 23:02:08 +0200 Subject: [PATCH 2/4] Remove slackclient requirement --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 53f9ce8..70ed1d1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,6 @@ python-dateutil==2.8.0 qrcode[pil]==6.1 requests==2.21.0 pyserial==3.4 -slackclient==2.5.0 ansicolors==1.1.8 pytest flake8==5.0.4 From 535e63ae744e4a78a9c071111ef839b6e6552634 Mon Sep 17 00:00:00 2001 From: InMyOrbit Date: Thu, 8 Jun 2023 21:46:47 +0200 Subject: [PATCH 3/4] Add explicit version of slack_sdk Co-authored-by: Erasmus Cedernaes --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 70ed1d1..2df4060 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,4 @@ pyserial==3.4 ansicolors==1.1.8 pytest flake8==5.0.4 -slack_sdk +slack_sdk=3.21.3 From 958b7566c080b6b8fe5e8be0b19760e11019c6d8 Mon Sep 17 00:00:00 2001 From: InMyOrbit Date: Thu, 8 Jun 2023 21:49:58 +0200 Subject: [PATCH 4/4] Updated requirements.txt with explicit version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 2df4060..4bbaf02 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,4 @@ pyserial==3.4 ansicolors==1.1.8 pytest flake8==5.0.4 -slack_sdk=3.21.3 +slack_sdk==3.21.3