python

log4j with timestamp per log entry

Hi! this is my log output INFO main digestemails - process inbox INFO main digestemails - checking for emails in c:\development\DCMail\email\KN-Source INFO main digestemails - digesting [email protected] INFO main digestemails - extracting attachments INFO main digestemails - no attachments or no attachments su...

Keeping a variable around from post to get?

I have a class called myClass which defines post() and get() methods. From index.html, I have a form with an action that calls myClass.post() which grabs some data from the data base, sets a couple variables and sends the user to new.html. now, new.html has a form which calls myClass.get(). I want the get() method to know the value...

xmodem for python

Hi All: I am wiriting a program that requires the use of XMODEM to transfer data from a sensor device. I'd like to avoid having to write my own XMODEM code, so I was wondering if anyone knew if there was a python XMODEM module available anywhere? Al ...

python, set terminal type in pexpect

I have a script which uses pexpect to start a CLI program. It works a bit like a shell where you get a prompt where you can enter some commands. The problem I have, I think, is that this program uses a coloured prompt. This is what I do import pprint import pexpect 1 a = pexpect.spawn('program') 2 a.expect("prompt>") 3 print "------...

How to launch multiple subprocesses sequentially in python ?

I would like to execute multiple commands in a row: ie (just to illustrate my need): cmd (the shell) then cd dir and ls and read the result of the ls. Any idea with subprocess module ? UPDATE: cd dir and ls are just an example. I need to run complex commands (following a particular order, without any pipelining). In fact, i wou...

What is the sqlalchemy equivalent column type for 'money' and 'OID' in Postgres?

What is the sqlalchemy equivalent column type for 'money' and 'OID' column types in Postgres? ...

How can I unload a DLL using ctypes in Python?

I'm using ctypes to load a DLL in Python. This works great. Now we'd like to be able to reload that DLL at runtime. The straightforward approach would seem to be: 1. Unload DLL 2. Load DLL Unfortunately I'm not sure what the correct way to unload the DLL is. _ctypes.FreeLibrary is available, but private. Is there some other way t...

Comparing List of Arguments to it self?

Kind of a weird question, but. I need to have a list of strings i need to make sure that every string in that list is the same. E.g: a = ['foo', 'foo', 'boo'] #not valid b = ['foo', 'foo', 'foo'] #valid Whats the best way to go about doing that? FYI, i don't know how many strings are going to be in the list. Also this is a super eas...

Split HTML after N words in python

Is there any way to split a long string of HTML after N words? Obviously I could use: ' '.join(foo.split(' ')[:n]) to get the first n words of a plain text string, but that might split in the middle of an html tag, and won't produce valid html because it won't close the tags that have been opened. I need to do this in a zope / plone ...

Lambda function for classes in python?

There must be an easy way to do this, but somehow I can wrap my head around it. The best way I can describe what I want is a lambda function for a class. I have a library that expects as an argument an uninstantiated version of a class to work with. It then instantiates the class itself to work on. The problem is that I'd like to be able...

Regular Expressions in unicode strings

I have some unicode text that I want to clean up using regular expressions. For example I have cases where u'(2'. This exists because for formatting reasons the closing paren ends up in an adjacent html cell. My initial solution to this problem was to look ahead at the contents of the next cell and using a string function determine if...

What GUI toolkit looks best for a native LAF for Python in Windows and Linux?

Hello I need to decide on a GUI/Widget toolkit to use with Python for a new project. The target platforms will be Linux with KDE and Windows XP (and probably Vista). What Python GUI toolkit looks best and consistent with the native look and feel of the run time platform? If possible, cite strengths and weaknesses of the suggested toolk...

Extract ipv6 prefix in python

Given either the binary or string representation of an IPv6 address and its prefix length, what's the best way to extract the prefix in Python? Is there a library that would do this for me, or would I have to: convert the address from string to an int (inet_ntop) Mask out the prefix Convert prefix back to binary Convert binary to str...

Access CVS through Apache service using SSPI

I'm running an Apache server (v2.2.10) with mod_python, Python 2.5 and Django. I have a small web app that will show the current projects we have in CVS and allow users to make a build of the different projects (the build checks out the project, and copies certain files over with the source stripped out). On the Django dev server, ever...

Need Help Understanding how to use less complex regex in Python

Hi I am trying to learn more about regular expressions I have one below that I believe finds cases where there is a missing close paren on a number up to 999 billion. The one below it I thought should do the same but I do not get similar results missingParenReg=re.compile(r"^\([$]*[0-9]{1,3}[,]?[0-9]{0,3}[,]?[0-9]{0,3}[,]?[0-9]{0,3...

Python - doctest vs. unittest

I'm trying to get started with unit testing in Python and I was wondering if someone could inform me of the advantages and disadvantages of doctest and unittest. What conditions would you use each for? ...

Python Canvas

I'm looking for a Python library for creating canvases for manipulating gemetric shapes. Specifically I need the ability to create arbitrary polygons and place them on the canvas, the polygons need to have the ability to be transparent/have an alpha channel, I need to be able to edit polygons that are currently on the canvas, and I need...

Techniques for data comparison between different schemas

Are there techniques for comparing the same data stored in different schemas? The situation is something like this. If I have a db with schema A and it stores data for a feature in say, 5 tables. Schema A -> Schema B is done during an upgrade process. During the upgrade process some transformation logic is applied and the data is stored ...

Python: Finding partial string matches in a large corpus of strings

I'm interested in implementing autocomplete in Python. For example, as the user types in a string, I'd like to show the subset of files on disk whose names start with that string. What's an efficient algorithm for finding strings that match some condition in a large corpus (say a few hundred thousand strings)? Something like: matches ...

Is there a standalone alternative to activerecord-like database schema migrations?

Hi! Is there any standalone alternative to activerecord-like migrations. Something like a script that is able to track current schema version and apply outstanding migrations. Basically, these migration files could be just a plain SQL files, something like: [timestamp]_create_users.sql reverse_[timestamp]_create_users.sql Language of...