From 44b7a852857879094017e424312cbdbb1c04ad37 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Wed, 3 Mar 2021 14:07:29 +0100 Subject: [PATCH 1/2] filter empty skylinks --- setup-scripts/blocklist-airtable.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/setup-scripts/blocklist-airtable.py b/setup-scripts/blocklist-airtable.py index aa818886..686e1702 100755 --- a/setup-scripts/blocklist-airtable.py +++ b/setup-scripts/blocklist-airtable.py @@ -36,10 +36,12 @@ async def block_skylinks_from_airtable(): return print(message) or await send_msg(client, message, force_notify=False) data = response.json() - skylinks = skylinks + [entry["fields"].get(AIRTABLE_FIELD, "") for entry in data["records"]] - if len(skylinks) == 0: - return print("Airtable returned 0 skylinks - make sure your configuration is correct") + if len(data["records"]) == 0: + return print("Airtable returned 0 records - make sure your configuration is correct") + + skylinks = skylinks + [entry["fields"].get(AIRTABLE_FIELD, "") for entry in data["records"]] + skylinks = [skylink for skylink in skylinks if skylink] # filter empty skylinks, most likely empty rows offset = data.get("offset") From a16b724583985f3156c3b918e195ef41e4ef4d0f Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Wed, 3 Mar 2021 14:34:27 +0100 Subject: [PATCH 2/2] do not try to attach an empty file --- setup-scripts/bot_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-scripts/bot_utils.py b/setup-scripts/bot_utils.py index 0f317780..9e918955 100644 --- a/setup-scripts/bot_utils.py +++ b/setup-scripts/bot_utils.py @@ -97,7 +97,7 @@ async def send_msg(client, msg, force_notify=False, file=None): # Add the portal name. msg = "**{}**: {}".format(portal_name, msg) - if isinstance(file, str): + if file and isinstance(file, str): is_json = is_json_string(file) content_type = "application/json" if is_json else "text/plain" ext = "json" if is_json else "txt"