Re: Windows gzip problem



On Feb 28, 6:57 pm, "Gabriel Genellina" <gagsl-...@xxxxxxxxxxxx>
wrote:
En Thu, 28 Feb 2008 21:09:30 -0200, John Earls <yt.r...@xxxxxxxxx>
escribió:



I am having a problem with gzip. The code worked fine under linux but
when I moved it over to windows it is getting stuck unzipping a gz
file.

-- snippet --

fileObj = gzip.GzipFile(iceGetter.file.localFileName, 'rb')
uncompressedFileName = iceGetter.file.localFileName[:-3]
output = open(uncompressedFileName, 'wb')
output.write(fileObj.read())
output.close()
fileObj.close()

-- snippet --

typing "python autoIce.py" gets this error:
--error--
Traceback(most recent call last):
File "runAuto.py", line 17 in ?
output.write(fileObj.read())
File "C:\Python24\lib\gzip.py". line 217 in read
self._read(readsize)
File "C:\Python24\lib\gzip.py", line 276 in _read
uncompress.decompress.decompress(buf)
Memory Error

Is the uncompressed file big? Instead of output.write(fileObj.read())
--that reads the whole contents in memory-- try
shutil.copyfileobj(fileObj, output)

--
Gabriel Genellina

That worked perfectly.

Thank you so much.

.



Relevant Pages

  • Re: Windows gzip problem
    ... when I moved it over to windows it is getting stuck unzipping a gz ... fileObj = gzip.GzipFile ... Gabriel Genellina ...
    (comp.lang.python)
  • Re: The Famous Error Message: "ImportError: No module named python_script"
    ... Yes of course the file has the ".py" extension and yes I went through ... Gabriel Genellina wrote: ... Windows Explorer options. ... Espacio para todos tus mensajes, ...
    (comp.lang.python)
  • Re: TIFF to PDF
    ... Gabriel Genellina said unto the world upon 05/21/2007 10:12 AM: ... \ is used as a escape character in strings. ... Use either \\ or a raw string, ... Windows is but a bitter memory for me, and / worked in every context in which I ever used it---I didn't know that the support was only partial. ...
    (comp.lang.python)
  • Windows gzip problem
    ... I am having a problem with gzip. ... The code worked fine under linux but ... when I moved it over to windows it is getting stuck unzipping a gz ...
    (comp.lang.python)
  • Re: Python 2.6 and wrapping C libraries on Windows
    ... Windows 2000 SP4. ... any reference. ... Gabriel Genellina ...
    (comp.lang.python)