corrupt download with urllib2
Ulli Horlacher
framstag at rus.uni-stuttgart.de
Tue Nov 10 08:43:11 EST 2015
Peter Otten <__peter__ at web.de> wrote:
> > It works with Linux, but not with Windows 7, where the downloaded 7za.exe
> > is corrupt: it has the wrong size, 589044 instead of 587776 Bytes.
> >
> > Where is my error?
>
> > sz = path.join(fexhome,'7za.exe')
> > szurl = "http://fex.belwue.de/download/7za.exe"
> >
> > try:
> > szo = open(sz,'w')
>
> Open the file in binary mode to avoid the translation of "\n" into "\r\n":
>
> szo = open(sz, 'wb')
Damn.. I should have known this!
Ok, now it works like on Linux. Windows is such a *BEEEP* *CENSORED*
> > except (IOError,OSError) as e:
> > die('cannot write %s - %s' % (sz,e.strerror))
>
> Unrelated, but I recommend that you let the exceptions bubble up for easier
> debugging.
die() is my debugging function :-)
> Python is not Perl ;)
*sigh* This is the problem ;-)
I am a Perl programmer for more than 25 years...
--
Ullrich Horlacher Server und Virtualisierung
Rechenzentrum IZUS/TIK E-Mail: horlacher at tik.uni-stuttgart.de
Universitaet Stuttgart Tel: ++49-711-68565868
Allmandring 30a Fax: ++49-711-682357
70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/
More information about the Python-list
mailing list