hound: allow setting github token
avoid rate limits
This commit is contained in:
parent
9684e8b7c3
commit
68ce9bac95
1 changed files with 9 additions and 1 deletions
|
@ -2,9 +2,12 @@
|
||||||
#!nix-shell -i python3 -p python3Packages.python -p python3Packages.requests
|
#!nix-shell -i python3 -p python3Packages.python -p python3Packages.requests
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
github_token = os.environ.get("GITHUB_TOKEN")
|
||||||
|
|
||||||
disallowed_repos = [
|
disallowed_repos = [
|
||||||
"NixOS/nixops-dashboard", # empty repo causes an error
|
"NixOS/nixops-dashboard", # empty repo causes an error
|
||||||
]
|
]
|
||||||
|
@ -27,7 +30,12 @@ def all_for_org(org):
|
||||||
|
|
||||||
next_url = "https://api.github.com/orgs/{}/repos".format(org)
|
next_url = "https://api.github.com/orgs/{}/repos".format(org)
|
||||||
while next_url is not None:
|
while next_url is not None:
|
||||||
repo_resp = requests.get(next_url)
|
|
||||||
|
if github_token is not None:
|
||||||
|
headers = {"Authorization": f"token {github_token}"}
|
||||||
|
repo_resp = requests.get(next_url, headers=headers)
|
||||||
|
else:
|
||||||
|
repo_resp = requests.get(next_url)
|
||||||
|
|
||||||
if "next" in repo_resp.links:
|
if "next" in repo_resp.links:
|
||||||
next_url = repo_resp.links["next"]["url"]
|
next_url = repo_resp.links["next"]["url"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue