python

how to "export CFLAGS='my -flags -here' from python script

I'm writing a python program that needs to set the environment CFLAGS as needed. I'm using the subprocess module to perform some operations, but, I'm not sure this is the correct way of doing this. The script will first set the CFLAGS and then compile some code, so the cflags need to stay put while the code is compiled. I know there i...

Haystack / Whoosh Index Generation Error

I'm trying to setup haystack with whoosh backend. When i try to gen the index [or any index command for that matter] i receive: TypeError: Item in ``from list'' not a string if i completely remove my search_indexes.py i get the same error [so i'm guessing it can't find that file at all] what might cause this error? it's set to autodi...

License plate recognition using OpenCV

I have a project where I need to identify the license plate of a car using OpenCV. I want to load an image of a number or a letter and let OpenCV identify it and print it to the console. Is there a function do this? If not, how can I do it? Note: I am working on gray level Please help, I have to make it a week from now ...

Python, PyTables - taking advantage of in-kernel searching

Hi guys, I have HDF5 files with multiple groups, where each group contains a data set with >= 25 million rows. At each time step of simulation, each agent outputs the other agents he/she sensed at that time step. There are ~2000 agents in the scenario and thousands of time steps; the O(n^2) nature of the output explains the huge numbe...

Replace letters in a secret text

Hello! I want to change every letter in a text to after next following letter. But this program doesnt work. Does anyone know why. Thanks in advance. There is also a minor problem with y and z. import string letters = string.ascii_lowercase text=("g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb ...

Image library with advanced text effects?

What would be the best Python library to use when producing text-based images requiring things such as leading, kerning, outlines, drop-shadows, etc? I've worked with PIL before for resizing images, but the methods for working with text seem rather limited. Is there a better alternative? ...

Unable to get Netbeans debugger working for python.

Ubuntu 9.10 Netbeans 6.7.1 Whenever I start the debugger it crashes out with the error below. I've set the project properties to the correct version of python, although it doesn't seem to make any difference what it is set to. I've also noticed that the PythonConsole window reports that Python 2.5.0+ is running regardless of the versi...

How can I insert a new Event for non primary Calendar? Using python gdata

def addEvent(calendar_service): event = gdata.calendar.CalendarEventEntry() event.content = atom.Content(text='Tennis with John 30.12.2009 15:00-16:00') event.quick_add = gdata.calendar.QuickAdd(value='true') new_event = calendar_service.InsertEvent(event, '/calendar/feeds/default/private/full') This write to primary Ca...

Interpolating a scalar field in a 3D space

I have a 3D space (x, y, z) with an additional parameter at each point (energy), giving 4 dimensions of data in total. I would like to find a set of x, y, z points which correspond to an iso-energy surface found by interpolating between the known points. The spacial mesh has constant spacing and surrounds the iso-energy surface entirel...

Start and capture GUI's output from same Python script and transfer variables?

Hi, I have to start a GUI from an existing Python application. The GUI is actually separate Python GUI that can run alone. Right now, I am starting the GUI using something like: res=Popen(['c:\python26\pythonw.exe', full_filename, str(RESULTs), str(context)], stdout=PI...

mysql-python install problem using virtualenv, windows, pip

I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error reported here, but the answer there worked for me too. Now I'm getting this following error: _mysql.c(34) : Fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory edit: If I symlink (Win7) to...

Separate image of text into component character images

I'd like to separate an image of text into it's component characters, also as images. For example, using the sample below I'd end up with 14 images. I'm only going to be using text on a single line, so the y-height is unimportant - what I need to find is the beginning and end of each letter and crop to those coordinates. That way I wou...

MySQLdb connection issue

I am writing a server which provide a service by query MySQL database. Everything goes fine, except when run one or two days the connection will go away. The error code is (2600, MySQL has gone away) I try to wrap the cursor object by: def cursor(self): try: return self.connection.cursor() except: self.conne...

What arguments does Python sort function have?

a=range(10) b=a[::-1] print b c=zip(a,b) print c c.sort(key=lambda x:x[1])#is there any other argument print c Is there any other argument except key,for example: value? Thanks. ...

Python-Challenge Level 3

The questions is: One small letter, surrounded by EXACTLY three big bodyguards on each of its sides. I wrote this code and get an answer. I thougt it would be correct, but it doesn't work. Can anybody help me? My answer: KWGtIDC import urllib, sys, string from string import maketrans bbb = 0 f = urllib.urlopen("http://www.pythonchalle...

Python code optimization

I'm building a online font previewer, with following architecture. I wrapped preview creation function in a standalone .py file and making system calls to it in a Django view in order to run them in parallel and maximum performance on multi-core CPU system. preview.py .... def make_preview(text, fontfile, imagefile, fontsize=30): t...

Get the position of the windows start menu

I'm writing an app in Python that automatically moves stuff around. How do I get the position of the windows start menu bar, so I can account for it in my calculations? ...

How to use pyparsing to parse and hash strings enclosed by special characters?

The majority of pyparsing examples that I have seen have dealt with linear expressions. a = 1 + 2 I'd like to parse mediawiki headlines, and hash them to their sections. e.g. Introduction goes here ==Hello== foo foo ===World=== bar bar Dict would look like: {'Introduction':'Whoot introduction goes here', 'Hello':"foo\nfoo", 'World...

delete a line based on logic

Hi everyone, I have a file where i have multiple records with such data F00DY4302B8JRQ rank=0000030 x=800.0 y=1412.0 length=89 now i want to search for the line where if i find length<=50 then delete this line and the next line in the file and write to another file. Thanks everyone ...

django:error with the custom inclusiong_tag, error info:Invalid block tag

I'm trying to write a custom inclusion_tag in django. Following the example on http://docs.djangoproject.com/en/dev/howto/custom-template-tags/ I'm just writing from django import template from libmas import models register = template.Library() @register.inclusion_tag('records.html') def display_records(book_id): book = models...