python

how can paramiko get ssh command return code

client = paramiko.SSHClient() stdin, stdout, stderr = client.exec_command(command) Is there any way to get the command return code? It's hard to parse all stdout/stderr and know whether the command finished successfully or not. ...

Python Threading socket

Hi Alls, I'm trying to implement a threading functionality for this answer : http://stackoverflow.com/questions/3491727/scanning-a-class-c-network-python/3492399#3492399 So far i have something like this: ...[snip].. m = re.search("/", str(host)) if m : net,_,mask = host.partition('/') mask = int(mask) net = atod(net) for...

How to check if DataStore Indexes are being served on AppEngine?

How can I check if datastore Indexes as defined in index.yaml are serving in the python code? I am using Python 1.3.6 AppEngine SDK. ...

When would my Python test suite file coverage not be 100%?

We are using Hudson and coverage.py to report the code coverage of our test suite. Hudson breaks down coverage into: packages files classes lines conditionals Coverage.py only reports coverage on files executed/imported during the tests, and so it seems is oblivious to any files not executed during the tests. Is there ever an instanc...

How to decode the pixels in a JPG in App Engine (using pure python) ?

Using python App Engine I need to convert a JPG image that is one 9 MB file (of Pakistan's floods) into many PNG tiles. For the PNG part, I already know how to use PyPNG, which is great. Note: PIL cant be used with App Engine. So how do I decode the JPG into pixel data? ...

how can I maintain sequence of my list using set?

In [1]: l1 = ['a',2,3,0,9.0,0,2,6,'b','a'] In [2]: l2 = list(set(l1)) In [3]: l2 Out[3]: ['a', 0, 2, 3, 6, 9.0, 'b'] Here you can see the the list l2 is falling with different sequence then the original l1, I need to remove the duplicate elements from my list without changing the sequence/order of the list elements.... ...

Polymorphism or Inheritance or any other suggestion?

Hi, I trying my hands on python. I am trying to implement a crypto class which does enc/dec . In my crypto class i require user to pass 3 args to do the enc dec operations. Till now i was reading key from file and doing the operations. Now i want to provide a generate key function also. But problem is that to call generate keys i dont w...

Java and Python App/Service Communication with Web Interface

Hi All, Currently I have a Java (and a half ported python version) app that runs in the background that has a queue of jobs (currently read out of a mysql database) which handles thread sleep/waking to share resources based on the job priority and running time. There is a front end php script that posts jobs to the database which are po...

How to add python support to already installed postgreSQL?

I have postgreSQL version 8.3 installed on an ubuntu machine. This was installed via apt get. When I was trying to source a database dump that has some plsql functions written, I got the following error - could not access file "$libdir/plpython": No such file or directory When I tried to enable python support for a particular databas...

url encoding/decoding with python

I am trying to encode and store, and decode arguments in python and getting lost somewhere along the way. Here are my steps: 1) I use google toolkit's gtm_stringByEscapingForURLArgument to convert an NSString properly for passing into http arguments. 2) On my server (python), I store these string arguments as something like u'1234567...

Python module installed or not installed?

Hi, How can I check if my Python module is successfully installed. I did: python setup.py install inside the folder where my module was downloaded. Now, I can see that this resulted in a folder inside this location: /usr/lib/python2.4/site-packages (I can see my module folder is inside here) Now I am using PHP to execute a script...

Gearman worker not woken up MACOSx python

I tried to run the example gearman client and workers. Gearman worker never seems to be woken up. I see the following message when I kill the gearman worker and I don't see the output at the worker(print statements) File "gearman_w.py", line 12, in worker.work() File "/opt/local/Library/Frameworks/Python.framework/Versions...

Can search(r'(ab)+', "ababababab") match all the characters in python

I found that findall(r'(ab)+', "ababababab") can only match the ["ab"] >>> re.findall(r'(ab)+', "ababababab") ['ab'] i just know that using r'(?:ab)+' can match all the characters >>> re.findall(r'(?:ab)+', "ababababab") ['ababababab'] Why does this happen? ...

stored procedures with sqlAlchemy

How can I call stored procedures of sql server with sqlAlchemy? ...

Google map plotting

I was wondering if anyone has any ideas/tutorials on how to plot various points on a google map, and save the points in a database with custom marker titles. I want something similar to http://www.mapmyrun.com/create_new , where i can actually draw on a map and mark out paths and such. ...

Decorator changing function status from method to function

[Updated]: Answer inline below question I have an inspecting program and one objective is for logic in a decorator to know whether the function it is decorating is a class method or regular function. This is failing in a strange way. Below is code run in Python 2.6: def decorate(f): print 'decorator thinks function is', f ret...

Which cross platform scripting language should we adopt for a group of DBAs?

Hi there, I wanted to get the community's feedback on a language choice our team is looking to make in the near future. We are a software developer, and I work in a team of Oracle and SQL Server DBAs supporting a cross platform Java application which runs on Oracle Application Server. We have SQL Server and Oracle code bases, and supp...

Ipod touch, python and BtStack

Does any one have tips on accessing the ipod's bluetooth functionality though python forgot to say im using a jail broken ipod touch 3g running 3.1.3 ...

Python in OpenOffice 3

Hello, I have a heap of Lotus 123 spreadsheets (not written by me) with Lotus Scripts in them doing an awful lot of leg work (moving data from one spreadsheet to another, and other things like that). I am making the consideration of moving it all away from Lotus 98 and going to something a little more open, like OpenOffice. I was wonde...

Python, mechanize, proper syntax for setting multiple headers?

I can't seem to find how to do this anywere, I am trying to set multiple headers with python's mechanize module, such as: br.addheaders = [('user-agent', ' Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3')] br.addheaders = [('accept', 'text/html,application/xhtml+xml,application/xm...