Help:Tool Labs/Python application stub

From Wikitech
< Help:Tool Labs(Redirected from Flask-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

General getting started steps

It has been suggested that this page should be merged with a General-purpose tool labs guide somewhere

  • You don't need IRC to work on tools, but you won't get very far without assistance from other developers. So join #wikimedia-labs connect.
  • create a Labs account
  • 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 need to specify 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 and make sure you can login.
  • Now you need to create a project on tool labs 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] next to the "tools" heading to (top right) and give your project a name and then press submit.
  • ssh, login, then enter become name_of_your_project
  • You should now be logged into your project's shell account.

Python-specific steps

Now fire up your favorite text editor and create a file called stubinstall and paste the following code:

rm -rf $prjdir  <-- VERY BAD IDEA to put this in the middle of a temporary script and tell users to run it!
hg clone 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

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<app name> (eg. 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.