Windows gzip problem

Discussion in 'Python' started by John Earls, Feb 28, 2008.

  1. John Earls

    John Earls Guest

    Hello,

    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

    --end error--
    I tried playing around with the wb/rb when writing and unzipping, like
    this post [http://groups.google.com/group/comp.lang.python/
    browse_thread/thread/96651e3cd2dc6070/e94ae3b22fc78a1b?lnk=gst&q=gzip
    +windows#e94ae3b22fc78a1b] suggested and that did not seem to change
    anything.

    I would really appreciate any assistance on this.

    Thanks

    John
     
    John Earls, Feb 28, 2008
    #1
    1. Advertising

  2. En Thu, 28 Feb 2008 21:09:30 -0200, John Earls <>
    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
     
    Gabriel Genellina, Feb 29, 2008
    #2
    1. Advertising

  3. John Earls

    John Earls Guest

    On Feb 28, 6:57 pm, "Gabriel Genellina" <>
    wrote:
    > En Thu, 28 Feb 2008 21:09:30 -0200, John Earls <>
    > 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.
     
    John Earls, Feb 29, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bill Loren

    gzip HTTP results problem

    Bill Loren, Jul 29, 2003, in forum: Python
    Replies:
    0
    Views:
    313
    Bill Loren
    Jul 29, 2003
  2. Fredrik Lundh

    Re: gzip HTTP results problem

    Fredrik Lundh, Jul 29, 2003, in forum: Python
    Replies:
    1
    Views:
    325
    John J. Lee
    Jul 29, 2003
  3. Xah Lee
    Replies:
    25
    Views:
    894
    Jeffrey Schwab
    Nov 9, 2005
  4. Byron Rios
    Replies:
    0
    Views:
    252
    Byron Rios
    Jun 22, 2008
  5. Xah Lee
    Replies:
    10
    Views:
    524
    Jeffrey Schwab
    Nov 9, 2005
Loading...

Share This Page