GitHub Basics

This notebook is a starter notebook for finding information about repositories that are managed by the Jupyter team.


In [ ]:
import github3
import json
from os.path import join
import pprint
import requests
from urllib.parse import urljoin

GitHub Authorization

Note: Be careful. Don't check in to version control your username and password.


In [ ]:
TOKEN=''
gh = github3.login(token=TOKEN)
type(gh)

Basic API request


In [ ]:
url = 'https://api.github.com/orgs/jupyterhub/repos'

response = requests.get(url)
if response.status_code != 200:
    # This means something went wrong.
    raise ApiError('GET /orgs/ {}'.format(resp.status_code))

repos = response.json()
pprint.pprint(repos)

In [ ]:
print('The total number of repos in the organization is {}'.format(len(repos)))

In [ ]:
# print repos
print('{0:30s}      {1:20s}\n'.format('Repository name', 'open_issues_count'))

for num in range(0, len(repos)):
    print('{0:30s}      {1:4d}\n'.format(repos[num]['name'],  repos[num]['open_issues_count']))

In [ ]:
for num in range(0, len(repos)):
    print('{0:30s}      {1:50s}\n'.format(repos[num]['name'], repos[num]['description']))

In [ ]:
print('{0:30s}      {1:20s}\n'.format('Repository name', 'open_issues_count'))

for num in range(0, len(repos)):
    print('{0:30s}      {1:4d}  {2:20s}\n'.format(repos[num]['name'], repos[num]['open_issues_count'], repos[num]['description']))

Issues in an organization's repos


In [ ]:
def get_issues(my_org, my_repo):
    for issue in gh.iter_repo_issues(owner=my_org, repository=my_repo):
        print(issue.number, issue.title)

In [ ]:
my_org = 'jupyterhub'
my_repo = 'configurable-http-proxy'
get_issues(my_org, my_repo)

In [ ]:
my_org = 'jupyterhub'
my_repo = 'jupyterhub'
get_issues(my_org, my_repo)

In [ ]:
subgroup={'authenticators':['oauthenticator', 'ldapauthenticator'],
         'spawners':['dockerspawner', 'sudospawner', 'kubespawner', 'batchspawner', 'wrapspawner', 'systemdspawner'],
         'deployments':['jupyterhub-deploy-docker', 'jupyterhub-deploy-teaching', 'jupyterhub-deploy-hpc', 'jupyterhub-example-kerberos'],
         'fundamentals':['jupyterhub', 'configurable-http-proxy', 'hubshare', 'jupyterhub-labextension'],
         'community':['jupyterhub-tutorial', 'jupyterhub-2016-workshop'],
        }

In [ ]:
print(subgroup['authenticators'])

In [ ]:


In [ ]: