python

How do I run Javascript tests in Windmill when using test_windmill for Django?

Hi, I'm using the Windmill test system and have it running using test_windmill for Django which works fine for the Python tests. I'd like this to run a suite of Javascript tests also whilst the Django test server is running. I've used the run_js_tests call from the Windmill shell which works fine but I can't find a way to have this run ...

fast java/python/C++ ipc

I notice this thread: Fastish Python/Jython IPC, and I have a similar problem, but in different language. I have a Java front-end and a C++ back-end, which I am thinking about rewrite it in Python in some near future. What will be the best IPC? I prefer socket to HTTP, as I am trying to avoid the HTTP overhead. And XML-RPC is an example...

Pycurl cannot connect to host

Hi, I am writing a pycurl script, which worked right on linux, but on mac os x I get the error: Traceback (most recent call last): File "curl.py", line 47, in <module> c.perform() pycurl.error: (7, "couldn't connect to host") any help? Thanks ...

Django - Access request.session in form

I am calling a form as follows, then passing it to a template: f = UserProfileConfig(request) I need to be able to access the request.session within the form... so first I tried this: class UserProfileConfig(forms.Form): def __init__(self,request,*args,**kwargs): super (UserProfileConfig,self).__init__(*args,**kwargs) ...

Can't import my module when start my twisted application under root

Here is absolutely minimal application so you could try to reproduce it on your machine. Having two files for example in /home/aln/tmp/tw_test: server.tac MyLib.py MyLib.py class Solver(object): def solve(self): """ do extremely complex stuff here """ print "Hello from solve" server.tac #!/usr/bin/python impor...

Set database connection timeout in Python

Hi, I'm creating a RESTful API which needs to access the database. I'm using Restish, Oracle, and SQLAlchemy. However, I'll try to frame my question as generically as possible, without taking Restish or other web APIs into account. I would like to be able to set a timeout for a connection executing a query. This is to ensure that lo...

How can I determine the final URL after redirection using python / urllib2?

I need to get the final URL after redirection in python. What's a good way to do that? ...

global set up in django test framework?

Is there some way (using the standard Django.test.TestCase framework) to perform a global initialization of certain variables, so that it only happens once. Putting things setUp() makes it so that the variables are initialized before each test, which kills performance when the setup involves expensive operations. I'd like to run a setup...

What is the best, python or bash for generating strings from combinations of letters?

Hi, I need to generate the strings STA and STB. STA and STB are strings of length 10, and each one can contain only the characters A,T,G or C. I have to generate all possible combinations of STA, and depending on STA, I generate STB. The ways is that the character A is always associated with T and viceversa and G with C and viceversa...

Django - Working with multiple forms

Hi everybody! What I'm trying to do is to manage several forms in one page, I know there are formsets, and I know how the form management works, but I got some problems with the idea I have in mind. Just to help you to imagine what my problem is I'm going to use the django example models: from django.db import models class Poll(model...

What are the possible pitfalls in porting Psyco to 64-bit?

The Psyco docs say: Just for reference, Psyco does not work on any 64-bit systems at all. This fact is worth being noted again, now that the latest Mac OS/X 10.6 "Snow Leopart" comes with a default Python that is 64-bit on 64-bit machines. The only way to use Psyco on OS/X 10.6 is by recompiling a custom Python in 32-...

Is it possible to get sqlalchemy to create a composite primary key with an integer part without making it an IDENTITY type?

I'm using sqlalchemy 6.0. The SQL Server T-SQL dialect seems to want to make any integer that's part of my primary key into an identity. That may be ok if the integer field were the primary key, but mine is a composite and this isn't going to work for me. Is there a way to suppress this behavior? Here's a demonstration of the problem: ...

Python win32crypt.CryptProtectData difference between 2.5 and 3.1?

I'm trying to hash a password to dump into a .rdp file. I found a site that (more or less) shows how to do that here but it doesn't work in 3.1. In 2.5.4 I get this: >>> import win32crypt >>> import binascii >>> pwdHash = win32crypt.CryptProtectData(u"password",u'psw',None,None,None,0) >>> print str(binascii.hexlify(pwdHash)).upper() 0...

Static Variables in Python C API

How would one expose "static" variables like this class MyClass: X = 1 Y = 2 via the C API? The only variable on the PyTypeObject that looks like it would work is tp_members, but I see no flag in the PyMemberDef to indicate that the member should be per-class, not per-instance. For a bit more clarification, since it may chang...

Python 2.x - Write binary output to stdout?

Is there any way to write binary output to sys.stdout in Python 2.x? In Python 3.x, you can just use sys.stdout.buffer (or detach stdout, etc...), but I haven't been able to find any solutions for Python 2.5/2.6. EDIT, Solution: From ChristopheD's link, below: import sys if sys.platform == "win32": import os, msvcrt msvcrt.se...

How do I calculate percentiles with python/numpy?

Is there a convenient way to calculate percentiles for a sequence or single-dimensional numpy array? I am looking for something similar to Excel's percentile function. I looked in NumPy's statistics reference, and couldn't find this. All I could find is the median (50th percentile), but not something more specific. ...

How does the following code in python work? How to work with struct_time objects

Hi if I do the following I can convert from a time_struct object to a datetime object: mydate = datetime.datetime(*time.localtime()[:6]) How does this code work? What do the * and the [:6] mean? ...

Generate image for each font on a linux system using Python

Hello, I'm looking for a way to list all fonts installed on a linux/Debian system, and then generate images of some strings using these fonts. I'm looking for your advice as I kind of see how to do each part, but not to do both: To list all fonts on a UNIX system, xlsfonts can do the trick: import os list_of_fonts=os.popen("xslfonts"...

How to do a dregradê on wx.Panel Background?

Hello, I want to color the background (SetBackgroundColour) of a wx.Panel with a blue to black degradê. How can I make it? ...

File Uploads with Turbogears 2

I've been trying to work out the 'best practices' way to manage file uploads with Turbogears 2 and have thus far not really found any examples. I've figured out a way to actually upload the file, but I'm not sure how reliable it us. Also, what would be a good way to get the uploaded files name? file = request.POST['file'] perma...