Chris' Python Page

reST to S5 convertor

rst2s5 is a Docutils writer for S5, a Simple Standards-based Slide Show System. This means simple text files with reStructuredText (reST) markup can be converted to nice looking slideshows that can easily be viewed with the webbrowser. See presentation.txt in the archive below for an example and instructions.

It's now part of the official Docutils distribution (starting from version 0.4) please use that version. (Download old version: rst2s5.zip)

Single File Executables

There are several solutions out there, here's the next one...

Based on Pyco (broken link) and py2exe. It is possible to make command line tools or GUI tools. It is realy only one file and it can be run without any installation. It unpacks the files to a temporary directory which is cleaned up afterwards.

Download: py2exe-pyco.zip

Arbitrary file size Hex Editor

YaHEbwinPy - Yet An Other Hex Editor, But Written In Python

Tested with file sizes up to 1267650600228229401496703205376 Bytes (2**100B). Runs on Linux and Windows. Features Undo/Redo, find, replace, copy&paste, save selection, edit devices on WinNT/2k/XP and Linux, decode selected text as Unicode or in a codepage and more. It has a plugin system where Python modules can register additional functions. It nerver loads the entire file, just a few megabytes, which means its capable of opening large files on network drives and such.

Sources: hexedit.zip (130kB, requires: Python 2.3 and wxPython 2.4) Win32 Installer, standalone version: install-YaHEbwinPy-0.7.exe (2.1MB)

Win32 Screensaver

This is a complete rewrite of my old screensaver module. This one is pure Python with the help of ctypes and py2exe. It is intended to make it easy to write windows screensavers in pure Python. Screensavers using the pyscr module can be implemented with ctypes (a little wrapper class around a DC already exits) or win32all. The pyscr_pygame module also gives the opportunity to write the screensaver with pygame.

The Win32 parts are implemented using ctypes.

Requires Python 2.3, ctypes, py2exe. Download archive with the library and examples: win32screensaver-0.3.2.zip.

VNC Viewer

This is a simple VNC viewer implemented in Python, using Twisted and PyGame. Please read the readme.txt in the archive for usage and limitations.

pyvncviewer.zip (18kB)

Samba tunnel over SSH

Note: Newer Putty clients should be able to bind forwarded ports to non-localhost addresses, which makes the tool below obsolete.

It happens that people want to forward Samba (SMB/Windows shared drives) connections though an encrypted SSH connection. The problem is just that one can't tell to Windows on which target port such a connection should be made (it only work on port 139). On the other hand, you can't tell SSH on which interface it should bind it's local ports (only 127.0.0.1 which happens to be used by the local server). SMB_reroute.py solves these two problems. Start with "python SMB_reroute.py username host", enter the SSH password when prompted.

It currently uses "ssh" which can be found in the cygwin distribution, but it should also work with putty. Note that for some reason tunneled SMB connections are slow... maybe because only a TCP conenction is tunneled and o UDP packets that are used for discovery - don't know... There are better ways to securely exchange files between two machines, e.g. with scp the secure copy of ssh.

One can now access the secure remote share with the path "\127.0.0.2". This script is intended to be used by Windows users. On Linux is this hack not needed as the port can be specified as option to the Samba programs.

NSIS Python Plugin

You use the Nullsoft NSIS installer and want some advanced scripting or you're deploying a Python application and want to execute some Python code during setup? Here is a solution. With this NSIS Plugin you can do all this.

Supported commands are eval, exec and execFile. A special module "nsis" is exposed to Python which supports writing to the log, display a message box and get/set the NSIS variables. The win32 parent handle of the installer can also be read so it's open for extensions that use win32all or ctypes.

Download it here: NSIS-Python22.zip (for Python 2.2) NSIS-Python23.zip (for Python 2.3)

Python License.

MySQL table viewer

This is a simple wxPython application. It has a TextField that lets you enter SQL commands that it executes and a ListCtrl to display the results.

Get it here: question.pyw.

Find the Mines

Yup, yet an other minesweeper clone. Here's a pygame version. You may want to delete the highscores file ;-) mines_pyg.zip

Unittest GUI

A simple, not finished but usable, frontend to run unittests. Using wxPython. unittestgui.py

Functional games

Some simple functions written in functional style. functional.py

Befunge Interpreter

You don't know Befunge? Well you missed something :-) It's an esotheric programming language that runs in a two dimensional space. This is an Interpreter written in Python and a unfinished viewer/debugger with pygame. befunge.zip

Here is the home of Befunge: http://www.catseye.mb.ca/esoteric/befunge/

Unix Daemon

You need to run a Python script as a daemon? So why don't you take this script, change the logfile location and call your main(). It takes care of the console detachement (double fork) and writes a PID file so that it can be killed. daemon.py

And here is a sample init.d script: daemon. It goes in /etc/init.d with an appropriate name, an then create links in the rc directories, like: ln -s /etc/init.d/daemon /etc/rc.2/S30daemon the location of the directories may vary between Linux distributions. Usualy Sxxname are starter, Kxxname stopper scripts. This one is from Debian.

Observer Pattern

Allways handy. Especialy for GUI programming but not exclusively. observerpattern.py


DISCLAIMER: THIS IS EXPERIMENTAL SOFTWARE. USE AT YOUR OWN RISK. THE AUTHORS CAN NOT BE HELD LIABLE UNDER ANY CIRCUMSTANCES FOR DAMAGE TO HARDWARE OR SOFTWARE, LOST DATA, OR OTHER DIRECT OR INDIRECT DAMAGE RESULTING FROM THE USE OF THIS SOFTWARE. IF YOU DO NOT AGREE TO THESE CONDITIONS, YOU ARE NOT PERMITTED TO USE OR FURTHER DISTRIBUTE THIS SOFTWARE.

Home