From ad91862c11b1361e7a0aeaaca180cf222f2a2a09 Mon Sep 17 00:00:00 2001 From: "nicolas.bessi@camptocamp.com" <> Date: Wed, 19 Jan 2011 15:50:32 +0100 Subject: [PATCH 1/3] [FIX] bug 704870 webkit_locals bzr revid: nicolas.bessi@camptocamp.com-20110119145032-61kf5gqi281x0br7 --- addons/report_webkit/webkit_report.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/report_webkit/webkit_report.py b/addons/report_webkit/webkit_report.py index 2944b768643..47d3e58482d 100644 --- a/addons/report_webkit/webkit_report.py +++ b/addons/report_webkit/webkit_report.py @@ -123,17 +123,17 @@ class WebKitParser(report_sxw): command.append("--footer-html '%s'"%(foot_file.name)) if webkit_header.margin_top : - command.append('--margin-top %s'%(webkit_header.margin_top)) + command.append('--margin-top %s'%(str(webkit_header.margin_top).replace(',', '.'))) if webkit_header.margin_bottom : - command.append('--margin-bottom %s'%(webkit_header.margin_bottom)) + command.append('--margin-bottom %s'%(str(webkit_header.margin_bottom).replace(',', '.'))) if webkit_header.margin_left : - command.append('--margin-left %s'%(webkit_header.margin_left)) + command.append('--margin-left %s'%(str(webkit_header.margin_left).replace(',', '.'))) if webkit_header.margin_right : - command.append('--margin-right %s'%(webkit_header.margin_right)) + command.append('--margin-right %s'%(str(webkit_header.margin_right).replace(',', '.'))) if webkit_header.orientation : - command.append("--orientation '%s'"%(webkit_header.orientation)) + command.append("--orientation '%s'"%(str(webkit_header.orientation).replace(',', '.'))) if webkit_header.format : - command.append(" --page-size '%s'"%(webkit_header.format)) + command.append(" --page-size '%s'"%(str(webkit_header.format).replace(',', '.'))) count = 0 for html in html_list : html_file = file(os.path.join(tmp_dir, str(time.time()) + str(count) +'.body.html'), 'w') From b6aae1062606f28fec2957a67f504e2d55ae405d Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 4 Apr 2011 18:33:07 +0200 Subject: [PATCH 2/3] [FIX] report_webkit: now works under Windows The following points correspond to the description JP Robiez gave in the bug report comments: No quotes around the templates filenames Use the subprocess module instead of the commands one Open explicitely the resulting pdf in binary mode lp bug: https://launchpad.net/bugs/704870 fixed bzr revid: vmt@openerp.com-20110404163307-x5h0apqxwwc7gc5o --- addons/report_webkit/webkit_report.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/addons/report_webkit/webkit_report.py b/addons/report_webkit/webkit_report.py index e99ad0386c0..a16d6d85e78 100644 --- a/addons/report_webkit/webkit_report.py +++ b/addons/report_webkit/webkit_report.py @@ -30,6 +30,7 @@ ############################################################################## import commands +import subprocess import os import report import tempfile @@ -109,7 +110,7 @@ class WebKitParser(report_sxw): head_file.write(header) head_file.close() file_to_del.append(head_file.name) - command.append("--header-html '%s'"%(head_file.name)) + command.extend(['--header-html', head_file.name]) if footer : foot_file = file( os.path.join( tmp_dir, @@ -120,20 +121,20 @@ class WebKitParser(report_sxw): foot_file.write(footer) foot_file.close() file_to_del.append(foot_file.name) - command.append("--footer-html '%s'"%(foot_file.name)) + command.extend(['--footer-html', foot_file.name]) if webkit_header.margin_top : - command.append('--margin-top %s'%(str(webkit_header.margin_top).replace(',', '.'))) + command.extend(['--margin-top', str(webkit_header.margin_top).replace(',', '.')]) if webkit_header.margin_bottom : - command.append('--margin-bottom %s'%(str(webkit_header.margin_bottom).replace(',', '.'))) + command.extend(['--margin-bottom', str(webkit_header.margin_bottom).replace(',', '.')]) if webkit_header.margin_left : - command.append('--margin-left %s'%(str(webkit_header.margin_left).replace(',', '.'))) + command.extend(['--margin-left', str(webkit_header.margin_left).replace(',', '.')]) if webkit_header.margin_right : - command.append('--margin-right %s'%(str(webkit_header.margin_right).replace(',', '.'))) + command.extend(['--margin-right', str(webkit_header.margin_right).replace(',', '.')]) if webkit_header.orientation : - command.append("--orientation '%s'"%(str(webkit_header.orientation).replace(',', '.'))) + command.extend(['--orientation', str(webkit_header.orientation).replace(',', '.')]) if webkit_header.format : - command.append(" --page-size '%s'"%(str(webkit_header.format).replace(',', '.'))) + command.extend(['--page-size', str(webkit_header.format).replace(',', '.')]) count = 0 for html in html_list : html_file = file(os.path.join(tmp_dir, str(time.time()) + str(count) +'.body.html'), 'w') @@ -145,17 +146,17 @@ class WebKitParser(report_sxw): command.append(out) generate_command = ' '.join(command) try: - status = commands.getstatusoutput(generate_command) - if status[0] : + status = subprocess.call(command) + if status : raise except_osv( _('Webkit raise an error' ), - status[1] + status ) except Exception: for f_to_del in file_to_del : os.unlink(f_to_del) - pdf = file(out).read() + pdf = file(out, 'rb').read() for f_to_del in file_to_del : os.unlink(f_to_del) From 61e505560e1d34a777dce181d477319082cf79fb Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 5 Apr 2011 09:45:59 +0200 Subject: [PATCH 3/3] [FIX] report_webkit: don't display warning message about non-patched qt. bzr revid: vmt@openerp.com-20110405074559-1ou27mu1cz41vmg8 --- addons/report_webkit/webkit_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/report_webkit/webkit_report.py b/addons/report_webkit/webkit_report.py index a16d6d85e78..07eb485260e 100644 --- a/addons/report_webkit/webkit_report.py +++ b/addons/report_webkit/webkit_report.py @@ -146,7 +146,7 @@ class WebKitParser(report_sxw): command.append(out) generate_command = ' '.join(command) try: - status = subprocess.call(command) + status = subprocess.call(command, stderr=subprocess.PIPE) # ignore stderr if status : raise except_osv( _('Webkit raise an error' ),