def index(): if "g" in flask.session: user = github.current_user() flask.session["e"] = user["email"] orgs = github.orgs() org_repos = [github.repos(org=org["login"]) for org in orgs] return flask.render_template("index_logged_in.html", user=user, repos=github.repos(), orgs=orgs, org_repos=org_repos) return flask.render_template("index.html", auth_url=github.auth_url())
def _do_next_repo(attempts=0) -> int: if attempts > MAX_GET_REPO_ID: raise GithubError( "Exceeded max num of attempts to find repo without error, stopping" ) repo_id_from_queue = db.get_next_repo_from_queue() if not repo_id_from_queue: largest_id = db.largest_repo_id() logging.info( "No repo in progress or in queue, getting listing from id = {}". format(largest_id)) repos = github.repos(largest_id) db.add_repos_to_queue(repos.data) repo_id_from_queue = db.get_next_repo_from_queue() logging.info("Got repo id {}, removing from queue and processing".format( repo_id_from_queue)) repo = github.repo(repo_id_from_queue) if repo.rate_limit_hit(): sleep_until_rate_reset() return if repo.error: logging.exception("Failed to get repo due to API error") logging.info( "Repo {} has access blocked, skipping".format(repo_id_from_queue)) db.remove_repo_from_queue(repo_id_from_queue) db.add_failed_repo(repo_id_from_queue, repo.request_log_id) return _do_next_repo(attempts + 1) db.insert_repo(repo.data) db.remove_repo_from_queue(repo_id_from_queue) return repo.data["id"]
async def test_all_repos(exec): all_repos = gh.repos() if live: repos = await exec(all_repos) assert isinstance(repos, list) assert len(repos) > 1 assert isinstance(repos[0], gh.RepoSummary)
def main(): for repo in github.repos(github_username): backup(repo)
def repo_data(name, org_name=None): for r in github.repos(org_name): if r["name"] == name: return r return None
import pytest import snug import github as gh from snug.utils import replace CRED_PATH = Path('~/.snug/github.json').expanduser() auth = tuple(json.loads(CRED_PATH.read_bytes())) resolve = partial(gh.resolve, auth=auth) all_orgs = gh.orgs() one_org = gh.org('github') one_repo = gh.repo(owner='github', name='hub') all_repos = gh.repos() assigned_issues = gh.issues() current_user = gh.current_user() my_issues = current_user.issues() repo_issues = one_repo.issues() one_repo_issue = one_repo.issue(123) one_repos_fixed_bugs = replace(repo_issues, labels='bug', state='closed') live = pytest.config.getoption('--live') def test_all_orgs(): assert isinstance(all_orgs, snug.Query)