Sunday, July 17, 2011

bye bye launchpad

I'm starting to move most of my projects off launchpad onto bitbucket.

launchpad just hasn't gone in the direction that is useful for me, or my projects.

It still has some nice features, such as packaging farms (PPAs) and of course bzr integration. However, github and bitbucket have just been moving more towards making it easy for developers compared to launchpad which is more geared towards for distributors who work with an upstream. Last year I hoped launchpad would improve after it went open source, and it has improved. Just not really in the direction useful for my projects.

Many people these days are able to use hg, or git... but still very many people have never even heard of bzr. I feel bzr+launchpad was holding one project back a little from gaining collaborators because of this. By that logic, I should be using svn for it... but I don't want to do that :)

The documentation to convert repositories to mecurial is on the hg wiki. The conversion seems to mostly have worked ok for me on my python newsletter project. Except it did not put the correct email address attached to each of the commits. Oh well.

Monday, July 04, 2011 opengl shading language toy shader

A couple of months ago I made a python port of the WebGL shadertoy. The shadertoy website is written in JavaScript and the opengl shading language.

Here is the python port:

Maybe it'll be useful for someone learning shading languages through python. Or not.

It's a fun demo anyway. Press the 'Anykey' to change between shader. You'll find the 'Anykey' on your keyboard. If the Anykey you press is Escape, then the program will 'quit'.

Requires 1 tsp of pygame, and a cup of pyopengl.

Saturday, July 02, 2011

cherrypy daemontools

Cherrypy and daemontools work nicely together. However, I have not found any instructions on how to use them together on the interwebs... so I've written up some basic notes for people who love cherrypy and daemontools.

daemontools is a collection of tools for managing UNIX services. It can be used to automatically start, and restart processes on a unix system.

The instructions to run services in daemontools are here: I'm assuming you have daemontools set up already.

Cherrypy is a python library for making website applications. There are many ways to deploy cherrypy apps, but I will describe how to deploy cherrypy apps with daemontools.

Firstly, you do not need the cherryd tool to use with daemontools. Daemontools does the daemonising for you. But cherryd can be used if you want, since it provides some nice options (just don't use the -d daemonize flag). You may want to use cherryd with daemontools if you'd like to use FastCGI or SCGI. I won't cover cherryd any further in this post.

I'll now show you how to setup daemontools for an example cherrypy application.

Here is a normal helloworld cherrypy app... which I'll put in the file
import cherrypy

class HelloWorld(object):
def index(self):
return "Hello World!" = True


This runs on on port 8080 by default. It also runs in development mode (which you should not deploy with, but only use for testing).

Now create a 'theservicedir' directory somewhere.
Also create the following directories: 'theservicedir/log' and 'theservicedir/log/main'

Then create a 'theservicedir/run' file.
exec setuidgid rene /usr/bin/python /home/rene/cherrypydaemontools/

Note that I specified full paths to python and to your python script. Also see that I got the app to run with the setuidgid program as the user 'rene'.

Then create a 'theservicedir/run' file for logging.
exec setuidgid rene multilog t ./main

Now to start it up we symlink the file into the service directory.
sudo ln -s /home/rene/cherrypydaemontools/theservicedir /service/theservicedir

To stop it:
svc -d /service/theservicedir

To restart it:
svc -t /service/theservicedir

To start it:
svc -u /service/theservicedir

Your app should start up the next time your server reboots. Happy cherrypy and daemontools usage. Please leave any related tips or fixes to these instructions in the comments.