Add support to Python 2.4.

- python 2.4 can not support try..except..finally, use try..except or try..f
    in ally only
- python 2.4's string has no format() method, use % instead.

Tested on Python 2.4.3 / RHEL 5.8.