We should raise an error when wkhtmltopdf fails
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Camptocamp Financial Addons |
Fix Released
|
Medium
|
Alexandre Fayolle - camptocamp |
Bug Description
Dear Camptocamp dream team,
In c2c-financial-
try:
status = subprocess.
if status :
except Exception:
for f_to_del in file_to_del :
The problem is the following :
if the wkhtmltopdf command fails, then status <> 0 and you raise an exception ; this exception is catched and you remove the HTML file... and then the program goes on ! No error message is displayed to the user !
In my case, wkhtmltopdf failed with the error "wkhtmltopdf: cannot connect to X server"... and it eventually crashes later on in the code and I get the Publisher warranty error pop-up with message :
OpenERP-Client Version : 6.1.1
Last revision No. & ID :2059 <email address hidden>
<ProtocolError for localhost:
and on the server side, the message was :
2012-05-23 17:10:33,208 20396 ERROR ? openerp.
Traceback (most recent call last):
File "/opt/openerp/
(result, format) = obj.create(cr, uid, ids, datas, context)
File "/opt/openerp/
result = self.create_
File "/opt/openerp/
return self.create_
File "/opt/openerp/
pdf = self.generate_
File "/opt/openerp/
pdf = file(out_filename, 'rb').read()
IOError: [Errno 2] No such file or directory: '/tmp/webkit.
2012-05-23 17:10:33,966 20396 ERROR ? openerp.netsvc: 2
No such file or directory
(<type 'exceptions.
2012-05-23 17:10:33,983 20396 INFO ? werkzeug: 127.0.0.1 - - [23/May/2012 17:10:33] "POST /xmlrpc/report HTTP/1.1" 500 -
2012-05-23 17:10:33,993 20396 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/local/
execute(app)
File "/usr/local/
application
File "/opt/openerp/
result = handler(environ, start_response)
File "/opt/openerp/
return xmlrpc_
File "/opt/openerp/
response = xmlrpc_
File "/opt/openerp/
fault = xmlrpclib.
TypeError: coercing to Unicode: need string or buffer, tuple found
The enclosed patch will block the execution if wkhtmltopdf fails and will display the error code to the user in a nice pop-up.
It would be even better to display the output of stderr, so that it's easier for the user to understand the cause of the issue. With my enclosed patch, the pop-up would say "The command 'wkhtmltopdf' failed with error code = 1", which won't help me solve the issue. If I get the message "The command 'wkhtmltopdf' failed with the following message : wkhtmltopdf: cannot connect to X server", then it would be easier for me to solve it. But I am not an expert of subprocess.call and I don't know how it can be done.
The enclosed patch has been successfully tested on the branch lp:c2c-financial-addons/6.1/
P.S. : for those we have the same error with wkhtmltopdf, here is the explaination : http://
Related branches
- Guewen Baconnier @ Camptocamp: Approve
- Nicolas Bessi - Camptocamp: Pending requested
-
Diff: 61 lines (+27/-16)1 file modifiedaccount_financial_report_webkit/report/webkit_parser_header_fix.py (+27/-16)
- Guewen Baconnier @ Camptocamp: Approve
- Nicolas Bessi - Camptocamp: Pending requested
-
Diff: 92 lines (+32/-20)1 file modifiedaccount_financial_report_webkit/report/webkit_parser_header_fix.py (+32/-20)
- Guewen Baconnier @ Camptocamp: Approve
- Alexis de Lattre: Pending requested
- Nicolas Bessi - Camptocamp: Pending requested
-
Diff: 61 lines (+27/-16)1 file modifiedaccount_financial_report_webkit/report/webkit_parser_header_fix.py (+27/-16)
Changed in c2c-financial-addons: | |
status: | Confirmed → In Progress |
Changed in c2c-financial-addons: | |
status: | In Progress → Fix Committed |
On mer. 23 mai 2012 19:28:33 CEST, Alexis de Lattre wrote: c2c-financial- addons- 6.1_webkit- error.diff" /bugs.launchpad .net/bugs/ 1003563/ +attachment/ 3159753/ +files/ patch-c2c- financial- addons- 6.1_webkit- error.diff
> ** Patch added: "patch-
> https:/
>
Thanks for the bug report Alexis.
I'm going to look into this, and propose an updated version of the
patch to include the output of the failing command. Stay tuned.
--
Alexandre Fayolle
Chef de Projet
Tel : + 33 (0)4 79 26 57 92
Camptocamp France SAS www.camptocamp. com
Savoie Technolac, BP 352
73377 Le Bourget du Lac Cedex
http://