in dev/merge_spark_pr.py [0:0]
def get_json(url):
try:
request = Request(url)
if GITHUB_OAUTH_KEY:
request.add_header("Authorization", "token %s" % GITHUB_OAUTH_KEY)
return json.load(urlopen(request))
except HTTPError as e:
if "X-RateLimit-Remaining" in e.headers and e.headers["X-RateLimit-Remaining"] == "0":
print_error(
"Exceeded the GitHub API rate limit; see the instructions in "
+ "dev/merge_spark_pr.py to configure an OAuth token for making authenticated "
+ "GitHub requests."
)
elif e.code == 401:
print_error(
"GITHUB_OAUTH_KEY is invalid or expired. Please regenerate a new one with "
+ "at least the 'public_repo' scope on https://github.com/settings/tokens and "
+ "update your local settings before you try again."
)
else:
print_error("Unable to fetch URL, exiting: %s" % url)
sys.exit(-1)