Commit 58a72658 authored by Nicolas Delaby's avatar Nicolas Delaby

Add additional parameter to define default language of OpenOffice.org deamon.

This is usefull for default formating, reading direction, default units, ...

for english, add in your cloudoooo.conf under section [app:main]:

openoffice_user_interface_language = en


Allowed values are iso language code (ISO 639)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@42004 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ea4bd677
...@@ -91,7 +91,10 @@ def application(global_config, **local_config): ...@@ -91,7 +91,10 @@ def application(global_config, **local_config):
working_path, working_path,
local_config.get('virtual_display_id'), local_config.get('virtual_display_id'),
local_config.get('office_binary_path'), local_config.get('office_binary_path'),
local_config.get('uno_path')) local_config.get('uno_path'),
local_config.get('openoffice_user_interface_language',
'en'),
)
openoffice.start() openoffice.start()
monitor.load(local_config) monitor.load(local_config)
......
...@@ -85,7 +85,7 @@ class OpenOffice(Application): ...@@ -85,7 +85,7 @@ class OpenOffice(Application):
self.request = 0 self.request = 0
def loadSettings(self, hostname, port, path_run_dir, display_id, def loadSettings(self, hostname, port, path_run_dir, display_id,
office_binary_path, uno_path, **kw): office_binary_path, uno_path, default_language, **kw):
"""Method to load the configuratio to control one OpenOffice Instance """Method to load the configuratio to control one OpenOffice Instance
Keyword arguments: Keyword arguments:
office_path -- Full Path of the OOo executable. office_path -- Full Path of the OOo executable.
...@@ -95,6 +95,7 @@ class OpenOffice(Application): ...@@ -95,6 +95,7 @@ class OpenOffice(Application):
Application.loadSettings(self, hostname, port, path_run_dir, display_id) Application.loadSettings(self, hostname, port, path_run_dir, display_id)
self.office_binary_path = office_binary_path self.office_binary_path = office_binary_path
self.uno_path = uno_path self.uno_path = uno_path
self.default_language = default_language
def _start_process(self, command, env): def _start_process(self, command, env):
"""Start OpenOffice.org process""" """Start OpenOffice.org process"""
...@@ -140,6 +141,7 @@ class OpenOffice(Application): ...@@ -140,6 +141,7 @@ class OpenOffice(Application):
'-display', '-display',
':%s' % self.display_id, ':%s' % self.display_id,
'-env:UserInstallation=file://%s' % self.path_user_installation, '-env:UserInstallation=file://%s' % self.path_user_installation,
'-language=%s' % self.default_language,
] ]
# To run the instance OOo is need a environment. So, the "DISPLAY" of Xvfb # To run the instance OOo is need a environment. So, the "DISPLAY" of Xvfb
# is passed to env and the environment customized is passed to the process # is passed to env and the environment customized is passed to the process
......
##############################################################################
#
# Copyright (c) 2009-2010 Nexedi SA and Contributors. All Rights Reserved.
# Gabriel M. Monnerat <gabriel@tiolive.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from socket import socket, error
from errno import EADDRINUSE
from time import sleep
from os import remove, environ
from shutil import rmtree
import logging
logger = logging.getLogger('Cloudooo')
PYTHON_ENVIRONMENT = [
'PYTHONHOME',
'PYTHONPATH',
'PYTHONSTARTUP',
'PYTHONY2K',
'PYTHONOPTIMIZE',
'PYTHONDEBUG',
'PYTHONDONTWRITEBYTECODE',
'PYTHONINSPECT',
'PYTHONNOUSERSITE',
'PYTHONNOUSERSITE',
'PYTHONUNBUFFERED',
'PYTHONVERBOSE'
]
def getCleanPythonEnvironment():
env = environ.copy()
# Clean python related environment variables
for k in PYTHON_ENVIRONMENT:
env.pop(k, None)
return env
def removeDirectory(path):
"""Remove directory"""
try:
rmtree(path)
except OSError, msg:
logger.error(msg)
def socketStatus(hostname, port):
"""Verify if the address is busy."""
try:
socket().bind((hostname, port),)
# False if the is free
return False
except error, (num, err):
if num == EADDRINUSE:
# True if the isn't free
return True
def waitStartDaemon(daemon, attempts):
"""Wait a certain time to start the daemon."""
for num in range(attempts):
sleep(1)
if daemon.status():
return
def waitStopDaemon(daemon, attempts=5):
"""Wait a certain time to stop the daemon."""
for num in range(attempts):
sleep(1)
if not daemon.status():
break
def configureLogger(level=None, debug_mode=False):
"""Configure logger.
Keyword arguments:
level -- Level to prints the log messages
"""
if level is None:
level = logging.INFO
if debug_mode:
level = logging.DEBUG
handler_list = logger.handlers
if handler_list:
for handler in iter(handler_list):
logger.removeHandler(handler)
# The propagate value indicates whether or not parents of this loggers will
# be traversed when looking for handlers. It doesn't really make sense in the
# root logger - it's just there because a root logger is almost like any
# other logger.
logger.propagate = 0
logger.setLevel(level)
# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(level)
# create formatter
formatter = logging.Formatter("%(asctime).19s - %(name)s - %(levelname)s - %(message)s")
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
logger.addHandler(ch)
def remove_file(filepath):
try:
remove(filepath)
except OSError, msg:
print msg.strerror
def convertStringToBool(string):
"""This function is used to convert string 'true' and 'false' only.
Keyword arguments:
string -- string to convert to boolean
"""
if string.upper() == "TRUE":
return True
elif string.upper() == "FALSE":
return False
else:
return None
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