Allow running ulg.py form console.

Add support for running ulg.py form console. (Do not blindly expect
CGI environment to be always set.)
Merge branch 'master' of https://github.com/tmshlvck/ulg