From 5d8699e86bb20e72d51e4493f29f30e6fcc560ab Mon Sep 17 00:00:00 2001 From: Jannik Vogel Date: Fri, 25 Nov 2016 01:37:23 +0100 Subject: [PATCH 1/2] Write HTTP status code to log --- tag_build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tag_build.py b/tag_build.py index 95893e4..2043769 100644 --- a/tag_build.py +++ b/tag_build.py @@ -71,13 +71,13 @@ class TagMergeBot: self.current_prs[repo['remote_name']] = [] res = requests.get(GITHUB_API+'/{owner}/{repo}/issues?labels={labels}&per_page=100'.format(labels=LABEL_TO_FETCH, owner=repo['owner'], repo=repo['name'])) if res.status_code != 200: - logger.error("Could not retrive pull requests from github") + logger.error("Could not retrive pull requests from github. Status: {status}".format(status=res.status_code)) return False issues = res.json() for issue in issues: pr_response = requests.get(issue['pull_request']['url']) if res.status_code != 200: - logger.warn("Couldn't fetch the PRs details for PR {pr}".format(pr=issue[''])) + logger.warn("Couldn't fetch the PRs details for PR {pr}. Status: {status}".format(pr=issue[''], status=res.status_code)) continue pr = pr_response.json() self.current_prs[repo['remote_name']].append({"number": pr['number'], "commit": pr['head']['sha'], "ref": pr['head']['ref']}) From a387e6f0e27e6d7c8215eecb9651f5c670d5f5ae Mon Sep 17 00:00:00 2001 From: Jannik Vogel Date: Fri, 25 Nov 2016 13:52:35 +0100 Subject: [PATCH 2/2] Use custom HTTP headers and params for the GitHub API --- tag_build.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tag_build.py b/tag_build.py index 2043769..f433df7 100644 --- a/tag_build.py +++ b/tag_build.py @@ -33,6 +33,14 @@ MAIN_REPO = PULL_REPOS[1] PUSH_REPO = 'git@github.com:citra-emu/citra-bleeding-edge' # PUSH_REPO = 'git@github.com:jroweboy/lemon' +GITHUB_API_HEADERS = { + 'User-Agent': 'citra-emu/lemonbot' +} +GITHUB_API_PARAMS = { + 'client_id': 'xxxx', + 'client_secret': 'yyyy' +} + class TagMergeBot: ''' Fetches all the pull requests on a repository and merges all the pull requests with a specified tag on them. ''' def __init__(self, main_repo, pull_repos, push_repo): @@ -69,13 +77,13 @@ class TagMergeBot: self.current_prs = {} for repo in self.repos: self.current_prs[repo['remote_name']] = [] - res = requests.get(GITHUB_API+'/{owner}/{repo}/issues?labels={labels}&per_page=100'.format(labels=LABEL_TO_FETCH, owner=repo['owner'], repo=repo['name'])) + res = requests.get(GITHUB_API+'/{owner}/{repo}/issues?labels={labels}&per_page=100'.format(labels=LABEL_TO_FETCH, owner=repo['owner'], repo=repo['name']), params=GITHUB_API_PARAMS, headers=GITHUB_API_HEADERS) if res.status_code != 200: logger.error("Could not retrive pull requests from github. Status: {status}".format(status=res.status_code)) return False issues = res.json() for issue in issues: - pr_response = requests.get(issue['pull_request']['url']) + pr_response = requests.get(issue['pull_request']['url'], params=GITHUB_API_PARAMS, headers=GITHUB_API_HEADERS) if res.status_code != 200: logger.warn("Couldn't fetch the PRs details for PR {pr}. Status: {status}".format(pr=issue[''], status=res.status_code)) continue