]> granicus.if.org Git - icinga2/commitdiff
Exit early in changelog.py if GitHub API fetch fails 5619/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Mon, 25 Sep 2017 14:05:05 +0000 (16:05 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Mon, 25 Sep 2017 14:05:05 +0000 (16:05 +0200)
fixes #5600

changelog.py

index f8cd361c2d91b3d41919fb0b7a86ad7d6f8e0d1b..91a0c26134b129f9308debb9bc0eed8cfd376e88 100755 (executable)
@@ -52,8 +52,8 @@ def fetch_github_resources(uri, params = {}):
         resp = requests.get(url, auth=(github_auth_username, github_auth_token), params=params)
         try:
             resp.raise_for_status()
-        except:
-            break
+        except requests.exceptions.HTTPError as e:
+            raise e
 
         data = resp.json()
 
@@ -115,13 +115,21 @@ def format_title(title):
 
 milestones = {}
 issues = defaultdict(lambda: defaultdict(list))
+project_name = "icinga2"
+
+log(1, "Fetching data from GitHub API for project " + project_name)
 
-log(1, "Fetching data from GitHub API for " + project_name)
+try:
+    tickets = fetch_github_resources("/issues", { "state": "all" })
+except requests.exceptions.HTTPError as e:
+    log(1, "ERROR " + str(e.response.status_code) + ": " + e.response.text)
+
+    sys.exit(1)
 
 clfp = open(changelog_file, "w+")
 
 with open('tickets.pickle', 'wb') as fp:
-    pickle.dump(fetch_github_resources("/issues", { "state": "all" }), fp)
+    pickle.dump(tickets, fp)
 
 with open('tickets.pickle', 'rb') as fp:
     cached_issues = pickle.load(fp)