-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Diez B. Roggisch wrote:
> You could for instance try and see what kind of result you got using the
> unix file command - it will tell you that you received a html file, not a
> deb.
>
> Or check the mimetype returned - its text/html in the error case
Diez B. Roggisch wrote:
> It makes no sense having urllib generating exceptions for such a
case. From
> its point of view, things work pefectly - it got a result. No network
error
> or whatsoever.
>
> Its your application that is not happy with the result - but it has
to
> figure that out by itsel
.from urllib2 import urlopen
. try:
. urlopen(someURL)
. except IOError, errobj:
.if hasattr(errobj, 'reason'): print 'server doesnt exist, is
down, DNS prob, or we don't have internet connect'
.if hasattr(errobj, 'code'): print errobj.code
--
http://mail.python.org/mailma
>> For example, for Temporary Name Resolution Failure, python raises an
>> exception which I've handled well. The problem lies with obsolete
>> urls where no exception is raised and I end up having a 404 error
>> page as my data.
Diez> It makes no sense having urllib generatin
> I'm coding a program for offline package management.
> The link that I provided could be obsolete by newer packages. That is
> where my problem is. I wanted to know how to raise an exception here so
> that depending on the type of exception I could make my program function.
>
> For example, for
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Larry Bates wrote:
> I noticed you hadn't gotten a reply. When I execute this it put's the
> following in the retrieved file:
>
>
>
> 404 Not Found
>
> Not Found
> The requested URL /pool/updates/main/p/perl/libparl5.6_5.6.1-8.9_i386.deb
> was no
Mertz' "Text Processing in Python" book had a good discussion about
trapping 403 and 404's.
http://gnosis.cx/TPiP/
Larry Bates wrote:
> I noticed you hadn't gotten a reply. When I execute this it put's
the following
> in the retrieved file:
>
>
>
> 404 Not Found
>
> Not Found
> The requested
I noticed you hadn't gotten a reply. When I execute this it put's the following
in the retrieved file:
404 Not Found
Not Found
The requested URL /pool/updates/main/p/perl/libparl5.6_5.6.1-8.9_i386.deb was no
t found on this server.
You will probably need to use something else to first determ
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Hello Everybody,
I've got a small problem with urlretrieve.
Even passing a bad url to urlretrieve doesn't raise an exception. Or does
it?
If Yes, What exception is it ? And how do I use it in my program ? I've
searched a lot but haven't found anythi