issue5907.diff # [trytond] Remove unoconv and call soffice directly
This commit is contained in:
parent
849cc20113
commit
53c8c12298
|
@ -0,0 +1,72 @@
|
|||
diff --git a/trytond/trytond/report/report.py b/trytond/trytond/report/report.py
|
||||
index 4ace05ea..fb93276d 100644
|
||||
--- a/trytond/trytond/report/report.py
|
||||
+++ b/trytond/trytond/report/report.py
|
||||
@@ -1,6 +1,7 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
import os
|
||||
+import logging
|
||||
import datetime
|
||||
import tempfile
|
||||
import warnings
|
||||
@@ -13,13 +14,14 @@ try:
|
||||
except ImportError:
|
||||
Manifest, MANIFEST = None, None
|
||||
from genshi.filters import Translator
|
||||
-from trytond.config import config
|
||||
from trytond.pool import Pool, PoolBase
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.url import URLMixin
|
||||
from trytond.rpc import RPC
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
+logger = logging.getLogger(__name__)
|
||||
+
|
||||
MIMETYPES = {
|
||||
'odt': 'application/vnd.oasis.opendocument.text',
|
||||
'odp': 'application/vnd.oasis.opendocument.presentation',
|
||||
@@ -246,21 +248,32 @@ class Report(URLMixin, PoolBase):
|
||||
if output_format in MIMETYPES:
|
||||
return output_format, data
|
||||
|
||||
- fd, path = tempfile.mkstemp(suffix=(os.extsep + input_format),
|
||||
- prefix='trytond_')
|
||||
+ dtemp = tempfile.mkdtemp(prefix='trytond_')
|
||||
+ path = os.path.join(
|
||||
+ dtemp, report.report_name + os.extsep + input_format)
|
||||
oext = FORMAT2EXT.get(output_format, output_format)
|
||||
- with os.fdopen(fd, 'wb+') as fp:
|
||||
+ with open(path, 'wb+') as fp:
|
||||
fp.write(data)
|
||||
- cmd = ['unoconv', '--connection=%s' % config.get('report', 'unoconv'),
|
||||
- '-f', oext, '--stdout', path]
|
||||
try:
|
||||
- proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
- stdoutdata, stderrdata = proc.communicate()
|
||||
- if proc.wait() != 0:
|
||||
- raise Exception(stderrdata)
|
||||
- return oext, stdoutdata
|
||||
+ cmd = ['soffice',
|
||||
+ '--headless', '--nolockcheck', '--nodefault', '--norestore',
|
||||
+ '--convert-to', oext, '--outdir', dtemp, path]
|
||||
+ output = os.path.splitext(path)[0] + os.extsep + oext
|
||||
+ subprocess.check_call(cmd)
|
||||
+ if os.path.exists(output):
|
||||
+ with open(output, 'rb') as fp:
|
||||
+ return oext, fp.read()
|
||||
+ else:
|
||||
+ logger.error(
|
||||
+ 'fail to convert %s to %s', report.report_name, oext)
|
||||
+ return input_format, data
|
||||
finally:
|
||||
- os.remove(path)
|
||||
+ try:
|
||||
+ os.remove(path)
|
||||
+ os.remove(output)
|
||||
+ os.rmdir(dtemp)
|
||||
+ except OSError:
|
||||
+ pass
|
||||
|
||||
@classmethod
|
||||
def format_date(cls, value, lang):
|
2
series
2
series
|
@ -83,3 +83,5 @@ issue8058.diff # [stock_supply_production] Can't create productions from request
|
|||
issue8038.diff # [sale_supply_drop_shipment] Crash when process a purchase from purchase request created from a sale
|
||||
change_key_tax.diff # Change the key tax use to not separrete refunds and invoiceds on the same invocie, as in v5.2 do
|
||||
038993.diff # [sale] Remove permission error when changing a supplier invoice to draft
|
||||
|
||||
issue5907.diff # [trytond] Remove unoconv and call soffice directly
|
||||
|
|
Loading…
Reference in New Issue