From 089c78cfaebcfdfaaf662dd1b468fc1731004291 Mon Sep 17 00:00:00 2001 From: luona-dev <132394780+luona-dev@users.noreply.github.com> Date: Mon, 4 Dec 2023 19:39:52 +0100 Subject: [PATCH] fixed connection handling --- assets/guides/formbricks-in-gpts/formbricks_to_gpt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/guides/formbricks-in-gpts/formbricks_to_gpt.py b/assets/guides/formbricks-in-gpts/formbricks_to_gpt.py index 31d9e9d..6729a34 100644 --- a/assets/guides/formbricks-in-gpts/formbricks_to_gpt.py +++ b/assets/guides/formbricks-in-gpts/formbricks_to_gpt.py @@ -7,6 +7,7 @@ def get_surveys(host: str, api_key: str) -> None: Get all surveys from the Formbricks API and save them to surveys.json """ surveys = [] + conn = None try: conn = http.client.HTTPSConnection(host, timeout=10) headers = { @@ -21,7 +22,8 @@ def get_surveys(host: str, api_key: str) -> None: print("Omit the protocol (https://) and the trailing slash (/)") exit(1) finally: - conn.close() + if conn: + conn.close() json.dump(data, open("surveys.json", "w"), indent=4)