Commit 249c0a77 authored by Nicolas Delaby's avatar Nicolas Delaby

All specific code to bootstrap ooo handler must be managed by the module...

All specific code to bootstrap ooo handler must be managed by the module cloudooo.handler.ooo itself


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@44937 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 83e4903a
...@@ -27,20 +27,12 @@ ...@@ -27,20 +27,12 @@
############################################################################## ##############################################################################
import gc import gc
from signal import signal, SIGINT, SIGQUIT, SIGHUP
from os import path, mkdir from os import path, mkdir
import os import os
import sys import sys
import cloudooo.handler.ooo.monitor as monitor
from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.wsgixmlrpcapplication import WSGIXMLRPCApplication from cloudooo.wsgixmlrpcapplication import WSGIXMLRPCApplication
from cloudooo.utils import utils from cloudooo.utils import utils
from cloudooo.handler.ooo.mimemapper import mimemapper
def stopProcesses(signum, frame):
monitor.stop()
openoffice.stop()
def application(global_config, **local_config): def application(global_config, **local_config):
...@@ -69,6 +61,9 @@ def application(global_config, **local_config): ...@@ -69,6 +61,9 @@ def application(global_config, **local_config):
if current_value: if current_value:
value = '%s:%s' % (value, current_value) value = '%s:%s' % (value, current_value)
environment_dict[variable_name] = value environment_dict[variable_name] = value
local_config['environment_dict'] = environment_dict
gc.enable() gc.enable()
debug_mode = utils.convertStringToBool(local_config.get('debug_mode')) debug_mode = utils.convertStringToBool(local_config.get('debug_mode'))
utils.configureLogger(debug_mode=debug_mode) utils.configureLogger(debug_mode=debug_mode)
...@@ -80,49 +75,25 @@ def application(global_config, **local_config): ...@@ -80,49 +75,25 @@ def application(global_config, **local_config):
cloudooo_path_tmp_dir = path.join(working_path, 'tmp') cloudooo_path_tmp_dir = path.join(working_path, 'tmp')
if not path.exists(cloudooo_path_tmp_dir): if not path.exists(cloudooo_path_tmp_dir):
mkdir(cloudooo_path_tmp_dir) mkdir(cloudooo_path_tmp_dir)
application_hostname = local_config.get('application_hostname')
openoffice_port = int(local_config.get('openoffice_port'))
# Loading Configuration to start OOo Instance and control it
openoffice.loadSettings(application_hostname,
openoffice_port,
working_path,
local_config.get('office_binary_path'),
local_config.get('uno_path'),
local_config.get('openoffice_user_interface_language',
'en'),
environment_dict=environment_dict,
)
openoffice.start()
utils.loadMimetypeList() utils.loadMimetypeList()
monitor.load(local_config)
timeout_response = int(local_config.get('timeout_response'))
kw = dict(uno_path=local_config.get('uno_path'),
office_binary_path=local_config.get('office_binary_path'),
timeout=timeout_response)
# Signal to stop all processes
signal(SIGINT, stopProcesses)
signal(SIGQUIT, stopProcesses)
signal(SIGHUP, stopProcesses)
# Load all filters
openoffice.acquire()
mimemapper.loadFilterList(application_hostname,
openoffice_port, **kw)
openoffice.release()
mimetype_registry = local_config.get("mimetype_registry", "") mimetype_registry = local_config.get("mimetype_registry", "")
kw["mimetype_registry"] = handler_mapping_list = \ local_config["mimetype_registry"] = handler_mapping_list = \
filter(None, mimetype_registry.split("\n")) filter(None, mimetype_registry.split("\n"))
handler_dict = {} handler_dict = {}
for line in handler_mapping_list: for line in handler_mapping_list:
input_mimetype, output_mimetype, handler = line.strip().split() input_mimetype, output_mimetype, handler = line.strip().split()
if handler not in handler_dict: if handler not in handler_dict:
import_path = "cloudooo.handler.%s.handler" % handler import_path = "cloudooo.handler.%s.handler" % handler
# Import Errors are not catched, check your configuration file
module = __import__(import_path, globals(), locals(), ['']) module = __import__(import_path, globals(), locals(), [''])
# Call the bootstraping method
getattr(module, 'bootstrapHandler', lambda x: None)(local_config)
handler_dict[handler] = module.Handler handler_dict[handler] = module.Handler
kw['handler_dict'] = handler_dict
kw["env"] = environment_dict local_config['handler_dict'] = handler_dict
local_config["env"] = environment_dict
from manager import Manager from manager import Manager
cloudooo_manager = Manager(cloudooo_path_tmp_dir, **kw) cloudooo_manager = Manager(cloudooo_path_tmp_dir, **local_config)
return WSGIXMLRPCApplication(instance=cloudooo_manager) return WSGIXMLRPCApplication(instance=cloudooo_manager)
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