Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Windows gzip problem

Reply
Thread Tools

Windows gzip problem

 
 
John Earls
Guest
Posts: n/a
 
      02-28-2008
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
 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      02-29-2008
En Thu, 28 Feb 2008 21:09:30 -0200, John Earls <(E-Mail Removed)>
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

 
Reply With Quote
 
 
 
 
John Earls
Guest
Posts: n/a
 
      02-29-2008
On Feb 28, 6:57 pm, "Gabriel Genellina" <(E-Mail Removed)>
wrote:
> En Thu, 28 Feb 2008 21:09:30 -0200, John Earls <(E-Mail Removed)>
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python doc problem example: gzip module (reprise) Byron Rios Python 0 06-21-2008 11:36 PM
Python doc problem example: gzip module (reprise) Xah Lee Perl Misc 10 11-09-2005 02:00 PM
Python doc problem example: gzip module (reprise) Xah Lee Python 25 11-09-2005 02:00 PM
Re: gzip HTTP results problem Fredrik Lundh Python 1 07-29-2003 09:39 PM
gzip HTTP results problem Bill Loren Python 0 07-29-2003 11:08 AM



Advertisments