GithubHelp home page GithubHelp logo

tonythomas01 / gdrive-to-commons Goto Github PK

View Code? Open in Web Editor NEW
9.0 4.0 10.0 8.8 MB

Tool to upload pictures from Google Drive to Wikimedia Commons ⚠️ Moved to Wikimedia Gerrit, so this repo is read only.

Home Page: https://gdrive-to-commons.toolforge.org/

License: Apache License 2.0

Python 2.49% HTML 5.63% JavaScript 67.65% CSS 24.14% Shell 0.08%
django django-rest-framework javascript wikimedia-tools wikimedia toolforge oauth google-drive wikimedia-commons wikimedia-developers

gdrive-to-commons's Introduction

Google drive to Wikimedia Commons (Read only)

Please see: https://github.com/wikimedia/labs-tools-gdrive-to-commons

Build Status

This tool is developed to Upload images directly from Google drive to Wikimedia Commons and is currently deployed at Toollabs.

⚠️ Contributing ⚠️

Development and codebase moved to Wikimedia Gerrit. This repo is read only now. Read how to contribute on the Gerrit Tutorial. Thank you!

Dependencies

We use python 3.5.3 on production. Make sure you have this installed on your machine, or use pyenv as described later in this documentation under steps for local development.

Pre-requisites for local development

The tool authenticates to the Wikimedia cluster using Wikimedia OAuth and to Google using Google OAuth. Hence, we need a couple of secret keys in your local_settings.py to start development.

  1. SOCIAL_AUTH_MEDIAWIKI_KEY & SOCIAL_AUTH_MEDIAWIKI_SECRET: You can request for an OAuth client using Wikimedia:OAuth. Once created, you will get both keys. Remember that you set the right Mediawiki OAuth callback URL.
  2. GOOGLE_APP_ID: We need an application running on Google cloud to authorize and access Google drive. You can create your application at Google cloud console. GOOGLE_APP_ID is your project id.
  3. GOOGLE_CLIENT_ID: You can create a new OAuth 2.0 Client at Google cloud credentials.
  4. GOOGLE_API_DEV_KEY: You need to enable the Google Picker API on Google cloud console. Once enabled, a dev key is generated, and you can find it on your Google cloud credentials.

For Wikimedia developers, you can find more information on development keys here

And also, the Google Drive to Wikimedia Commons Developer credentials are provided at the following link: https://phabricator.wikimedia.org/P10014 .
Developers need not create new secret keys and can use the credentials given in the above link as instructed later in this documentation under steps for local development.

Steps for local development

  1. Create a local fork of https://github.com/tonythomas01/gdrive_to_commons using your GitHub account by running the following command in terminal:

    $  git clone https://github.com/username/gdrive-to-commons.git
    
  2. If homebrew is not installed before, install homebrew package manager by following the instructions given in the below link:
    https://docs.brew.sh/Homebrew-on-Linux

  3. Install pyenv and virtual manager by running the following commands in terminal:

    $ brew install pyenv
    $ brew install pyenv-virtualenv
    $ export PATH="$HOME/.pyenv/bin:$PATH"   
    $ eval "$(pyenv init -)"
    $ eval "$(pyenv virtualenv-init -)"
    $ pyenv install 3.5.3
    $ eval "$(pyenv init -)"
    
  4. navigate into the repository by running the following command in terminal:

    $ cd gdrive_to_commons   
    

    Now you are in the gdrive_to_commons directory and all the following commands are run in this directory.

  5. Create pyenv-virtualenv by running the following command in terminal:

    gdrive_to_commons/$ pyenv virtualenv 3.5.3 gdrive-env-3.5.3   
    

    This will create a pyenv-virtualenv for you and probably place it on your ~/home/<username>/.pyenv/versions/.

  6. Activate the virtual environment manually by running the following command:

    gdrive_to_commons/$ source ~/.pyenv/versions/gdrive-env-3.5.3/bin/activate
    

    or even better:

    gdrive_to_commons/$ pyenv activate gdrive-env-3.5.3
    

    or,
    there are better ways to do this if you follow https://github.com/pyenv/pyenv-virtualenv.

    Now you are in the right environment if your terminal shows:

    (gdrive-env-3.5.3) gdrive_to_commons/$
    

    All the following commands are run in this environment and in this directory only.

  7. Install dependencies by running the following command:

    (gdrive-env-3.5.3) gdrive_to_commons/$ pip install -r requirements.txt
    
  8. We use pre-commit hooks to format code. install precommit framework by running the following command: (gdrive-env-3.5.3) gdrive_to_commons/$ pip install pre-commit
    Now, install our pre-commit hooks using: (gdrive-env-3.5.3) gdrive_to_commons/$ pre-commit install

  9. There are some localsettings you need to have as part of running the server. You can copy a template using: (gdrive-env-3.5.3) gdrive_to_commons/$ cp gdrive_to_commons/local_settings_sample.py gdrive_to_commons/local_settings.py
    Few credentials have to be modified in local_setting.py
    The credentials that are to be pasted in the local_settings.py are given in the following link:
    https://phabricator.wikimedia.org/P10014.
    Paste the Google Drive to Wikimedia Commons Dev credentials in local_settings.py

  10. Run the Django standard runserver steps:

(gdrive-env-3.5.3) gdrive_to_commons/$ python manage.py makemigrations
(gdrive-env-3.5.3) gdrive_to_commons/$ python manage.py migrate
(gdrive-env-3.5.3) gdrive_to_commons/$ python manage.py collectstatic
(gdrive-env-3.5.3) gdrive_to_commons/$ python manage.py runserver localhost:8000

or even better, run it from pyCharm using your debugger.

Note: Only paste the command after $ in terminal while setting up and do not paste the whole line which might cause error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.