From a8b8965d960db4a47024e01f4aec27b782d5f3dd Mon Sep 17 00:00:00 2001 From: Shinwell Hu Date: Thu, 29 Oct 2020 05:33:46 +0000 Subject: [PATCH] fix rate limite issue with gitee GET --- advisors/gitee.py | 13 ++++++++++--- advisors/review_tool.py | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/advisors/gitee.py b/advisors/gitee.py index 14dab428..75e771b3 100755 --- a/advisors/gitee.py +++ b/advisors/gitee.py @@ -164,14 +164,21 @@ class Gitee(): """ GET from gitee api """ + if '?' in url: + new_url = url + "&" + else: + new_url = url + "?" + new_url = new_url + "access_token=" + self.token["access_token"] if headers is None: - req = urllib.request.Request(url=url, headers=self.headers) + req = urllib.request.Request(url=new_url, headers=self.headers) else: - req = urllib.request.Request(url=url, headers=headers) + req = urllib.request.Request(url=new_url, headers=headers) try: result = urllib.request.urlopen(req) return result.read().decode("utf-8") - except urllib.error.HTTPError: + except urllib.error.HTTPError as error: + print("get_gitee failed to access: %s" % (url)) + print("get_gitee failed: %d, %s" % (error.code, error.reason)) return None def get_pr(self, repo, num, owner="src-openeuler"): diff --git a/advisors/review_tool.py b/advisors/review_tool.py index cea2a251..5d049c97 100755 --- a/advisors/review_tool.py +++ b/advisors/review_tool.py @@ -662,8 +662,8 @@ def main(): user_gitee = gitee.Gitee() pull_request = user_gitee.get_pr(repo_name, pull_id, group) if not pull_request: - print("Failed to get PR:%s of repository:%s, make sure the PR is exist."\ - % (pull_id, repo_name)) + print("Failed to get PR:%s of repository:%s/%s, make sure the PR is exist."\ + % (pull_id, group, repo_name)) sys.exit(1) if args.edit and args.status: edit_review_status(args, user_gitee, group, repo_name, pull_id) -- Gitee