[ADD] tools: handling of bin_path key in find_in_path
The openerp-server.conf now generates the bin_path record, in order to resolve calls to external binaries served in the thirdparty dir. Adpated report.py to use find_in_path and not directly which.
This commit is contained in:
parent
d804ba36a8
commit
f76d4525a3
|
@ -23,7 +23,8 @@ from openerp import api
|
|||
from openerp import SUPERUSER_ID
|
||||
from openerp.exceptions import AccessError
|
||||
from openerp.osv import osv
|
||||
from openerp.tools import config, which
|
||||
from openerp.tools import config
|
||||
from openerp.tools.misc import find_in_path
|
||||
from openerp.tools.translate import _
|
||||
from openerp.addons.web.http import request
|
||||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
|
@ -48,8 +49,7 @@ from pyPdf import PdfFileWriter, PdfFileReader
|
|||
_logger = logging.getLogger(__name__)
|
||||
|
||||
def _get_wkhtmltopdf_bin():
|
||||
defpath = os.environ.get('PATH', os.defpath).split(os.pathsep)
|
||||
return which('wkhtmltopdf', path=os.pathsep.join(defpath))
|
||||
return find_in_path('wkhtmltopdf')
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
|
@ -60,7 +60,7 @@ try:
|
|||
process = subprocess.Popen(
|
||||
[_get_wkhtmltopdf_bin(), '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
except (OSError, IOError):
|
||||
except (OSError, IOError, ValueError):
|
||||
_logger.info('You need Wkhtmltopdf to print a pdf version of the reports.')
|
||||
else:
|
||||
_logger.info('Will use the Wkhtmltopdf binary at %s' % _get_wkhtmltopdf_bin())
|
||||
|
|
|
@ -65,9 +65,13 @@ _logger = logging.getLogger(__name__)
|
|||
# We include the *Base ones just in case, currently they seem to be subclasses of the _* ones.
|
||||
SKIPPED_ELEMENT_TYPES = (etree._Comment, etree._ProcessingInstruction, etree.CommentBase, etree.PIBase)
|
||||
|
||||
DEFAULT_PATH = os.environ.get('PATH', os.defpath).split(os.pathsep)
|
||||
if config.get('bin_path'):
|
||||
DEFAULT_PATH.append(config['bin_path'])
|
||||
|
||||
def find_in_path(name):
|
||||
try:
|
||||
return which(name)
|
||||
return which(name, path=os.pathsep.join(DEFAULT_PATH))
|
||||
except IOError:
|
||||
return None
|
||||
|
||||
|
|
|
@ -249,6 +249,7 @@ Section $(TITLE_OpenERP_Server) SectionOpenERP_Server
|
|||
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "db_port" $TextPostgreSQLPort
|
||||
# Fix the addons path
|
||||
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "addons_path" "$INSTDIR\server\openerp\addons"
|
||||
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "bin_path" "$INSTDIR\thirdparty"
|
||||
|
||||
# if we're going to install postgresql force it's path,
|
||||
# otherwise we consider it's always done and/or correctly tune by users
|
||||
|
|
Loading…
Reference in New Issue