Try to be a little less noisy about errors processing xls files

This commit is contained in:
Jean-Francois Dockes 2019-03-26 09:20:21 +01:00
parent 083a7dfcc1
commit a7f01c0b87
2 changed files with 17 additions and 4 deletions

View File

@ -73,16 +73,23 @@ class Executor(RclBaseHandler):
(fullcmd, err))
return (False, "")
for line in stdout:
postproc.takeLine(line.strip())
try:
for line in stdout:
postproc.takeLine(line.strip())
except:
return (False, "")
proc.wait()
try:
data = postproc.wrapData()
except:
return (False, "")
if (opt & self.opt_ignxval) == 0 and proc.returncode:
self.em.rclog("extractone: [%s] returncode %d" % \
(filename, proc.returncode))
return False, postproc.wrapData()
return False, data
else:
return True, postproc.wrapData()
return True, data
def extractone(self, params):
#self.em.rclog("extractone %s %s" % (params["filename:"], \

View File

@ -19,6 +19,8 @@ class XLSProcessData:
self.ishtml = ishtml
def takeLine(self, line):
if not line:
return
if self.ishtml:
self.out.append(line)
return
@ -31,6 +33,9 @@ class XLSProcessData:
self.xmldata.append(line)
def wrapData(self):
if not self.gotdata:
raise Exception("xls-dump returned no data")
return b''
if self.ishtml:
return b'\n'.join(self.out)
handler = xlsxmltocsv.XlsXmlHandler()
@ -62,6 +67,7 @@ class XLSFilter:
cmd = rclexecm.which("xls-dump.py")
if cmd:
# xls-dump.py often exits 1 with valid data. Ignore exit value
# We later treat an empty output as an error
return ([sys.executable, cmd, "--dump-mode=canonical-xml", \
"--utf-8", "--catch"],
XLSProcessData(self.em), rclexec1.Executor.opt_ignxval)