Use gzip python library instead of sys call for compressing buildlogs
Bug #3111 reported by
Celso Providelo
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Launchpad itself |
Fix Released
|
Low
|
Celso Providelo |
Bug Description
The original idea was to used the gzip python library to compress buildlog before storing in librarian, but it present a error decribed below:
"""
python.gzip presented weird errors at this point, most
related to incomplete file storage, the compressed file
was prematurely finished in a 0x00. Using system call for while
"""
this error needs to be further investigated to repair the current implementation, even if it works properly, the style is bad.
Changed in launchpad-buildd: | |
assignee: | nobody → malcolmcleaton |
Changed in launchpad-buildd: | |
status: | Unconfirmed → In Progress |
Changed in soyuz: | |
assignee: | nobody → cprov |
Changed in soyuz: | |
status: | Confirmed → In Progress |
Changed in soyuz: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
it's a simple example I wrote to use gzip and it works fine.
import gzip
import tempfile
import os
CONTENT = 'Hello World !!!'
def gzipContent( content) : mkstemp( suffix= ".gz") out_file_ name, mode='wb') file.write( content)
"""Return the filename of gzipped content."""
out_file_fd, out_file_name = tempfile.
gz_file = gzip.GzipFile(
gz_
gz_file.close()
return out_file_name
def fileSize(filename):
"""Return the real file size."""
_file = open(filename, 'r')
_file.seek(0,2)
size = _file.tell()
_file.close()
return size
def gunzipFile( filename) :
"""Uncompress filename and return its content """
gz_file = gzip.open(filename)
raw = gz_file.read()
gz_file.close()
return raw
if __name__ == '__main__':
filename = gzipContent( CONTENT)
print 'Compressed: %s' % (filename)
gz_size = fileSize(filename)
print 'Gzip file size: %d' % gz_size
content = gunzipFile( filename)
print 'Raw content: %s' % content
os. remove( filename)