python

paramiko SSH exec_command(shell script) returns before completion

I launch a shell script from a remote Linux machine using paramiko. The shell script is launched and execute a command make -j8. However the exec_command returns before the completion of the make. If I launch the script on the local machine it executes correctly. Could someone explain me this behaviour ? ...

Generating a CSR in Python

I'm trying to generate a CSR in Python without using OpenSSL. If someone could point in the right direction, I'd be very grateful. ...

ImportError: [libraryname].so: undefined symbol: [function name]

I'm extending my Python program with a C module that uses the GstPhotography interface for GStreamer. My C module compiles fine, but when I try running it from Python, I get this error: $python Program.py Traceback (most recent call last): File "Program.py", line 10, in <module> import MyPythonClass File "/path/MyPythonClass....

Extract Meta Keywords From Webpage?

I need to extract the meta keywords from a web page using Python. I was thinking that this could be done using urllib or urllib2, but I'm not sure. Anyone have any ideas? I am using Python 2.6 on Windows XP ...

(Django) object is unsubscriptable

When I'm trying to create an extended user profile I'm getting UserProfile object is unsubscriptable. I've googled for solution, but 'your object is not a sequence' does not help here much. Here's the function I'm using, 'temp_data' is the data from my registration form : def create_user(request): data = request.session['temp_da...

MySQLdb Handle Row Lock

I'm using MySQLdb and when I perform an UPDATE to a table row I sometimes get an infinite process hang. At first I thought, maybe its COMMIT since the table is Innodb, but even with autocommit(True) and db.commit() after each update I still get the hang. Is it possible there is a row lock and the query just fails to carry out? Is there...

Python and HTML: Not all arguments converted to a string

I writing HTML to a text file which is then read by the browser, but I get an error stating "not all arguments converted during string formatting" But i can't see hwere im going wrong. z.write('<td><a href=/Plone/query/species_strain?species=%s>'+k+'</td>' % k) ...

I'm running nginx with fastcgi, is that all I need to serve python apps also?

I'm running ubuntu with nginx with fastcgi, is that all I need to serve python apps also? ...

lists and sublists

i use this code to split a data to make a list with three sublists. to split when there is * or -. but it also reads the the \n\n *.. dont know why? i dont want to read those? can some one tell me what im doing wrong? this is the data *Quote of the Day -Education is the ability to listen to almost anything without losing your temper or ...

sorting by arbitrary lambda in Python

How can I sort a list by a key described by an arbitrary function? For example, if I have: mylist = [["quux", 1, "a"], ["bar", 0, "b"]] I'd like to sort "mylist" by the second element of each member, e.g. sort(mylist, key=lambda x: x[1]) how can I do this? thanks. ...

Python function implementations

I've seen various answers to the ball collision detection question explaining why sqrt operations are slow, why absolute value operations are fast on floating ponts etc. How can I find out which operations are expensive and which are not? Basically, I'm looking for a resource where I can learn about the implementation of all the python ...

Socket in python will only send data it receives

I must be missing something in the code. I've rewritten an 'echo server' example to do a bit more when it receives something. This is how it currently looks: #!/usr/bin/env python import select import socket import sys import threading import time import Queue globuser = {} queue = Queue.Queue() class Server: def __init__(self)...

Entering precise degrees into python

What is the standard way to enter degrees into python? My total station gives degrees in degree-minute-second format. I could write a function to convert this to a decimal degree but I would like to know if there is a common way to do this that I am unaware of. -Chris ...

Which of `if x:` or `if x != 0:` is preferred in Python?

Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing. Does Python have a preference? A link t...

If x is list, why does x += "ha" work, while x = x + "ha" throw an exception?

From what little I know, + op for lists only requires the 2nd operand to be iterable, which "ha" clearly is. Thanks in advance. In Code: >>> x = [] >>> x += "ha" >>> x ['h', 'a'] >>> x = x + "ha" Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: can only concatenate list (not "str") to list ...

Python: Amazon AWS interface?

Googling reveals several Python interfaces to Amazon AWS. Which are the most popular, feature-complete, etc? ...

Help me translate Python code which replaces an extension in file name to C++.

I apologize if you know nothing about Python, however, the following snippet should be very readable to anyone. The only trick to watch out for - indexing a list with [-1] gives you the last element if there is one, or raises an exception. >>> fileName = 'TheFileName.Something.xMl' >>> fileNameList = fileName.split('.') >>> assert(len(f...

Perceptual Hash Algorithms in Python or PHP?

I've been exposed via StackOverflow to pHash, a C++ perceptual hash library for audio, video, images, and text fingerprinting - recently with preliminary bindings for PHP, C# and Java. I'm interested in studying these algorithms and I'm wondering if there are any open-source pure Python or PHP implementations of the same / similar algor...

Class attributes reset when imported from package

I have a project that is organized something like project/ __init__.py builder.py component/ __init__.py Within builder.py, I have a class called Builder that has several class attributes in order to implement the Borg pattern. The trouble arises when I try to import Builder in component/__init__.py and make change...

Is it possible to use soaplib server with Apache?

Almost every documentation I am seeing shows Soaplib servers to be deployed using Cherry Py or some other server. Instead of that can be be deployed using apache? Thanks ...