From d3fbf39060464f9140d9225562e2b7d9adf4a50a Mon Sep 17 00:00:00 2001 From: Kelley Spoon Date: Mon, 9 Aug 2021 18:11:52 -0500 Subject: sync_github_changes.py: For some reason, a few of these projects are returning a 404 whenever you attempt to list pull requests through the API. We should avoid exiting and instead gracefully continue execution so we don't changes from other projects. Change-Id: I5ffeafc1587a5888640f50bbc89acbbc5fd26ab2 --- linaro_metrics/sync_github_changes.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/linaro_metrics/sync_github_changes.py b/linaro_metrics/sync_github_changes.py index 682b22f..33d41be 100755 --- a/linaro_metrics/sync_github_changes.py +++ b/linaro_metrics/sync_github_changes.py @@ -113,9 +113,15 @@ def _get(url): try: return urllib2.urlopen(request) except urllib2.HTTPError as e: + error_code = e.getcode() log.error('HTTP_%d while GETing %s:\n %s', - e.getcode(), url, e.readlines()) - sys.exit(1) + error_code, url, e.readlines()) + # 404 not found shouldn't be fatal.. make this + # a list in case there are others + if error_code in [404]: + return None + else: + sys.exit(1) def get_pull_requests(owner, repo, last_update=None): @@ -124,6 +130,8 @@ def get_pull_requests(owner, repo, last_update=None): url = url % (owner, repo) while url: resp = _get(url) + if resp is None: + return data = json.loads(resp.read()) for x in data: ts = datetime.strptime(x['updated_at'], '%Y-%m-%dT%H:%M:%SZ') -- cgit v1.2.3