From ea15adf09986d5b65b51fb6d0257e622d3628097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kalinowski?= Date: Sun, 22 Sep 2024 12:59:54 +0200 Subject: [PATCH] Changed error handling, added comments --- .gitignore | 3 +++ README.md | 0 main.py | 11 ++++++++++- requirements.txt | Bin 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 .gitignore mode change 100644 => 100755 README.md mode change 100644 => 100755 main.py mode change 100644 => 100755 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..74da93c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.venv/ +.env +*.crt \ No newline at end of file diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/main.py b/main.py old mode 100644 new mode 100755 index 34c4c63..21e8182 --- a/main.py +++ b/main.py @@ -19,11 +19,16 @@ JIRA_URL = 'https://globaljira.roche.com/rest/api/2/issue/picker' USERNAME = os.getenv("JIRA_USER") PASSWORD = os.getenv("JIRA_PASSWORD") ROOT_CERT = ".\\Roche G3 Root CA.crt" +PRINT_RESPONSE_ON_ERR = False headers = { 'Content-Type': 'application/json' } +# For this query for user kalinom6 there are 6 results, 5 of them are correct, +# but one is certainly not associated with the user in any way according to +# the web application. The result set is lacking too, there should be way +# more issues assigned to this user query = { 'query': f'assignee = {USERNAME} AND status not in (Closed, Done)' } @@ -47,4 +52,8 @@ if response.status_code == 200: print(issues) else: print(f"Failed to execute JQL query. Status code: {response.status_code}") - print("Response:", response.text) \ No newline at end of file + if response.status_code == 403: + print("If you're sure you've set up the environment variables correctly\n \ + Please login to Jira in the browser to solve a CAPTCHA.") + if PRINT_RESPONSE_ON_ERR: + print("Response:", response.text) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt old mode 100644 new mode 100755