=== modified file 'report_webkit/webkit_report.py' --- report_webkit/webkit_report.py 2011-06-16 05:40:53 +0000 +++ report_webkit/webkit_report.py 2011-10-04 12:31:32 +0000 @@ -55,6 +55,15 @@ # default_filters=['unicode', 'h'] can be used to set global filters return Template(text, input_encoding='utf-8', output_encoding='utf-8') +def find_binary_in_path(biname): + """ Find a binary in the system PATH """ + path = os.environ['PATH'] + for directory in path.split(':'): + f = os.path.join(directory, biname) + if os.path.exists(f) and os.access(f, os.X_OK): + return f + return None + class WebKitParser(report_sxw): """Custom class that use webkit to render HTML reports @@ -74,14 +83,18 @@ path = self.pool.get('res.company').read(cursor, uid, company, ['lib_path',]) path = path['lib_path'] if not path: - raise except_osv( - _('Wkhtmltopdf library path is not set in company'), - _('Please install executable on your system'+ - ' (sudo apt-get install wkhtmltopdf) or download it from here:'+ - ' http://code.google.com/p/wkhtmltopdf/downloads/list and set the'+ - ' path to the executable on the Company form.'+ - 'Minimal version is 0.9.9') - ) + path = find_binary_in_path('wkhtmltopdf') + if not path: + raise except_osv( + _('Wkhtmltopdf not found on the system'), + _('Please install executable on your system'+ + ' (sudo apt-get install wkhtmltopdf) or download it from here:'+ + ' http://code.google.com/p/wkhtmltopdf/downloads/list and set the'+ + ' path to the executable on the Company form.'+ + 'Minimal version is 0.9.9') + ) + else: + return path if os.path.isabs(path) : if (os.path.exists(path) and os.access(path, os.X_OK)\ and os.path.basename(path).startswith('wkhtmltopdf')):