python

measuring page request timing in pylons app?

How can I test the time it takes to render a pylons page request? Where do I hook this in? (and what class/method do I use to output this information) I'm sort of new to both pylons and python. ...

How do I access outer functions variables inside a closure(python 2.6)?

From wikipedia I need to access outer functions variables in a similar manner as using the 'nonlocal' keyword from python 3.x. Is there some way to do that in python 2.6? (Not necessarily using the nonlocal keyword) ...

Start interactive SSH session from Python script.

Hello, I'd like to start an interactive SSH terminal from a Python script without using modules like pexpect or paramiko - I want to stick with what CentOS pre-installed Python provides me (to ease compatibility and deployment issues). I can run commands fine using the subprocess module, but cannot get an interactive terminal. In Perl...

[numpy] creating a masked array from text fields

The numpy documentation shows an example of masking existing values with ma.masked a posteriori (after array creation), or creating a masked array from an list of what seem to be valid data types (integer if dtype=int). I am trying to read in data from a file (and requires some text manipulation) but at some point I will have a list of l...

Rename dictionary keys/values in python

What I'm trying to do is this. I have a dictionary laid out as such: legJointConnectors = {'L_hip_jnt': ['L_knee_jnt'], 'L_knee_jnt': ['L_ankle_jnt'], 'L_ankle_jnt': ['L_ball_jnt'], 'L_ball_jnt': ['L_toe_jnt']} What I want to be able to do is iterate through this, but change the L_ to R_. Here's how I tried to do it, but it failed, be...

Sphinx Search Engine & Python API

I am trying to use Sphinx Search Engine with their Python API. The installation went fine. But when I use their Python API I do not get the complete result set. I only get the ID's? But when I use their ./search binary in ./bin I get the entire indexed content. When using cpp ./search binary - ./search test 1. document=1, weight=1, gr...

Security considerations - office website/portal on GAE

If one needs to create an office website (that serves as a platform for clients/customers/employees) to login and access shared data, what are the security considerations. to give you some more detail, The office portal has been developed in django/python and hosted through GAE. Essentially, the end point comes with a login/password to...

clr.AddReferenceToFile() fails in IronPython 2.7

Can someone explain why this code: import sys sys.path.append("C:\\WINDOWS\\system32") import clr clr.AddReferenceToFile("wiimotelib.dll") works fine with IronPython 2.6, but fails in IronPython 2.7 alpha 1 with an IOException, and the message: Could not add reference to assembly wiimotelib.dll Is this new behaviour in 2.7, or is ...

Adding shared python packages to multiple virtualenvs

Current Python Workflow I have pip, distribute, virtualenv, and virtualenvwrapper installed into my Python 2.7 site-packages (a framework Python install on Mac OS X). In my ~/.bash_profile I have the line export PIP_DOWNLOAD_CACHE=$HOME/.pip_download_cache This gives a workflow as follows: $ mkvirtualenv pip-test $ pip install nose...

read/write in python !

Hello everyone, can someone help me do this : I first open a file: Date=open('Test.txt','r') but what I am looking for is how to read line number 12, then check if it contains the word "Hey!", and in that case print "Found Word", otherwise print "not found" and write "Hello Dude" after 30 letters. ...

Image Sent via XML from iPhone to App Engine

I am trying to send a small image along with some XML information to App Engine from my iPhone app. I am having trouble with the image somewhere along the path. There is no error given and data is being transfered into a Blob entry in Datastore Viewer but the blob files on App Engine do not appear in Blob Viewer. I have a suspicion t...

python qt, display text/label above another widget(phonon)

I'm making a video player using PySide which is a python bind to the Qt framework. I'm using phonon(a module) to display the video and I want to display text above the video as a subtitle. How can I put another widget above my phonon widget. Is opengl an option? ...

Create openVPN Certificate with python

Hi guys ... Do you guys know a python "script" that can generate openVPN certificates ? I need this to integrate it with my django project ... Thx. ...

Django admin - How can I add the green plus sign for Many-to-many Field in custom admin form

The green plus sign button for adding new instances in the admin form disappears for my MultiSelect field (photos) when I define it in my form. Ie, removing the line with the definition (photos = ...) makes the plus sign appear. However, in order to use a custom Field/Widget I need to figure this out. class GalleryForm(ModelForm): ...

'WSGIRequest' object has no attribute 'user'

I'm new to django and Google App Engine, and I'm having trouble with using the datastore. Every time I make a query, such as db.GqlQuery("SELECT * FROM Listing ORDER BY date DESC LIMIT 10") I receive the error: 'WSGIRequest' object has no attribute 'user' This error seems to be generated in context_processors.py within the django c...

How should a ZeroMQ worker safely "hang up"?

I started using ZeroMQ this week, and when using the Request-Response pattern I am not sure how to have a worker safely "hang up" and close his socket without possibly dropping a message and causing the customer who sent that message to never get a response. Imagine a worker written in Python who looks something like this: import zmq c ...

User specified date time

I need to parse a date/time string from user input, and convert to UTC based on timzeone info not available in the string for datetime.strptime() (any suggestions?). Is there a straightforward way of doing this? Ideally, on google app engine i'd like to grab local time with tzinfo from the browser if possible also. timezone_string = ...

Displaying a local gstreamer stream in a browser

I have a camera feed coming into a linux machine using a V4l2 interface as the source for a gstreamer pipeline. I'm building an interface to control the camera, and I would like to do so in HTML/javascript, communicating to a local server. The problem is getting a feed from the gst pipeline into the browser. The options for doing so seem...

from list to select menu in django

I thought I had it figured out but now I'm missing something. First I have a QuerySet, records records = Record.objects.all() Now I want to make this into a list of one of the columns of the table, columnA alist = records.values_list('columnA') And then I want to pass this list in as a parameter to a custom form. FilterForm(alist...

Why doesn't the save button work on a matplotlib plot?

I have matplotlib 1.0.0 installed in a Python 2.7 virtualenv on Mac OS X 10.6. I can create plots fine. However, whenever I press the Save button, I can't type text into the save dialog window nor can I save the plot. The only thing I can do is hit cancel. Any thoughts on what's causing this and how to fix it? Matplotlib installation ...