CherryPy + MySQLdb

After hours of searching and hitting the walls with the following error:

File "build/bdist.macosx-10.3-i386/egg/MySQLdb/", line 19, in
File "build/bdist.macosx-10.3-i386/egg/", line 7, in
File "build/bdist.macosx-10.3-i386/egg/", line 6, in __bootstrap__
ImportError: dlopen(/Users/oleksii/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg-tmp/, 2): image not found

I finally decided just to look on what actually was in the .python-eggs folder. Rrrriiight:

-rw------- 1 oleksii oleksii 123024 Sep 20 2008

Isn’t this just beautiful? I don’t get why it is created under my user anyway while Apache2 is running under different user, but since the created library was only readable by me myself… Well, Apache just couldn’t get to it. Damn. What a loss of time (simply not mentioning all previous frustrations with installs, etc).

Reviewing svn changes

I have a habit of reviewing my changes before committing them to the repository. What suprises me is that so far I have only seen home-brewed scripts to perform a ‘batch’ review of all changed files. But ok, how difficult is that? So for my current project I came up with a similar solution. Here are some lines of bash script:


# Find the list of changed files.
FILES=`/usr/local/bin/svn st | grep ^M | /usr/bin/sed ‘s/^M[ ]*\(.*\)/\1/’`
for FILE in $FILES; do
# Invoke favorite diff viewer to see the changes.
svn diff –diff-cmd /Users/oleksii/Scripts/ $FILE

It could have been beautified a bit, but what a heck… BTW, the ‘magic’’ looks like the following for me (use any other diff tool if you like, I just happen to use DiffMerge because it is available for all the platforms I am using now):





It should not be difficult to see which OS I am using here :).

XPlanner setup

I like XPlanner, but I am also very suspicious on beta’s being frozen for years (ok, GMail being a nice exception :)). Anyway, today I was happily changing XPlanner configuration to get around a known bug in XPlanner, which fortunately didn’t cost too much time to find solution for. XPlanner on Tomcat 5.5 + Java-6 on Ubuntu 8.04 apparently result in an exception during startup. The following explanation (thanks Alex!) gives a quick fix.

  1. in /xplanner/WEB-INF/classes/sbring-beans.xml
  2. for Find the bean id="metaRepository"
  3. replace

    <property name="repositories">
    <bean class="java.util.HashMap">

Arrgggh, I feel I am hacking too much just to get get things working while I already expect them to work out of a box. Is this the way all admins feel?..

Killing time with vsftpd

It seems that I am out of luck for the last 24 hours. I have tried to set up virtual ftp users for my server and seen the number of posts on this topic it should have been a piece of cake. I wish… Some good posts worth having a look though (and reading CAREFULLY!):

Several lessons on this topic:

  1. Make sure you have By default it is NOT present on Ubuntu (at least 8.04). Get it by issuing

    sudo apt-get install libpam-pwdfile
  2. Don’t try to be smarter than you are. The following command (without -m switch!) do the trick with the passwd file:

    sudo htpasswd -c /etc/vsftpd/passwd user_name

Damn, was it worth sleepless 4 hours of headaches?

Getting wireless iface up and running on boot under Ubuntu 8.04

Well, this was driving me crazy for several days. My wlan0 interface was not getting ip address from my router, which was pretty bad considering that machine it supposed to be a server. After all I’ve started getting dreadful
WPA: EAPOL-Key Replay Counter did not increase - dropping packet
messages, which I couldn’t get at all.


  • Ubuntu 8.04 (server)
  • Linksys WMP54G PCI wireless network card (almost stopped trusting Linksys since this one); driver WinXP 64 bit via ndiswrapper
  • Linksys WRT54GL w/Tomato firmware (yeah, finally got to it and it is so much better than the original;


  • No IP address after restart on the host; the IP address is provided when doing manual
    sudo ifdown wlan0
    and then
    sudo ifup wlan0

Damn… that’s not how I want to run a headless server that I have planned to put somewhere in the house to get rid of the noise (therefore the wireless to make freely movable).

Tips & Tricks

  • Check if you’re running multiple wpa_supplicant instances by running

    ps ax | grep wpa_supplicant

    If so, stop them by issuing

    wpa_cli terminate

  • The following wpa_supplicant.conf worked for me



    And here is the reference to it in the /etc/network/interfaces:

    auto lo wlan0
    iface wlan0 inet dhcp
    wpa-driver wext
    wpa-conf /etc/wpa_supplicant.conf

    Finally, there was no luck in obtaining DHCP consistently, I have used the same hack as described in the Ubuntu WIFIDocs, and added the
    ifdown wlan0
    ifup wlan0

    to the /etc/rc.local :(. This works properly since it will be executed when the rest is properly started.

    p.s. This seem to be a known bug #53387, so I am not the only one spending my time for nothing. Welcome to the wonderful world of Linux (you have to set it up and you will be setting it up… forever…).

Guest WinXP VM host share access

I use VmWare Server 1.0.6 for testing purposes (great thing because of snapshots and it is free!), but for a while I could only connect to the guest VM from my host. Somehow my guest Windows XP refused to connect to the host machine shares. After all the following worked:

  • Create a regular user on the host computer.
    e.g. go to Control Panel | User Accounts | Advanced (tab), click on the Advanced button
    And select Users | Right mouse click | New User
    enter new user name and password.
    Make sure the “User must change password at next logon” checkbox is not checked; then check then “Password never expires” checkbox.
  • add a new share to the disk/folder you would like to share
  • give the new user rights to use share (remove Anybody from the list for security reasons)
  • connect from your guest machine using
    net use * \\ /user:<host_name>\<new_user>

    you will be prompted for a password.



Original date: 2008-12-27

Apparently using the TIMESTAMP fields in the MySQL the MySQLdb library in python results in the datetime.datetime() objects. A valid value can be set by providing a valid datetime.datetime instance.

Giving up on PHP

Quick and dirty prototyping in python instead of PHP (+MySQL).

Original date: 2008-12-22

I have spent a lot of time trying to figure out how to get my time registration app (php + mysql) up and running on my old FreeBSD laptop. After several unsuccessful attempts, abscence of properly installed mod_php and perhaps a lot of other things gave up. I can quickly do the minimal thingy using python!

I have added .py to the cgi script handlers:

AddHandler cgi-script .py

Made a simple script to connect to the MySQL database, but it failed miserably. No output was generated. After several attempts it seems that the import statement fails. Ok, put a try/except clause around and output the result. Hmmm, the result is rather interesting:

(Can’t extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: ‘/nonexistent’ The Python egg cache directory is currently set to: /nonexistent/.python-eggs Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory. )

Ok, it seems that my www user (which does not have any home folder of course!) attempts to create cache folder under his (non-existing) home folder. Adding (perhaps not very secure)

SetEnv PYTHON_EGG_CACHE /tmp/apache/

to the virtual host configuration helped for now (you need mod_env for this). The cache can be created.
Ideally you would need a proper home directory with a restricted access for the apache user account.

If the server comes up with a very descriptive message like

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

This may simply means that your beauty (script) contains just a small typo. Very handy indeed. The following two lines help a lot:

import cgitb