[Tutor] Trying to d0 HTTP GET

Ertl, John john.ertl at fnmoc.navy.mil
Mon Apr 18 20:02:40 CEST 2005


I am trying to get some binary data from a web service.  None of the tech
guys are around so I am hoping you might be able to shed some light on what
might be happening.

Here is part of the email that explained what I needed to do.

----- clip ---

If you can do an http "get" from Python, you'll be set.

It returns an http header like the following (if the grid exists), 
followed by the grid data in big-endian, IEEE format.

         "HTTP/1.1 200 OK\r\n"
         "Server: ISIS/4.0\r\n"
         "Content-type: application/x-grid\r\n"
         "Content-length: 261234\r\n\r\n"

----- end-----

The grid data is in Binary.  How would I get to this?  I would imagine that
since f (the object) exists the call to the web service worked. Now I need
to read the grid...eventually I need to put it into a Numeric array but not
sure how to get just the grid from "f".

As a simple starting point I tried.  

>>> import urllib
>>> f =
>>> f.info()
<httplib.HTTPMessage instance at 0xb9255f6c>
>>> f.readlines()

I tried read(), readLines() and some other stuff using scipy and Numeric.

The prompt has moved to the next line but nothing else has happened for 30
min or so (I have tried several times).  When I try to close IDLE it says
the program is still running.  How should I be getting this data is it
trying to read the binary and that is why it is stalled?  


John Ertl 

More information about the Tutor mailing list