User:Danmichaelo
Appearance
- SUL: Danmichaelo
Toolserver: tools:~danmichaelo- Tools on labs: UKBot
- Help:Access#Accessing_instances_with_a_graphical_file_manager
- Nova Resource:Tools/Help
- User:Russell_Blau/Using_pywikibot_on_Labs
Checklist setting up a new python project
- Create a new project at Special:NovaServiceGroup using "Add service group".
- Wait a few
minutesseconds, log out and in again, type become <projectname> - vim .description and add a short description that will show up on tools.wmflabs.org. You can use html syntax to add links.
- Setup a virtual environment for python: virtualenv ENV
- Activate it: source ENV/bin/activate
- Install latest mwclient: pip install git+git://github.com/mwclient/mwclient.git
- vim .profile and add the following:
# Detect if we have an interactive shell
case "$-" in
*i*) export INTERACTIVE=yes ;;
*) unset INTERACTIVE ;;
esac
# Say hello
test -n "$INTERACTIVE" && {
echo "Hello ${SUDO_USER}!"
}
# Load user's environment
test -f /home/${SUDO_USER}/.profile && {
echo "✔ Loading your .profile"
. /home/${SUDO_USER}/.profile
}
test -f /home/${SUDO_USER}/.vimrc && {
echo "✔ Aliasing vim to use your .vimrc"
# alias vim="vim -u ~${SUDO_USER}/.vimrc --cmd 'set rtp^=~${SUDO_USER}/.vim'"
alias vim="HOME=/home/$SUDO_USER vim"
}
# Activate virtualenv
test -d ENV && {
test -n "$INTERACTIVE" && echo "✔ Activating virtualenv"
. ENV/bin/activate
}
# Check gitconfig
test -n "$INTERACTIVE" && {
alias git="HOME=/home/$SUDO_USER git"
if [ ! -r /home/$SUDO_USER/.gitconfig ]
then
echo Please set git user and e-mail *in your own \$HOME* before running git
echo in this project. In addition, make sure this tool user can read your
echo ~/.gitconfig.
echo
echo "The following should work (remember: as your own user!)"
echo git config --global user.name "My Username"
echo git config --global user.email "my@email"
echo chmod 644 \~/.gitconfig
echo chmod +x \~
echo
fi
}
# Show running jobs
test -n "$INTERACTIVE" && qstat
- vim .inputrc and add the following:
# Up arrow
"\e[A": history-search-backward
# Down arrow
"\e[B": history-search-forward
- Setup git repo:
- git init
- git remote add origin <repo>
- Ctrl-D to become yourself again (if you need your own private key, etc..)
- cd to the project folder and git pull origin master
- Check that files are group-writable
- Configure uwsgi: vim uwsgi.ini and add the following: (replacing TOOLNAME with the name of the tool)
[uwsgi]
plugin = python3
socket = /data/project/TOOLNAME/TOOLNAME.sock
chdir = /data/project/TOOLNAME/www/python/src
venv = /data/project/TOOLNAME/www/python/venv
module = app
callable = app
manage-script-name = true
mount = /TOOLNAME=app:app
single-interpreter = true
- Start webserver: webservice --backend=gridengine uwsgi-plain start