python

WSGI blogging software for programmers

Hi. I'm new to python w/o WSGI, but I have a C/C++ and PHP background. Do you know any blogging software written as a WSGI application on top of spawning, eventually by using werkzeug? Analysing such a code would give me a better understanding of how things work and/or should work. Thanks. Addendum: SQLAlchemy changed its API since 0....

Python Fabric: How to answer to keyboard input ?

I would like to automate the response for some question prompted by some programs, like mysql prompting for a password, or apt asking for a 'yes' or ... when I want to rebuild my haystack index with a ./manage.py rebuild_index. For MySQL, I can use the --password= switch, and I'm sure that apt has a 'quiet' like option. But how can I p...

multiprocessing Pool hangs when there is a exception in any of the thread

I am new to Python and trying a multiprocessing.pool program to process files, it works fine as long as there are no exceptions. If any of the thread/process gets an exception the whole program waits for the thread snippet of the code: cp = ConfigParser.ConfigParser() cp.read(gdbini) for table in cp.sections(): jobs.append(table) ...

boolean text search in python

i'm looking for an existing module(s) which enabled me to write basic boolean queries for matching and searching texts, WITHOUT writing my own parser etc. for example, president AND (ronald OR (george NOT bush)) would match TRUE against "the president ronald ragen" "the president ronald ragen and bush" "max bush was not a president" ...

PyScripter - change highlighting options/color scheme Python

Hi all, Just wondering if anyone else is using PyScripter as a Python editing app. I've been runnign my python IDLE in a black background and now find the default white of PyScripter to be blinding. For the life of me I can't find the menu to change the "highlighting" portion of the program (where you open and modify .py files). ...

Django, template context processors

Hello, I have a weird problem, I want to add a global query using context processors. This is how I did it by following: made a processor.py in my app as such: from myproject.myapp.models import Foo def foos(request): return {'foos': Foo.objects.all()} and at the end of my setting.py I have added this: TEMPLATE_CONTEXT_PROCESS...

app-engine (python) Modeling relationships, am I doing it wrong?

Using the following models I am trying to figure out a way to generate a news feed of sorts so that when a user logs in they are presented with a list of upcoming events for bars that they choose to follow. Will I be able to query something like “SELECT * FROM Barevent WHERE parent_bar IN UserprofileInstance.following”? If so will this b...

How can I filter a pcap file by specific protocol using python?

Hello I have some pcap files and I want to filter by protocol, i.e., if I want to filter by HTTP protocol, anything but HTTP packets will remain in the pcap file. There is a tool called openDPI, and it's perfect for what I need, but there is no wrapper for python language. Does anyone knows any python modules that can do what I need...

Associative Matrices?

I'm working on a project where I need to store a matrix of numbers indexed by two string keys. The matrix is not jagged, i.e. if a column key exists for any row then it should exist for all rows. Similarly, if a row key exists for any column then it should exist for all columns. The obvious way to express this is with an associative a...

Python returning the wrong length of string when using special characters

I have a string ë́aúlt that I want to get the length of a manipulate based on character positions and so on. The problem is that the first ë́ is being counted twice, or I guess ë is in position 0 and ´ is in position 1. Is there any possible way in Python to have a character like ë́ be represented as 1? I'm using UTF-8 encoding for the...

stream socket send/receive broadcast messages?

Hi, I browsed the python socket docs and google for two days but I did not find any answer. Yeah I am a network programming newbie :) I would like to implement some LAN chatting system with specific function for our needs. I am at the very beginning. I was able to implement a client-server model where the client connects to the server (...

python bisect, it is possible to work with descending sorted lists?

How can I use bisect module on lists that are sorted descending? eg. import bisect x = [1.0,2.0,3.0,4.0] # normal, ascending bisect.insort(x,2.5) # --> x is [1.0, 2.0, 2.5, 3.0, 4.0] ok, works fine for ascending list # however x = [1.0,2.0,3.0,4.0] x.reverse() # --> x is [4.0, 3.0, 2.0, 1.0] descending list b...

Python best way to check for existing key

I was just wondering which is the more efficient/faster/better way to check if a key exists. if 'subject' in request.POST: subject = request.POST['subject'] else: // handle error OR try: subject = request.POST['subject'] except KeyError: // handle error ...

"HTTP Error 409: Conflict" when using urllib.request.urlopen()

Under Python 3.1, when trying to run this code: from urllib import request def test(): request.urlopen("http://www.google.com") test() I get an HTTP 409 error. The stack trace is: Traceback (most recent call last): File "C:\Users\Beau\Python\pokescrape.py", line 6, in <module> test() File "C:\Users\Beau\Python\pokescra...

How can you access the "calling" object through a RelatedManager in Django?

Say I have a model with a foreign key to a Django Auth user: class Something(models.Model): user = models.ForeignKey(User, related_name='something') I can then access this model through a RelatedManager: u = User.objects.create_user('richardhenry', '[email protected]', 'password') u.something.all() My question is, if I creat...

Python String Method Conundrum

The following code is supposed to print MyWords after removing SpamWords[0]. However; instead of returning "yes" it instead returns "None". Why is it returning "None"? MyWords = "Spam yes" SpamWords = ["SPAM"] SpamCheckRange = 0 print ((MyWords.upper()).split()).remove(SpamWords[SpamCheckRange]) ...

Anyone benchmarked virtual machine performance for build servers?

We have been trying to use virtual machines for build servers. Our build servers are all running WinXP32 and we are hosting them on VMWare Server 2.0 running on Ubuntu 9.10. We build a mix of C, C++, python packages, and other various deployment tasks (installers, 7z files, archives, etc). The management using VMWare hosted build serv...

render users' equations in Python

Hello all! I am a very new/inexperienced Python programmer. I teach maths and am trying to create a GUI graph-plotting package suitable for schoolchildren. As well as plotting a graph, I would ideally like to render the equation a user enters [eg. y = (x^2)/3] in a nicely formatted style - ideally updating in real-time as the user enter...

running BLAST (bl2seq) without creating sequence files

I have a script that performs BLAST queries (bl2seq) The script works like this: Get sequence a, sequence b write sequence a to filea write sequence b to fileb run command 'bl2seq -i filea -j fileb -n blastn' get output from STDOUT, parse repeat 20 million times The program bl2seq does not support piping. Is there ...

Grid lines in parasitic axes in matplotlib

Can you draw the grid lines in a plot with parasitic axes in matplotlib? I try this, based on the samples for grids and for parasitic axes, but grid drawing is not performed: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost import matplotlib.pyplot as plt fig = plt.figure(1) host = SubplotHost(fig, 111) fig.add_subplot(ho...