From 79fa9080ff543ff82d140ac901cc6a36abe35e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Chali=C5=84ski?= Date: Fri, 2 Feb 2024 16:51:27 +0100 Subject: [PATCH 1/2] add try catch --- scripts/python/get_author_origin.py | 14 +++++++++----- scripts/python/get_ticket_id.py | 14 ++++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/scripts/python/get_author_origin.py b/scripts/python/get_author_origin.py index 2f8eb6bd7..9f0843618 100644 --- a/scripts/python/get_author_origin.py +++ b/scripts/python/get_author_origin.py @@ -3,10 +3,14 @@ membrane_team = json.load(sys.stdin) pr_author = sys.argv[1] -for person in membrane_team: - if person["login"] == pr_author: - print("MEMBRANE") - sys.exit(0) +try: + for person in membrane_team: + if person["login"] == pr_author: + print("MEMBRANE") + sys.exit(0) -print("COMMUNITY") + print("COMMUNITY") +except: + print("An exception occurred, provided JSON:") + print(membrane_team) diff --git a/scripts/python/get_ticket_id.py b/scripts/python/get_ticket_id.py index 9ac65b1de..97e8c03f2 100644 --- a/scripts/python/get_ticket_id.py +++ b/scripts/python/get_ticket_id.py @@ -1,6 +1,12 @@ import sys, json; -project_items = json.load(sys.stdin)["items"] -pr_url = sys.argv[1] -[id] = [item["id"] for item in project_items if ("url" in item["content"] and item["content"]["url"] == pr_url)] -print(id) +full_json = json.load(sys.stdin) + +try: + project_items = full_json["items"] + pr_url = sys.argv[1] + [id] = [item["id"] for item in project_items if ("url" in item["content"] and item["content"]["url"] == pr_url)] + print(id) +except: + print("An exception occurred, provided JSON:") + print(full_json) \ No newline at end of file From acdeccad57685498305fe8e123dfb15b40313f9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Chali=C5=84ski?= Date: Fri, 2 Feb 2024 17:05:15 +0100 Subject: [PATCH 2/2] more debug prints --- scripts/python/get_author_origin.py | 2 +- scripts/python/get_ticket_id.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/python/get_author_origin.py b/scripts/python/get_author_origin.py index 9f0843618..0ff857386 100644 --- a/scripts/python/get_author_origin.py +++ b/scripts/python/get_author_origin.py @@ -13,4 +13,4 @@ except: print("An exception occurred, provided JSON:") print(membrane_team) - + print("provided PR_AUTHOR:", pr_author) \ No newline at end of file diff --git a/scripts/python/get_ticket_id.py b/scripts/python/get_ticket_id.py index 97e8c03f2..d0eb92104 100644 --- a/scripts/python/get_ticket_id.py +++ b/scripts/python/get_ticket_id.py @@ -1,12 +1,13 @@ import sys, json; full_json = json.load(sys.stdin) +pr_url = sys.argv[1] try: project_items = full_json["items"] - pr_url = sys.argv[1] [id] = [item["id"] for item in project_items if ("url" in item["content"] and item["content"]["url"] == pr_url)] print(id) except: print("An exception occurred, provided JSON:") - print(full_json) \ No newline at end of file + print(full_json) + print("provided PR_URL:", pr_url) \ No newline at end of file