[Erp5-report] r37677 gabriel - in /erp5/trunk/utils/cloudooo: ./ cloudooo/ cloudooo/applica...
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Aug 10 20:57:28 CEST 2010
Author: gabriel
Date: Tue Aug 10 20:57:26 2010
New Revision: 37677
URL: http://svn.erp5.org?rev=37677&view=rev
Log:
add script openoffice_tester.py to test the OpenOffice.org via socket. When the OpenOffice.org is started this process is tested, if occurs error the openoffice.org is restarted. This way is more fast and reliable.
Added:
erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py (with props)
Modified:
erp5/trunk/utils/cloudooo/cloudooo/application/openoffice.py
erp5/trunk/utils/cloudooo/cloudooo/cloudooo.py
erp5/trunk/utils/cloudooo/setup.py
Modified: erp5/trunk/utils/cloudooo/cloudooo/application/openoffice.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/application/openoffice.py?rev=37677&r1=37676&r2=37677&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/application/openoffice.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/application/openoffice.py [utf8] Tue Aug 10 20:57:26 2010
@@ -26,7 +26,7 @@
#
##############################################################################
-from os import environ, remove
+from os import environ
from os.path import exists, join
from subprocess import Popen, PIPE
from threading import Lock
@@ -34,7 +34,8 @@ from cloudooo.ooolib import setUpUnoEnvi
from zope.interface import implements
from application import Application
from cloudooo.interfaces.lockable import ILockable
-from cloudooo.utils import logger, waitStartDaemon, removeDirectory, waitStopDaemon
+from cloudooo.utils import logger, waitStartDaemon,\
+ removeDirectory, waitStopDaemon, convertStringToBool
class OpenOffice(Application):
"""Object to control one OOo Instance and all features instance."""
@@ -56,25 +57,19 @@ class OpenOffice(Application):
"""Test if OpenOffice was started correctly"""
logger.debug("Test OpenOffice %s - Pid %s" % (self.getAddress()[-1], self.pid()))
command = [self.python_path
- , self.unoconverter_bin
- , "--test"
+ , self.openoffice_tester_bin
, "--hostname=%s" % host
, "--port=%s" % port
- , "--document_url=%s" % self.document_url
- , "--unomimemapper_bin=%s" % self.unomimemapper_bin
- , "--python_path=%s" % self.python_path
- , "--uno_path=%s" % self.uno_path
- , "--office_bin_path=%s" % self.office_bin_path]
+ , "--uno_path=%s" % self.uno_path]
logger.debug("Testing Openoffice Instance %s" % port)
stdout, stderr = Popen(" ".join(command), shell=True, stdout=PIPE,
- stderr=PIPE).communicate()
- if not stdout and stderr != "":
- logger.debug(stderr)
+ stderr=PIPE, close_fds=True).communicate()
+ stdout_bool = convertStringToBool(stdout.replace("\n",""))
+ if stdout_bool and stderr != "":
+ logger.debug("%s\n%s" % (stderr, stdout))
return False
else:
- url = stdout.replace("\n", "")
logger.debug("Instance %s works" % port)
- remove(url)
return True
def _cleanRequest(self):
@@ -99,6 +94,7 @@ class OpenOffice(Application):
self.unoconverter_bin = kw.get("unoconverter_bin", "unoconverter")
self.python_path = kw.get('python_path', 'python')
self.unomimemapper_bin = kw.get("unomimemapper_bin")
+ self.openoffice_tester_bin = kw.get("openoffice_tester_bin")
def _start_process(self, command, env):
"""Start OpenOffice.org process"""
@@ -108,10 +104,7 @@ class OpenOffice(Application):
close_fds=True,
env=env)
waitStartDaemon(self, self.timeout)
- if exists(self.document_url):
- return self._testOpenOffice(self.hostname, self.port)
-
- return True
+ return self._testOpenOffice(self.hostname, self.port)
def start(self):
"""Start Instance."""
Added: erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py?rev=37677&view=auto
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py (added)
+++ erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py [utf8] Tue Aug 10 20:57:26 2010
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+import sys
+from getopt import getopt, GetoptError
+from cloudooo.utils import usage
+from cloudooo import ooolib
+from os import environ
+
+def test_openoffice(hostname, port):
+ try:
+ ooolib.getServiceManager(hostname, port)
+ return True
+ except Exception, err:
+ print err
+ return False
+
+def main():
+ try:
+ opt_list, arg_list = getopt(sys.argv[1:], "",
+ ["port=","hostname=","uno_path="])
+ except GetoptError, e:
+ usage(sys.stderr, "%s \nUse --port and --hostname" % e)
+ sys.exit(2)
+
+ for opt, arg in opt_list:
+ if opt == "--port":
+ port = arg
+ elif opt == "--hostname":
+ hostname = arg
+ elif opt == "--uno_path":
+ environ["uno_path"] = arg
+
+ print test_openoffice(hostname, port)
+
+
+if __name__ == "__main__":
+ main()
Propchange: erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py
------------------------------------------------------------------------------
svn:executable = *
Modified: erp5/trunk/utils/cloudooo/cloudooo/cloudooo.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/cloudooo.py?rev=37677&r1=37676&r2=37677&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/cloudooo.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/cloudooo.py [utf8] Tue Aug 10 20:57:26 2010
@@ -67,10 +67,9 @@ def application(global_config, **local_c
gc.enable()
debug_mode = convertStringToBool(local_config.get('debug_mode'))
configureLogger(debug_mode=debug_mode)
- document_name = local_config.get("document_name")
# path of directory to run cloudooo
path_dir_run_cloudooo = local_config.get('path_dir_run_cloudooo')
- cleanDirectory(path_dir_run_cloudooo, ignore_list=["tmp", document_name])
+ cleanDirectory(path_dir_run_cloudooo, ignore_list=["tmp",])
# directory to create temporary files
cloudooo_path_tmp_dir = path.join(path_dir_run_cloudooo, 'tmp')
cleanDirectory(cloudooo_path_tmp_dir)
@@ -86,10 +85,7 @@ def application(global_config, **local_c
virtual_screen=local_config.get('virtual_screen'),
start_timeout=local_config.get('start_timeout'))
xvfb.start()
-
- document_url = path.join(path.dirname(__file__),
- "tests/data/%s" % document_name)
-
+
# Loading Configuration to start OOo Instance and control it
openoffice.loadSettings(application_hostname,
openoffice_port,
@@ -97,10 +93,10 @@ def application(global_config, **local_c
local_config.get('virtual_display_id'),
local_config.get('office_bin_path'),
local_config.get('uno_path'),
- document_url=document_url,
unoconverter_bin=local_config.get('unoconverter_bin'),
python_path=local_config.get('python_path'),
- unomimemapper_bin=local_config.get('unomimemapper_bin'))
+ unomimemapper_bin=local_config.get('unomimemapper_bin'),
+ openoffice_tester_bin=local_config.get('openoffice_tester_bin'))
openoffice.start()
monitor.load(local_config)
Modified: erp5/trunk/utils/cloudooo/setup.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/setup.py?rev=37677&r1=37676&r2=37677&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/setup.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/setup.py [utf8] Tue Aug 10 20:57:26 2010
@@ -1,10 +1,6 @@
-import sys
from setuptools import setup, find_packages
-from os.path import realpath, exists, join, dirname
-from os import symlink, unlink
-from shutil import copyfile
-version = '1.0.1'
+version = '1.0.2'
setup(name='cloudooo',
version=version,
@@ -39,5 +35,6 @@ setup(name='cloudooo',
[console_scripts]
unoconverter.py = cloudooo.bin.unoconverter:main
unomimemapper.py = cloudooo.bin.unomimemapper:main
+ openoffice_tester.py = cloudooo.bin.openoffice_tester:main
""",
)
More information about the Erp5-report
mailing list