mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-20 07:12:02 +02:00
18.0 vanilla
This commit is contained in:
parent
d72e748793
commit
0a7ae8db93
337 changed files with 399651 additions and 232598 deletions
|
|
@ -14,7 +14,6 @@ from lxml import etree
|
|||
from subprocess import Popen, PIPE
|
||||
|
||||
from .. import api
|
||||
from . import ustr, config
|
||||
from .safe_eval import safe_eval
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
|
@ -41,21 +40,20 @@ def try_report(cr, uid, rname, ids, data=None, context=None, our_module=None, re
|
|||
if res_format == 'pdf':
|
||||
if res_data[:5] != b'%PDF-':
|
||||
raise ValueError("Report %s produced a non-pdf header, %r" % (rname, res_data[:10]))
|
||||
res_text = False
|
||||
res_text = None
|
||||
try:
|
||||
fd, rfname = tempfile.mkstemp(suffix=res_format)
|
||||
os.write(fd, res_data)
|
||||
os.close(fd)
|
||||
|
||||
proc = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', rfname, '-'], shell=False, stdout=PIPE)
|
||||
stdout, stderr = proc.communicate()
|
||||
res_text = ustr(stdout)
|
||||
proc = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', rfname, '-'], shell=False, stdout=PIPE, encoding="utf-8")
|
||||
res_text, _stderr = proc.communicate()
|
||||
os.unlink(rfname)
|
||||
except Exception:
|
||||
_logger.debug("Unable to parse PDF report: install pdftotext to perform automated tests.")
|
||||
|
||||
if res_text is not False:
|
||||
for line in res_text.split('\n'):
|
||||
if res_text:
|
||||
for line in res_text.splitlines():
|
||||
if ('[[' in line) or ('[ [' in line):
|
||||
_logger.error("Report %s may have bad expression near: \"%s\".", rname, line[80:])
|
||||
# TODO more checks, what else can be a sign of a faulty report?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue