python

How can I set up Juno on apache with FCGI?

Hello, I have an Apache server with mod_fcgi and I made a project with Juno, which I'd like to run on it. Juno says it supports flup for fcgi but I can't find any info on that, has anyone used it/set it up? Can it be done with server-spawned processes, like with Django? ...

appengine select based on timestamp

I can't seem to select something based on timestamp. The behavior is a bit weird and the < and = symbols don't seem to mean what I expect them to. """ A site message """ class Message( db.Model ) : # from/to/ a few other fields subject = db.StringProperty() body = db.Text() # this is the field i'm trying to use sent = db.Da...

How to install distutils packages using distutils api or setuptools api

Hello, I'm working on a buildout script that needs to install a distutils package on remote server. On PyPi there are 2 recipes for doing this collective.recipe.distutils 0.1 and zerokspot.recipe.distutils 0.1.1. The later module a derivative of the former, and is a little more convenient then the first, but the both suffer from the s...

How to Model a Foreign Key in a Reusable Django App?

In my django site I have two apps, blog and links. blog has a model blogpost, and links has a model link. There should be a one to many relationship between these two things. There are many links per blogpost, but each link has one and only one blog post. The simple answer is to put a ForeignKey to blogpost in the link model. That's al...

Python __init__ setattr on arguments?

It seems that often __init__ methods are similar to this: def __init__(self, ivar1, ivar2, ivar3): self.ivar1 = ivar1 self.ivar2 = ivar2 self.ivar3 = ivar3 Is there someway to turn the arguments into a list (without resorting to *args or **kwargs) and then using setattr to set the instance variables, with the name of the p...

Selecting based on __key__ (a unique identifier) in google appengine

Again i have """ A site message """ class Message( db.Model ) : # from/to/ a few other fields subject = db.StringProperty() body = db.Text() sent = db.DateTimeProperty( auto_now_add=True ) Now I'm trying to pick out a Message by its KEY. I saved off the key earlier and planted it in an HTML form. The result is a clickable...

Django LEFT JOIN?

I have models, more or less like this: class ModelA(models.Model): field = models.CharField(..) class ModelB(models.Model): name = models.CharField(.., unique=True) modela = models.ForeignKey(ModelA, blank=True, related_name='modelbs') class Meta: unique_together = ('name','modela') I want to do a query that ...

How to forward port to router using python...

I am building python p2p application like p2p instant messenger. I am communicating with other peers using TCP/IP connection. I do not want client to do port forwarding. When application starts it should check whether port is forwarded to router if not it should forward it to router. Is it possible to programaticaly forward the port to ...

How to extract and then refer to variables defined in a python module?

I'm trying to build a simple environment check script for my firm's test environment. My goal is to be able to ping each of the hosts defined for a given test environment instance. The hosts are defined in a file like this: #!/usr/bin/env python host_ip = '192.168.100.10' router_ip = '192.168.100.254' fs_ip = '192.168.200.10' How ca...

Atlassian Bamboo with Django & Python - Possible?

At my company, we currently use Atlassian Bamboo for our continuous integration tool. We currently use Java for all of our projects, so it works great. However, we are considering using a Django + Python for one of our new applications. I was wondering if it is possible to use Bamboo for this. First off, let me say that I have a low ...

Just installed QtOpenGL but cannot import it (from Python)

I just installed it with apt-get on debian linux with apt-get install libqt4-opengl the rest of PyQt4 is available, but I cant get to this new module. from PyQt4 import QtOpenGL raises ImportError. any idea what to do? ...

Parsing unstructured text in Python

I wanted to parse a text file that contains unstructured text. I need to get the address, date of birth, name, sex, and ID. . 55 MORILLO ZONE VIII, BARANGAY ZONE VIII (POB.), LUISIANA, LAGROS F 01/16/1952 ALOMO, TERESITA CABALLES 3412-00000-A1652TCA2 12 . 22 FABRICANTE ST. ZONE VIII LUISIANA LAGROS, BARANGAY ZONE VIII (POB.), LUISIA...

convert the key in MIME encoded form in python

this is the code : f = urllib.urlopen('http://pool.sks-keyservers.net:11371/pks/lookup?op=get&amp;search= 0x58e9390daf8c5bf3') #Retrieve the public key from PKS data = f.read() decoded_bytes = base64.b64decode(data) print decoded_bytes i need to convert the key in MIME encoded form which is presently comes in (ascii armored) radix 64...

How can I generate a complete histogram with numpy?

I have a very long list in a numpy.array. I want to generate a histogram for it. However, Numpy's built in histogram requires a pre-defined number of bins. What's the best way to generate a full histogram with one bin for each value? ...

How can I add a decorator to an existing object method?

If I'm using a module/class I have no control over, how would I decorate one of the methods? I understand I can: my_decorate_method(target_method)() but I'm looking to have this happen wherever target_method is called without having to do a search/replace. Is it even possible? ...

How do I loop through relationships in a list only once?

I have a list of users: users = [1,2,3,4,5] I want to compute a relationship between them: score = compatibility( user[0], user[1] ) How do I loop over users so that a relationship between users are computed only once? ...

Change keyboard layout with python?

I'm working on a college system (windows XP) and want to set the keyboard to Dvorak when I log on. I currently have a python script that changes the desktop image. Can I use python to change the layout as well? Or are there other ways? ...

Stopping embedded Python

I'm embedding Python interpreter to a C program. However, it might happen that while running some python script via PyRun_SimpleString() will run into infinite loop or execute for too long. Consider PyRun_SimpleString("while 1: pass"); In preventing the main program to block I thought I could run the interpreter in a thread. How do I st...

Yahoo BOSS Python Library, ExpatError

I tried to install the Yahoo BOSS mashup framework, but am having trouble running the examples provided. Examples 1, 2, 5, and 6 work, but 3 & 4 give Expat errors. Here is the output from ex3.py: gpython examples/ex3.py examples/ex3.py:33: Warning: 'as' will become a reserved keyword in Python 2.6 Traceback (most recent call last):...

Python 3-compatibe HTML to text converter preserving basic structure under permissive licence?

I am looking for a relatively simple HTML to text converter which displays links and works on strings. So far I have tried lynx but performance is too bad, html2text which gives weird and verbose markdown output and is under GPLv3 which is too restrictive for my (BSD-licensed) project, http://effbot.org/librarybook/formatter-example-3...