Commit cbd525cd authored by Gabriel Monnerat's avatar Gabriel Monnerat

refactor to get the path of the python scripts and cloudooo dynamically.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@37816 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ea7311b9
...@@ -33,6 +33,7 @@ from threading import Lock ...@@ -33,6 +33,7 @@ from threading import Lock
from cloudooo.ooolib import setUpUnoEnvironment from cloudooo.ooolib import setUpUnoEnvironment
from zope.interface import implements from zope.interface import implements
from application import Application from application import Application
from sys import executable as python_path
from xvfb import xvfb from xvfb import xvfb
from cloudooo.interfaces.lockable import ILockable from cloudooo.interfaces.lockable import ILockable
from cloudooo.utils import logger, waitStartDaemon,\ from cloudooo.utils import logger, waitStartDaemon,\
...@@ -57,7 +58,7 @@ class OpenOffice(Application): ...@@ -57,7 +58,7 @@ class OpenOffice(Application):
def _testOpenOffice(self, host, port): def _testOpenOffice(self, host, port):
"""Test if OpenOffice was started correctly""" """Test if OpenOffice was started correctly"""
logger.debug("Test OpenOffice %s - Pid %s" % (self.getAddress()[-1], self.pid())) logger.debug("Test OpenOffice %s - Pid %s" % (self.getAddress()[-1], self.pid()))
command = [self.python_path command = [python_path
, self.openoffice_tester_bin , self.openoffice_tester_bin
, "--hostname=%s" % host , "--hostname=%s" % host
, "--port=%s" % port , "--port=%s" % port
......
...@@ -54,10 +54,12 @@ class Xvfb(Application): ...@@ -54,10 +54,12 @@ class Xvfb(Application):
def start(self): def start(self):
"""Method to start Virtual Frame Buffer.""" """Method to start Virtual Frame Buffer."""
self.command = ["Xvfb", "-ac", ":%s" % self.display_id, \ self.command = ["Xvfb", "-ac", ":%s" % self.display_id, \
# "-nolisten", "tcp",
"-screen", self.virtual_screen, "800x600x16", \ "-screen", self.virtual_screen, "800x600x16", \
"-fbdir", self.path_run_dir] "-fbdir", self.path_run_dir]
self.process = Popen(self.command, self.process = Popen(" ".join(self.command),
stdout=PIPE, stdout=PIPE,
shell=True,
close_fds=True) close_fds=True)
waitStartDaemon(self, self.timeout) waitStartDaemon(self, self.timeout)
Application.start(self) Application.start(self)
......
...@@ -32,9 +32,9 @@ from application.xvfb import xvfb ...@@ -32,9 +32,9 @@ from application.xvfb import xvfb
from wsgixmlrpcapplication import WSGIXMLRPCApplication from wsgixmlrpcapplication import WSGIXMLRPCApplication
from utils import convertStringToBool, configureLogger, cleanDirectory from utils import convertStringToBool, configureLogger, cleanDirectory
from os import path from os import path
import monitor from sys import executable
from mimemapper import mimemapper from mimemapper import mimemapper
import gc import monitor, gc, pkg_resources
def stopProcesses(): def stopProcesses():
monitor.stop() monitor.stop()
...@@ -73,6 +73,15 @@ def application(global_config, **local_config): ...@@ -73,6 +73,15 @@ def application(global_config, **local_config):
# directory to create temporary files # directory to create temporary files
cloudooo_path_tmp_dir = path.join(path_dir_run_cloudooo, 'tmp') cloudooo_path_tmp_dir = path.join(path_dir_run_cloudooo, 'tmp')
cleanDirectory(cloudooo_path_tmp_dir) cleanDirectory(cloudooo_path_tmp_dir)
# it extracts the path of cloudooo scripts
cloudooo_resources = pkg_resources.get_distribution('cloudooo')
console_scripts = cloudooo_resources.get_entry_map()['console_scripts']
unomimemapper_bin = path.join(path.dirname(executable),
console_scripts["unomimemapper.py"].name)
unoconverter_bin = path.join(path.dirname(executable),
console_scripts["unoconverter.py"].name)
openoffice_tester_bin = path.join(path.dirname(executable),
console_scripts["openoffice_tester.py"].name)
# The Xvfb will run in the same local of the OpenOffice # The Xvfb will run in the same local of the OpenOffice
application_hostname = local_config.get('application_hostname') application_hostname = local_config.get('application_hostname')
...@@ -93,10 +102,10 @@ def application(global_config, **local_config): ...@@ -93,10 +102,10 @@ def application(global_config, **local_config):
local_config.get('virtual_display_id'), local_config.get('virtual_display_id'),
local_config.get('office_bin_path'), local_config.get('office_bin_path'),
local_config.get('uno_path'), local_config.get('uno_path'),
unoconverter_bin=local_config.get('unoconverter_bin'), unoconverter_bin=unoconverter_bin,
python_path=local_config.get('python_path'), python_path=local_config.get('python_path'),
unomimemapper_bin=local_config.get('unomimemapper_bin'), unomimemapper_bin=unomimemapper_bin,
openoffice_tester_bin=local_config.get('openoffice_tester_bin')) openoffice_tester_bin=openoffice_tester_bin)
openoffice.start() openoffice.start()
monitor.load(local_config) monitor.load(local_config)
...@@ -108,14 +117,12 @@ def application(global_config, **local_config): ...@@ -108,14 +117,12 @@ def application(global_config, **local_config):
openoffice.acquire() openoffice.acquire()
mimemapper.loadFilterList(application_hostname, mimemapper.loadFilterList(application_hostname,
openoffice_port, openoffice_port,
unomimemapper_bin=local_config.get('unomimemapper_bin'), unomimemapper_bin=unomimemapper_bin,
python_path=local_config.get('python_path')) python_path=local_config.get('python_path'))
openoffice.release() openoffice.release()
from manager import Manager from manager import Manager
timeout_response = int(local_config.get('timeout_response')) timeout_response = int(local_config.get('timeout_response'))
kw = dict(timeout=timeout_response, kw = dict(timeout=timeout_response, unoconverter_bin=unoconverter_bin)
unoconverter_bin=local_config.get('unoconverter_bin'),
python_path=local_config.get('python_path'))
cloudooo_manager = Manager(cloudooo_path_tmp_dir, **kw) cloudooo_manager = Manager(cloudooo_path_tmp_dir, **kw)
return WSGIXMLRPCApplication(instance=cloudooo_manager) return WSGIXMLRPCApplication(instance=cloudooo_manager)
...@@ -31,6 +31,7 @@ from subprocess import Popen, PIPE ...@@ -31,6 +31,7 @@ from subprocess import Popen, PIPE
from zope.interface import implements from zope.interface import implements
from filter import Filter from filter import Filter
from os import environ from os import environ
from sys import executable as python_path
from interfaces.mimemapper import IMimemapper from interfaces.mimemapper import IMimemapper
from types import InstanceType from types import InstanceType
...@@ -106,7 +107,7 @@ class MimeMapper(object): ...@@ -106,7 +107,7 @@ class MimeMapper(object):
"/usr/bin/unomimemapper.py") "/usr/bin/unomimemapper.py")
uno_path = kw.get("uno_path", environ.get('uno_path')) uno_path = kw.get("uno_path", environ.get('uno_path'))
office_bin_path = kw.get("office_bin_path", environ.get('office_bin_path')) office_bin_path = kw.get("office_bin_path", environ.get('office_bin_path'))
command = [self.python_path command = [python_path
, self.unomimemapper_bin , self.unomimemapper_bin
, "--uno_path=%s" % uno_path , "--uno_path=%s" % uno_path
, "--office_bin_path=%s" % office_bin_path , "--office_bin_path=%s" % office_bin_path
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment