Archives for posts tagged ‘Python’

Printing the current running stack in Python

The traceback module has utility functions for printing the currently running stack, not just tracebacks.

import traceback
import logging

# somewhere in your buggy code
logging.log(1, "".join(traceback.format_stack())

unable to remap C:\cygwin\bin\tk84.dll to same address as parent

I was checking out Tauber’s Pinax, and came across VirtualEnv for the first time. Those are two cool projects.
However, building PIL on Cygwin Python 2.5 yields the following error message:
unable to remap C:\cygwin\bin\tk84.dll to same address as parent
Thanks to the power of Google, DataHammer has already found a resolution

C:\>cd \cygwin\bin
C:\cygwin\bin>ash
$ ./rebase -b 0×1000000000 tk84.dll

Python Grep

From ZazzyBob
Occasionally I have to wade through log files on sites running Windows, since our program is python based, it’s useful to be able to have these tools on hand without downloading exes. I’m hosting a copy here just in case it gets lost in the interweb.

#!/usr/bin/python
#< PYTHON – simple grep through a file – [...]

Cygwin Python and sqlite3

Apparently, cygwin’s distribution of Python 2.5.1 doesn’t come with sqlite3. This is a pity for those who would like to work with Django using cygwin Python.
Building _sqlite3.dll on cygwin is not too difficult. If you are in a hurry, heres the download _sqlite3.dll.
Prerequisites

/bin/cygsqlite3-0.dll
/bin/libpython2.5.dll
/usr/include/sqlite3.h
/usr/include/python2.5/Python.h [et.c]

tar jxf Python-2.5.2.tar.bz2 Python-2.5.2/Modules/_sqlite/
cd Python-2.5.2/Modules/_sqlite/
gcc -shared -o _sqlite3.dll -I /usr/include/python2.5 -L /bin [...]