python

Using zeromq in a distributed load pipeline, can I get the address of the last server a message was sent to

If I set up a pipeline which distributes load across a cluster, I would like to log where the messages get sent. This is what I have in mind (python): import zmq context = zmq.Context() socket = context.socket(zmq.DOWNSTREAM) socket.connect("tcp://127.0.0.1:5000") socket.connect("tcp://127.0.0.1:6000") msg = "Hello World\0" connection...

python thread queue question..

Hell All. i was made some python script with thread which checking some of account exist in some website if i run thread 1 , it working well but if increase thread such like 3~5 and above, result was very different compare with thread 1 and i was checked manually and if i increase thread result was not correct. i think some of my ...

Continous loop and exiting in python

I have a script that runs continuously when invoked and every 5 minutes checks my gmail inbox. To get it to run every 5 minutes I am using the time.sleep() function. However I would like user to end the script anytime my pressing q, which it seems cant be done when using time.sleep(). Any suggestions on how i can do this? Ali ...

Two Tkinter Questions

Is it possible to change the color of certain particular bits of text in the entry widget, or does it all have to be the same color? Is it possible to change the Tk logo in the top right to a different image? ...

PHP HTTP server? Ports 80, 443-444, 1000-3000, 8000-9000. (No-Apache)

I will upgrading to Linux Debian 6.0 "Squeeze" on the server soon and I want to know how I can use Python as a web-server on many ports dedicated for different things.. Ports Directory Description 80, 443 /var/www/sitegen/ Take all domains and generate a site from the SQL DB 444, 1000-3000 /var/www/mana...

How to parse the "request body" using python CGI?

I just need to write a simple python CGI script to parse the contents of a POST request containing JSON. This is only test code so that I can test a client application until the actual server is ready (written by someone else). I can read the cgi.FieldStorage() and dump the keys() but the request body containing the JSON is nowhere to ...

Connected Component labelling -gray scale image

I tried to modify the code given in http://stackoverflow.com/questions/1989987/my-own-ocr-program-in-python for finding the connected components in a gray scale image. Ive attached the code,sample image and output below. Sample Image Output: But the connected components obtained is not correct. Please suggest some solution for th...

Which XML style is better when handling it with Python's ElementTree?

I'd like to store some relatively simple stuff in XML in a cascading manner. The idea is that a build can have a number of parameter sets and the Python scripts creates the necessary build artifacts (*.h etc) by reading these sets and if two sets have the same parameter, the latter one replaces the former. There are (at least) two diffe...

django python: How to use the source instead of the egg?

Hi there, I was having some issues with a Django app called "django-categories" The developer told me to use the source instead of the egg. How do I do that? ...

How to get Network Interface Card names in Python?

Hi there! I am totally new to python programming so please be patient with me. Is there anyway to get the names of the NIC cards in the machine etc. eth0, lo? If so how do you do it? I have researched but so far I have only found codes to get IP addresses and MAC addresses only such as import socket socket.gethostbyname(socket.gethostn...

Python set intersection question

I have three sets: s0 = [set([16,9,2,10]), set([16,14,22,15]), set([14,7])] # true, 16 and 14 s1 = [set([16,9,2,10]), set([16,14,22,15]), set([7,8])] # false I want a function that will return True if every set in the list intersects with at least one other set in the list. Is there a built-in for this or a simple list comprehen...

Is there a way to use the java browsing perspective of eclipse for python?

I'd like to use the browsing perspective ("column view") of eclipse for Python development. Is there a way to do this? ...

Redirection error in Python script

Hi there! I have 2 python scripts which are main_menu.py and inputip.py. The problem occurs when I press "enter" to be redirected to main_menu.py when my function finishes in iputip.py. The script does not allow me to redirect to main_menu.py instead it shows this error on the Windows command prompt: Traceback (most recent call last): ...

Python and executing php files?

Possible Duplicate: Start local PHP script w/ local Python script How do you execute a php file and then view the output of it? os.system("php ./index.php") Does not work only returns 0 ...

Python : No translation file found for domain using custom locale folder

Hi there, I have the following structure : / |- main.py |- brainz | |- __init__.py | |- Brainz.py |- datas |- locale |- en_US |- LC_MESSAGES |- brainz.mo |- brainz.po In my __init__.py there is the following lines : import locale import gettext import os cu...

How to create a simple Gradient Descent algorithm

Hi everyone, i'm studying simple machine learning algorithms, beginning with a simple gradient descent, but i've got some trouble trying to implement it in python. here is the example i'm trying to reproduce, i've got data about houses with the (living area (in feet2), and number of bedrooms) with the resulting price : Living area (...

How to resolve DNS in Python?

Hi there! I have a DNS script which allow users to resolve DNS names by typing website names on a Windows command prompt. I have looked through several guides on the DNS resolve but my script can't still seem to resolve the names (www.google.com) or (google.com) to IP address. The script outputs an error of Traceback (most recent cal...

How can I check if a point is below a line or not ?

How can I check if a point is below a line or not ? I've the following data: Line [ {x1,y1}, {x2,y2} ] Points {xA,yA}, {xB,yB} ... I need to write a small algorithm in python to detect points on one side and the other side of the line. thanks ...

How can I check if 2 segments intersect ?

How can I check if 2 segments intersect ? I've the following data: Segment1 [ {x1,y1}, {x2,y2} ] Segment2 [ {x1,y1}, {x2,y2} ] I need to write a small algorithm in python to detect if the 2 lines are intersecting. thanks Update: ...

PIL crop and paste problem: Cropping doesn't create a cropped image

I'm trying to crop an image and then paste the cropped image into the centre of another image. Ideally I'd like the cropped image to be smaller than the image its being pasted on so that there is a border around the pasted image but I don't know if that's possible. Here's what I've tried (along with the resulting error message): >>> i...