python

Auto-generating WSDL file for a Python Twisted SOAP Server

Any recommendations for auto-generating the WSDL for a Python/Twisted SOAP Server? I've found lots of examples for taking an existing WSDL and generating the stubbed Python code, but am looking for the reverse operation. ...

Need help with comparing two pictures in Python.

Hey guys, Im working on an assignment for my comp sci class, I dont know where Im going wrong here. The function is supposed to take two pictures, pic1 and pic2, and return how different they are. Heres what I have def smart_difference(pic1, pic2): '''Given two Pictures, pic1 and pic2 of any size and colour, return the differe...

List Comprehension in Nested Lists

Hi all, I have a list like [["foo", ["a", "b", "c"]], ["bar", ["a", "b", "f"]]] and I'm wanting to split it out so I can get a count of the total number of As, Bs, etc. but I'm new to Python and having a bit of a time of it. I'm using [lx for lx in [li[1] for li in fieldlist if li[1]]] to try and get a list with all of the items in th...

Jython: subprocess.Popen runs out of file descriptors

I'm using the Jython 2.51 implementation of Python to write a script that repeatedly invokes another process via subprocess.Popen and uses PIPE to pipe stdout and stderr to the parent process and stdin to the child process. After several hundred loop iterations, I seem to run out of file descriptors. The Python subprocess documentati...

Best way to submit data to a form using Python?

I have not worked with web programming or web forms before so I am lost here. There is a simple perl/cgi <form method="post" action="/gestalt/cgi-pub/Kaviar.pl" enctype="multipart/form-data"> Now I tried looking at questions here, did a google search and read some about urllib2 etc. I guess I don't know enough about this to pick up f...

How can I profile python code line-by-line?

I've been using cProfile to profile my code, and it's been working great. I also use gprof2dot.py to visualize the results (makes it a little clearer). However, cProfile (and most other python profilers I've seen so far) seem to only profile at the function-call level. This causes confusion when certain functions are called from diffe...

Documenting Python scripts for non-programmers

We are currently looking for ways to help the non-programming members of the sysadmin group familiarize themselves with Python scripts used for day-to-day sysadmin tasks. Does anyone have any suggested documentation tools or best practices that we might find useful for this purpose? Edit to address S.Lott's comment: First, my apologie...

Is it possible to overload from/import in Python?

Is it possible to overload the from/import statement in Python? For example, assuming jvm_object is an instance of class JVM, is it possible to write this code: class JVM(object): def import_func(self, cls): return something... jvm = JVM() # would invoke JVM.import_func from jvm import Foo ...

lxml cleaner with a custom tag?

I want to use lxml cleaner to get rid of all html, but then a regex to autolink something: [ABC] -> <a href="bah bah bah">ABC</a> what is the right way to handle this without xss and such? ...

Send files from form directly to remote server

In my application I'm dealing with upload of really big image files. They will be stored on a remote server, so from what I was able to learn I need to write some custom Storage system (probably with the use of python's poster module). Because of the size I would like to send the files directly to media server without storing them in mem...

rounding-up numbers within a tuple

Is there anyway I could round-up numbers within a tuple to two decimal points, from this: ('string 1', 1234.55555, 5.66666, 'string2') to this: ('string 1', 1234.56, 5.67, 'string2') Many thanks in advance. ...

Measuring internet data transfers

Is there any way in python for S60 (using the python 2.5.4 codebase) to track the amount of data transferred over the mobile device's internet connection? ...

Struggling to draw something onto a full screen canvas on n95

Hey, I'm trying to work out how to use canvas in PyS60 on the n95. I'm attempting to draw a rectangle that will fill the whole screen, but the rectangle seems to get cut off. This is the code: import e32, appuifw #Define the exit function app_lock=e32.Ao_lock() def quit(): app_lock.signal() appuifw.app.exit_key_handler=quit canv...

Ideas for managing snippets of code in windows?

I am using a folder full of notepad files. Are there better ways? ...

500 Error when sending file from python to django

I've found a nice python module for sending data to remote servers via HTTP POST called poster. So I've wrote a simple view on my django app to receive and store data and then tried to send some file. Unfortunatelly even though I've set everything as it was shown in the instruction I'm getting Internal Server Error. Can anyone maybe see ...

How to print the top 10 users by the number of processes ?

How could I print the top 10 users on a linux distribution by the number of processes they have running? I have managed to do this using a shell script, but now I'm interested at how I can do this using Python. ...

Filesnames with FUSE and IMAP

I want to build a fuse-filesystem with IMAP4 in python. As filename I would like to use the subject of each mail. So I can rename the filenames and with this the Subjects. But subjects can be used several times in one directory, so this breaks the common filesystem rules. I wouldn't like to use a difficult directory-system (like here) no...

String Comparison with a Format - Python

I wanted to check if user has entered the input in particular order or not. Basically i wanted user to input date in format like this %d/%m/%y %H:%M Is there any way i can compare string input with the above format in python? ...

Options for handling javascript heavy pages while screen scraping

Disclaimer here: I'm really not a programmer. I'm eager to learn, but my experience is pretty much basic on c64 20 years ago and a couple of days of learning Python. I'm just starting out on a fairly large (for me as a beginner) screen scraping project. So far I have been using python with mechanize+lxml for my browsing/parsing. Now I'm...

python for loop, how to find next value(object)?

HI, I'm trying to use for loop to find the difference between every two object by minus each other. So, how can I find the next value in a for loop? for entry in entries: first = entry # Present value last = ?????? # The last value how to say? diff = last = first ...