From 81b1984c2f1d1513d0a6d1d1eed9b3dcef33009f Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Tue, 1 Feb 2022 23:48:54 +0100 Subject: Show which requests fail at startup --- wee_slack.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wee_slack.py b/wee_slack.py index 98f0c0b..4d0ff63 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1544,7 +1544,7 @@ class SlackTeam(object): users, bots, channels, - **kwargs + **kwargs, ): self.slack_api_translator = copy.deepcopy(SLACK_API_TRANSLATOR) self.identifier = team_info["id"] @@ -6749,12 +6749,13 @@ def initiate_connection(token): "prefs": False, "presence": False, }, + "errors": [], } def handle_initial(data_type): def handle(response_json, eventrouter, team, channel, metadata): if not response_json["ok"]: - initial_data["error"] = response_json["error"] + initial_data["errors"].append(f'{data_type}: {response_json["error"]}') initial_data["complete"][data_type] = True create_team(token, initial_data) return @@ -6769,7 +6770,7 @@ def initiate_connection(token): def handle_prefs(response_json, eventrouter, team, channel, metadata): if not response_json["ok"]: - initial_data["error"] = response_json["error"] + initial_data["errors"].append(f'prefs: {response_json["error"]}') initial_data["complete"]["prefs"] = True create_team(token, initial_data) return @@ -6780,7 +6781,7 @@ def initiate_connection(token): def handle_getPresence(response_json, eventrouter, team, channel, metadata): if not response_json["ok"]: - initial_data["error"] = response_json["error"] + initial_data["errors"].append(f'presence: {response_json["error"]}') initial_data["complete"]["presence"] = True create_team(token, initial_data) return @@ -6835,11 +6836,11 @@ def initiate_connection(token): def create_team(token, initial_data): if all(initial_data["complete"].values()): - if "error" in initial_data: + if initial_data["errors"]: w.prnt( "", "ERROR: Failed connecting to Slack with token {}: {}".format( - token_for_print(token), initial_data["error"] + token_for_print(token), ", ".join(initial_data["errors"]) ), ) if not re.match(r"^xo\w\w(-\d+){3}-[0-9a-f]+(:.*)?$", token): -- cgit