RE: [Tutor] Trying to d0 HTTP GET

2005-04-18 Thread Ertl, John
This data set is 65160 bytes.  I am having a bit more success with urllib2
but still not there yet...byte swapping and such.  But now I think the
server is having problems.

Thanks for your help.

-Original Message-
From: Kent Johnson [mailto:[EMAIL PROTECTED]
Sent: Monday, April 18, 2005 13:10
Cc: tutor@python.org
Subject: Re: [Tutor] Trying to d0 HTTP GET

Ertl, John wrote:
> All,
>
> 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.

I would think that
f = urllib.urlopen(...)
data = f.read()

would work. You could try urllib2.urlopen() and see if it is any better.

How big is the data you are expecting?

Kent

>
> 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.
> 
>
http://dsd1u:7003/GRID:U:WW3_GLOBAL:2005041512:global_360x181:max_wav_ht:sur
> face:::fcst_ops:0480
>
> 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 =
>
>
urllib.urlopen("http://dsd1u:7003/GRID:U:WW3_GLOBAL:2005041800:global_360x18
> 1:max_wav_ht:surface:::fcst_ops:0240")
>
>>>>f.info()
>
> 
>
>>>>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? 
>
> Thanks,
>
> John Ertl
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Trying to d0 HTTP GET

2005-04-18 Thread Kent Johnson
Ertl, John wrote:
All,
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.
I would think that
f = urllib.urlopen(...)
data = f.read()
would work. You could try urllib2.urlopen() and see if it is any better.
How big is the data you are expecting?
Kent
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.
 
http://dsd1u:7003/GRID:U:WW3_GLOBAL:2005041512:global_360x181:max_wav_ht:sur
face:::fcst_ops:0480

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 =
urllib.urlopen("http://dsd1u:7003/GRID:U:WW3_GLOBAL:2005041800:global_360x18
1:max_wav_ht:surface:::fcst_ops:0240")
f.info()

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?  

Thanks,
John Ertl 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor