Last active
January 11, 2019 10:26
-
-
Save minrk/e5073438d944f7c16788afe064246fa8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Script to get watchers/stars/forks for all repos on a github organization | |
Set GITHUB_API_TOKEN environment variable if you are hitting the API rate limit | |
Requires pygithub and Python 3.6: | |
pip install pygithub | |
Usage: | |
python org-activity.py <org-name> | |
e.g. | |
python org-activity.py binder-examples | |
LICENSE: CC-0 or Public Domain | |
""" | |
import os | |
import sys | |
# pip install pygithub | |
from github import Github as GitHub # fix case! | |
def main(org_name): | |
gh = GitHub() | |
if 'GITHUB_API_TOKEN' in os.environ: | |
gh = GitHub(os.environ['GITHUB_API_TOKEN']) | |
else: | |
gh = GitHub() | |
org = gh.get_organization(org_name) | |
totals = { | |
'watchers': 0, | |
'stars': 0, | |
'forks': 0, | |
} | |
print(f"{'repo':40} {'watch'} {'stars'} {'forks'}") | |
for repo in org.get_repos(): | |
print(f"{repo.full_name:40}" | |
f" {repo.watchers_count:5}" | |
f" {repo.stargazers_count:5}" | |
f" {repo.forks_count:5}" | |
) | |
totals['watchers'] += repo.watchers_count | |
totals['stars'] += repo.stargazers_count | |
totals['forks'] += repo.forks_count | |
print("\nTotals:") | |
for key, value in totals.items(): | |
print(f"{key:8}: {value:4}") | |
if __name__ == '__main__': | |
main(sys.argv[1]) |
@npscience yup. The main thing is getting a list of repos to iterate through here. So you can tweak it to take any number of orgs, repo names, etc. e.g. to take a list of jupyterhub/binder
-style full repo names on the command-line:
repo_names = sys.argv[1:]
for repo_name in repo_names:
repo = gh.get_repo(repo_name)
... # same as before
Report for binder-examples as of now (Dec 8, 16:29 CET)
repo watch stars forks
binder-examples/julia-python 2 2 3
binder-examples/requirements 1 1 7
binder-examples/conda 0 0 1
binder-examples/remote_storage 1 1 0
binder-examples/latex 0 0 1
binder-examples/jupyterlab 2 2 5
binder-examples/dockerfile-r 4 4 11
binder-examples/dockerfile-rstudio 20 20 7
binder-examples/python2_runtime 0 0 0
binder-examples/jupyter-extension 5 5 0
binder-examples/python-conda_pip 0 0 1
binder-examples/jupyter-rise 7 7 0
binder-examples/appmode 1 1 0
binder-examples/jupyter-stacks 0 0 1
Totals:
watchers: 43
stars : 43
forks : 37
That's
watchers : +9
stars : +9
forks : +11
since Nov 29 (blog launch on Nov 30)
And jupyterhub (Dec 8, 16:30 CET)
repo watch stars forks
jupyterhub/jupyterhub 2529 2529 571
jupyterhub/configurable-http-proxy 86 86 57
jupyterhub/oauthenticator 103 103 104
jupyterhub/dockerspawner 165 165 137
jupyterhub/sudospawner 13 13 19
jupyterhub/batchspawner 46 46 41
jupyterhub/kubespawner 82 82 59
jupyterhub/ldapauthenticator 38 38 64
jupyterhub/jupyterhub-deploy-docker 142 142 94
jupyterhub/jupyterhub-deploy-teaching 48 48 33
jupyterhub/jupyterhub-tutorial 52 52 21
jupyterhub/jupyterhub-deploy-hpc 11 11 4
jupyterhub/systemdspawner 25 25 10
jupyterhub/wrapspawner 11 11 8
jupyterhub/jupyterlab-hub 32 32 15
jupyterhub/nbserverproxy 2 2 5
jupyterhub/jupyterhub-example-kerberos 11 11 9
jupyterhub/hubshare 32 32 12
jupyterhub/nbrsessionproxy 2 2 10
jupyterhub/tmpauthenticator 1 1 5
jupyterhub/zero-to-jupyterhub-k8s 74 74 47
jupyterhub/helm-chart 20 20 22
jupyterhub/binderhub 177 177 28
jupyterhub/mybinder.org-deploy 5 5 6
jupyterhub/binder 1 1 12
jupyterhub/nullauthenticator 0 0 1
jupyterhub/team-compass 0 0 0
Totals:
watchers: 3708
stars : 3708
forks : 1394
That's
watchers: +97
stars : +97
forks : +16
since Nov 29 (blog launch on Nov 30)
❗ also @minrk, this is the first time I've known how to run a script like this. Thank's for the push! 😄
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And jupyterhub, for good measure: