Help:Tool Labs/Python application stub

From Wikitech
< Help:Tool Labs(Redirected from Stub)
Jump to: navigation, search

This stub application is designed to get a sample python application installed onto the tools-project as quickly as possible. The application is written in python using the flask framework. The application uses the tool's local mysql database instance whose credentials are located in .my.cnf

  • Login to #wikimedia-labs connect. You don't need IRC to work on tools, but you won't get very far without assistance from other developers.
  • Register for an account on Wikimedia labs
  • After creating an account, you need to request access to one of the projects that will host your tool. Requesting via IRC is probably faster, but you can also follow these instructions. You also need to request which project you want to work on. This guide assumes you will be using the tools project.
  • Once you have received access to your shell, SSH into tools-login.wmflabs.org and make sure you can login.
  • Now you need to create a project in which your application will reside. Go to the projects list (you may have to set the project filter to "tools") and click "Add service group" (top right) and give your project a name and then press submit.
  • Login into tools-login.wmflabs.org and type
become <name of your project>
  • You should now be logged into your project's shell account. Now fire up your favorite text editor and create a file called stubinstall and paste the following code:
prjdir=$HOME
prjdir=${prjdir/\data\/project\//}
prjdir=${prjdir/\//}
prjdir=${prjdir/\//}
rm -rf $prjdir
hg clone https://bitbucket.org/littlegreenrosetta/stub stub
cp ~/stub/setup/wmf/stubinit .
chmod 755 stubinit
./stubinit $prjdir $prjdir
mysql < ~/$prjdir/setup/sql/world.sql
rm stubinit
  • Now modify the file so it can run then start the script.
chmod 755 stubinstall
./stubinstall

The script will download the stub application and set the application up to use the name of your tool. Your tool should now be available at http://tools.wmflabs.org/<app name> (eg. http://tools.wmflabs.org/fubar). You can now modify the python and html files to add functionality to your application.

This application is maintained by little green rosetta (wikipedia-en)

If your application needs third party libraries, pip won't work for you - you are not root. However:

pip install --user yourthirdpartylibrary

will locally install, and that's all you care about anyway.