writing serial port data to the gzip file
Petr Jakes
mcbooczech at gmail.com
Sun Dec 17 20:06:33 EST 2006
I am trying to save data it is comming from the serial port continually
for some period.
(expect reading from serial port is 100% not a problem)
Following is an example of the code I am trying to write. It works, but
it produce an empty gz file (0kB size) even I am sure I am getting data
from the serial port. It looks like g.close() does not close the gz
file.
I was reading in the doc:
Calling a GzipFile object's close() method does not close fileobj,
since you might wish to append more material after the compressed
data...
so I am completely lost now...
thanks for your comments.
Petr Jakes
==== snippet of the code ====
def dataOnSerialPort():
data=s.readLine()
if data:
return data
else:
return 0
while 1:
g=gzip.GzipFile("/root/foofile.gz","w")
while dataOnSerialPort():
g.write(data)
else: g.close()
More information about the Python-list
mailing list