urlretrieve() failing on me

Robert Dailey rcdailey at gmail.com
Fri Jun 5 20:53:50 EDT 2009


On Jun 5, 10:31 am, Peter Otten <__pete... at web.de> wrote:
> Robert Dailey wrote:
> > On Jun 5, 3:47 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
> >> En Thu, 04 Jun 2009 23:42:29 -0300, Robert Dailey <rcdai... at gmail.com>
> >> escribió:
>
> >> > Hey guys, try using urlretrieve() in Python 3.0.1 on the following
> >> > URL:
>
> >> >http://softlayer.dl.sourceforge.net/sourceforge/wxwindows/wxMSW-2.8.1...
>
> >> > Have it save the ZIP to any destination directory. For me, this only
> >> > downloads about 40KB before it stops without any error at all. Any
> >> > reason why this isn't working?
>
> >> I could not reproduce it. I downloaded about 300K without error  (Python
> >> 3.0.1 on Windows)
>
> >> --
> >> Gabriel Genellina
>
> > Can you show me your test code please?
>
> Here's mine:
>
> $ cat retriever.py
> import urllib.request
> import os
>
> def report(*args):
>     print(args)
>
> url = "http://softlayer.dl.sourceforge.net/sourceforge/wxwindows/wxMSW-2.8.1..."
> filename = url.rsplit("/")[-1]
>
> urllib.request.urlretrieve(url, filename=filename, reporthook=report)
> print(os.path.getsize(filename))
> $
>
> If you had shown your code in the first place the problem might have been solved by now...
>
> Peter

Well I did not post the code because it is fairly complex and its hard
to give you the whole picture without giving you too much code. But
here you go, you get what you ask for:


   def Download( self ):
      PrintSubStatus( 'Downloading...' )
      destination = normalize( '{0}/{1}'.format( self._info.outdir,
self._info.file_ext ) )
      print( self._info.url )
      print( destination )
      urlretrieve( self._info.url, destination )

Both print statements are shown as below:
http://easynews.dl.sourceforge.net/sourceforge/wxwindows/mxMSW-2.8.10.zip
D:\IT\personal\haresvn\temp\mxMSW-2.8.10.zip

I really can't figure out why this isn't working.



More information about the Python-list mailing list