Hello,
I'm trying to catch an "EOFError" exception that occurs when reading
truncated tarfile. Here's my routine, and below that the callback
trace. Note that although I'm trying to catch all TarFile exceptions,
the tarfile.EOFErro r ecxeption, and the global EOFError exception, the
program still falls through and fails.
def query_archive(b atch_base):
arc_name = os.path.join(ar chive_dir, 'B_'+batch_base +'.tar.bz2')
sys.stderr.writ e('Archive: %s ' % arc_name)
try:
archive = tarfile.open(ar c_name, 'r:bz2')
members = archive.getmemb ers()
except tarfile.TarErro r, EOFError, tarfile.EOFErro r:
sys.stderr.writ e("corrupt.\n ")
db.execute('UPD ATE Archives SET Status=2 WHERE BatchBase=?',
(batch_base, ))
update_batchinf o(members, batch_base)
return 0
Archive: f:/wafermap_archiv e/B_48380.tar.bz2 Traceback (most recent
call last):
File "./wmap", line 11, in <module>
task.run(comman d, args)
File "/cygdrive/h/wafermaps/wmap_import.py" , line 142, in run
query_archive(b atch_base)
File "/cygdrive/h/wafermaps/wmap_import.py" , line 95, in
query_archive
members = archive.getmemb ers()
File "/usr/lib/python2.5/tarfile.py", line 1282, in getmembers
self._load() # all members, we first have to
File "/usr/lib/python2.5/tarfile.py", line 2003, in _load
tarinfo = self.next()
File "/usr/lib/python2.5/tarfile.py", line 1809, in next
self.fileobj.se ek(self.offset)
EOFError: compressed file ended before the logical end-of-stream was
detected
I'm trying to catch an "EOFError" exception that occurs when reading
truncated tarfile. Here's my routine, and below that the callback
trace. Note that although I'm trying to catch all TarFile exceptions,
the tarfile.EOFErro r ecxeption, and the global EOFError exception, the
program still falls through and fails.
def query_archive(b atch_base):
arc_name = os.path.join(ar chive_dir, 'B_'+batch_base +'.tar.bz2')
sys.stderr.writ e('Archive: %s ' % arc_name)
try:
archive = tarfile.open(ar c_name, 'r:bz2')
members = archive.getmemb ers()
except tarfile.TarErro r, EOFError, tarfile.EOFErro r:
sys.stderr.writ e("corrupt.\n ")
db.execute('UPD ATE Archives SET Status=2 WHERE BatchBase=?',
(batch_base, ))
update_batchinf o(members, batch_base)
return 0
Archive: f:/wafermap_archiv e/B_48380.tar.bz2 Traceback (most recent
call last):
File "./wmap", line 11, in <module>
task.run(comman d, args)
File "/cygdrive/h/wafermaps/wmap_import.py" , line 142, in run
query_archive(b atch_base)
File "/cygdrive/h/wafermaps/wmap_import.py" , line 95, in
query_archive
members = archive.getmemb ers()
File "/usr/lib/python2.5/tarfile.py", line 1282, in getmembers
self._load() # all members, we first have to
File "/usr/lib/python2.5/tarfile.py", line 2003, in _load
tarinfo = self.next()
File "/usr/lib/python2.5/tarfile.py", line 1809, in next
self.fileobj.se ek(self.offset)
EOFError: compressed file ended before the logical end-of-stream was
detected
Comment