[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 import SUPERUSER_ID
|
||||||
from openerp.exceptions import AccessError
|
from openerp.exceptions import AccessError
|
||||||
from openerp.osv import osv
|
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.tools.translate import _
|
||||||
from openerp.addons.web.http import request
|
from openerp.addons.web.http import request
|
||||||
from openerp.tools.safe_eval import safe_eval as eval
|
from openerp.tools.safe_eval import safe_eval as eval
|
||||||
|
@ -48,8 +49,7 @@ from pyPdf import PdfFileWriter, PdfFileReader
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
def _get_wkhtmltopdf_bin():
|
def _get_wkhtmltopdf_bin():
|
||||||
defpath = os.environ.get('PATH', os.defpath).split(os.pathsep)
|
return find_in_path('wkhtmltopdf')
|
||||||
return which('wkhtmltopdf', path=os.pathsep.join(defpath))
|
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------
|
#--------------------------------------------------------------------------
|
||||||
|
@ -60,7 +60,7 @@ try:
|
||||||
process = subprocess.Popen(
|
process = subprocess.Popen(
|
||||||
[_get_wkhtmltopdf_bin(), '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
[_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.')
|
_logger.info('You need Wkhtmltopdf to print a pdf version of the reports.')
|
||||||
else:
|
else:
|
||||||
_logger.info('Will use the Wkhtmltopdf binary at %s' % _get_wkhtmltopdf_bin())
|
_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.
|
# 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)
|
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):
|
def find_in_path(name):
|
||||||
try:
|
try:
|
||||||
return which(name)
|
return which(name, path=os.pathsep.join(DEFAULT_PATH))
|
||||||
except IOError:
|
except IOError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -249,6 +249,7 @@ Section $(TITLE_OpenERP_Server) SectionOpenERP_Server
|
||||||
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "db_port" $TextPostgreSQLPort
|
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "db_port" $TextPostgreSQLPort
|
||||||
# Fix the addons path
|
# Fix the addons path
|
||||||
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "addons_path" "$INSTDIR\server\openerp\addons"
|
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,
|
# if we're going to install postgresql force it's path,
|
||||||
# otherwise we consider it's always done and/or correctly tune by users
|
# otherwise we consider it's always done and/or correctly tune by users
|
||||||
|
|
Loading…
Reference in New Issue