Integrate openhub APIs with Django
The full documentation is at https://openhub-django.readthedocs.io.
- Install openhub-django:
pip install openhub-django
- Add it to your
INSTALLED_APPS
:
INSTALLED_APPS = (
...
'openhub_django.apps.OpenhubDjangoConfig',
...
)
- Add openhub-django's URL patterns:
urlpatterns = [
...
url(r'^', include('openhub_django.urls')),
...
]
Configure following environment variables:
OpenHub Token
How to get OpenHub Token?
- Signup with GitHub on OpenHub
- Go to your profile settings to create a new API Key.
- Choose "API Keys" from the section and create a new one by clicking on button "Request New API Key"
- Fill in the required fields and Save it.
- Copy the
API Key
for the generated token to add it to your environment.
Add it to your Linux (or Ubuntu) environment-
- Open the terminal and run cat ~/.bashrc.
- Find this peice of code
if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi
- In this case we will create a new file in
$HOME
directory named.bash_aliases
to store our environment variables. As it will execute everytime we open a new terminal window.
vi ~/.bash_aliases
- Enter into the insert mode and add the value of token that you generated from OpenHub settings.
export OH_TOKEN=<PASTE THE COPIED API KEY OF TOKEN>
- Exit the insert mode by pressing
esc
key and the editor. - Restart your terminal and run
printenv
to verify the API Key added.
Organization name
Set the environment variable
ORG_NAME
following the above mentioned steps like you did adding the environment variableOH_TOKEN
. Once you setup these two environment variables, you're ready to run a management command to fetch the organization related information from OpenHub.
Run management command
python manage.py migrate
python manage.py import_openhub_data
- View the fetched data:
python manage.py runserver
# Open http://127.0.0.1:8000/openhub/ in browser
- Import all the organization portfolio projects data
- Import all the organization outside projects data such as dependencies
- Import all the affiliated committers data who made contributions to the projects
- Import all the outside committers data
- Import the organization related information
- Generate the static web-pages of all the imported data with an interactive UI/UX design.
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Tools used in rendering this package: