Commit 80bc4448 authored by Gabriel Monnerat's avatar Gabriel Monnerat

remove functions and Remove all attributes that works with cloudooo script paths.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@37984 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 00981561
1.0.9
=====
- Remove all attributes that works with cloudooo script paths.
- Use all scripts according to your python eggs.
1.0.8 1.0.8
===== =====
......
...@@ -37,7 +37,7 @@ from sys import executable as python_path ...@@ -37,7 +37,7 @@ 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, removeDirectory, \ from cloudooo.utils import logger, waitStartDaemon, removeDirectory, \
waitStopDaemon, convertStringToBool, extractModuleName waitStopDaemon, convertStringToBool
class OpenOffice(Application): class OpenOffice(Application):
"""Object to control one OOo Instance and all features instance.""" """Object to control one OOo Instance and all features instance."""
...@@ -60,7 +60,7 @@ class OpenOffice(Application): ...@@ -60,7 +60,7 @@ class OpenOffice(Application):
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 = [python_path command = [python_path
, "'-c'" , "'-c'"
, "'from %s import main;main()'" % extractModuleName("openoffice_tester") , "'from cloudooo.bin.openoffice_tester import main;main()'"
, "'--hostname=%s'" % host , "'--hostname=%s'" % host
, "'--port=%s'" % port , "'--port=%s'" % port
, "'--uno_path=%s'" % self.uno_path] , "'--uno_path=%s'" % self.uno_path]
......
...@@ -32,9 +32,8 @@ from application.xvfb import xvfb ...@@ -32,9 +32,8 @@ from application.xvfb import xvfb
from wsgixmlrpcapplication import WSGIXMLRPCApplication from wsgixmlrpcapplication import WSGIXMLRPCApplication
from utils import convertStringToBool, configureLogger from utils import convertStringToBool, configureLogger
from os import path, mkdir from os import path, mkdir
from sys import executable
from mimemapper import mimemapper from mimemapper import mimemapper
import monitor, gc, pkg_resources import monitor, gc
def stopProcesses(): def stopProcesses():
monitor.stop() monitor.stop()
...@@ -56,9 +55,6 @@ def application(global_config, **local_config): ...@@ -56,9 +55,6 @@ def application(global_config, **local_config):
application_hostname -- Sets the host to Xvfb and Openoffice. application_hostname -- Sets the host to Xvfb and Openoffice.
virtual_screen -- Use to define the screen to Xvfb virtual_screen -- Use to define the screen to Xvfb
e.g virtual_screen='0' e.g virtual_screen='0'
number_instances_openoffice -- Defines a number of OOo Instances.
pool_port_range_start -- Initial number to start all OOo Instances.
e.g pool_port_range_start=4060
office_bin_path -- Full Path of the OOo executable. office_bin_path -- Full Path of the OOo executable.
e.g office_bin_path='/opt/openoffice.org3/program' e.g office_bin_path='/opt/openoffice.org3/program'
uno_path -- Full path to pyuno library. uno_path -- Full path to pyuno library.
......
...@@ -36,7 +36,7 @@ from cloudooo.interfaces.handler import IHandler ...@@ -36,7 +36,7 @@ from cloudooo.interfaces.handler import IHandler
from cloudooo.mimemapper import mimemapper from cloudooo.mimemapper import mimemapper
from cloudooo.document import FileSystemDocument from cloudooo.document import FileSystemDocument
from cloudooo.monitor.timeout import MonitorTimeout from cloudooo.monitor.timeout import MonitorTimeout
from cloudooo.utils import logger, extractModuleName from cloudooo.utils import logger
from psutil import pid_exists from psutil import pid_exists
from sys import executable as python_path from sys import executable as python_path
...@@ -72,7 +72,7 @@ class OOHandler: ...@@ -72,7 +72,7 @@ class OOHandler:
kw['port'] = port kw['port'] = port
command_list = [python_path command_list = [python_path
, "-c" , "-c"
, "'from %s import main;main()'" % extractModuleName("unoconverter") , "'from cloudooo.bin.unoconverter import main;main()'"
, "--uno_path='%s'" % self.uno_path , "--uno_path='%s'" % self.uno_path
, "--office_bin_path='%s'" % self.office_bin_path , "--office_bin_path='%s'" % self.office_bin_path
, "--document_url='%s'" % self.document.getUrl()] , "--document_url='%s'" % self.document.getUrl()]
......
...@@ -34,7 +34,6 @@ from os import environ ...@@ -34,7 +34,6 @@ from os import environ
from sys import executable as python_path 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
from utils import extractModuleName
class MimeMapper(object): class MimeMapper(object):
"""Load all filters from OOo. You can get the of the filter you want or all """Load all filters from OOo. You can get the of the filter you want or all
...@@ -107,7 +106,7 @@ class MimeMapper(object): ...@@ -107,7 +106,7 @@ class MimeMapper(object):
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 = [python_path command = [python_path
, "'-c'" , "'-c'"
, "'from %s import main;main()'" % extractModuleName("unomimemapper") , "'from cloudooo.bin.unomimemapper import main;main()'"
, "'--uno_path=%s'" % uno_path , "'--uno_path=%s'" % uno_path
, "'--office_bin_path=%s'" % office_bin_path , "'--office_bin_path=%s'" % office_bin_path
, "'--hostname=%s'" % hostname, "--port=%s" % port] , "'--hostname=%s'" % hostname, "--port=%s" % port]
......
...@@ -46,23 +46,6 @@ def check_folder(path_dir_run_cloudooo, tmp_dir_path): ...@@ -46,23 +46,6 @@ def check_folder(path_dir_run_cloudooo, tmp_dir_path):
if not path.exists(tmp_dir_path): if not path.exists(tmp_dir_path):
mkdir(tmp_dir_path) mkdir(tmp_dir_path)
def extract_cloudooo_script():
from sys import executable
import pkg_resources
cloudooo_resources = pkg_resources.get_distribution('cloudooo')
console_scripts = cloudooo_resources.get_entry_map()['console_scripts']
openoffice_tester_bin_path = path.join(path.dirname(executable),
console_scripts["openoffice_tester"].name)
unomimemapper_bin_path = path.join(path.dirname(executable),
console_scripts["unomimemapper"].name)
unoconverter_bin_path = path.join(path.dirname(executable),
console_scripts["unoconverter"].name)
return dict(unoconverter_bin=unoconverter_bin_path,
unomimemapper_bin=unomimemapper_bin_path,
openoffice_tester_bin=openoffice_tester_bin_path)
def make_suite(test_case): def make_suite(test_case):
"""Function is used to run all tests together""" """Function is used to run all tests together"""
suite = unittest.TestSuite() suite = unittest.TestSuite()
...@@ -108,10 +91,6 @@ def startFakeEnvironment(start_openoffice=True, conf_path=None): ...@@ -108,10 +91,6 @@ def startFakeEnvironment(start_openoffice=True, conf_path=None):
virtual_screen='1') virtual_screen='1')
xvfb.start() xvfb.start()
waitStartDaemon(xvfb, 10) waitStartDaemon(xvfb, 10)
cloudooo_script_dict = extract_cloudooo_script()
openoffice_tester_bin = cloudooo_script_dict["openoffice_tester_bin"]
unomimemapper_bin = cloudooo_script_dict["unomimemapper_bin"]
if start_openoffice: if start_openoffice:
openoffice.loadSettings(hostname, openoffice.loadSettings(hostname,
...@@ -119,13 +98,11 @@ def startFakeEnvironment(start_openoffice=True, conf_path=None): ...@@ -119,13 +98,11 @@ def startFakeEnvironment(start_openoffice=True, conf_path=None):
path_dir_run_cloudooo, path_dir_run_cloudooo,
virtual_display_id, virtual_display_id,
office_bin_path, office_bin_path,
uno_path, uno_path)
openoffice_tester_bin=openoffice_tester_bin)
openoffice.start() openoffice.start()
openoffice.acquire() openoffice.acquire()
hostname, port = openoffice.getAddress() hostname, port = openoffice.getAddress()
kw = dict(unomimemapper_bin=unomimemapper_bin, kw = dict(uno_path=config.get("app:main", "uno_path"),
uno_path=config.get("app:main", "uno_path"),
office_bin_path=config.get("app:main", "office_bin_path")) office_bin_path=config.get("app:main", "office_bin_path"))
if not mimemapper.isLoaded(): if not mimemapper.isLoaded():
mimemapper.loadFilterList(hostname, port, **kw) mimemapper.loadFilterList(hostname, port, **kw)
...@@ -147,12 +124,6 @@ class cloudoooTestCase(unittest.TestCase): ...@@ -147,12 +124,6 @@ class cloudoooTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
"""Creates a environment to run the tests. Is called always before the """Creates a environment to run the tests. Is called always before the
tests.""" tests."""
cloudooo_script_dict = extract_cloudooo_script()
self.openoffice_tester_bin = cloudooo_script_dict["openoffice_tester_bin"]
self.unomimemapper_bin = cloudooo_script_dict["unomimemapper_bin"]
self.unoconverter_bin = cloudooo_script_dict["unoconverter_bin"]
self.hostname = config.get("server:main", "host") self.hostname = config.get("server:main", "host")
self.cloudooo_port = config.get("server:main", "port") self.cloudooo_port = config.get("server:main", "port")
self.openoffice_port = config.get("app:main", "openoffice_port") self.openoffice_port = config.get("app:main", "openoffice_port")
......
...@@ -34,7 +34,6 @@ from cloudoooTestCase import cloudoooTestCase, make_suite ...@@ -34,7 +34,6 @@ from cloudoooTestCase import cloudoooTestCase, make_suite
from cloudooo.mimemapper import mimemapper from cloudooo.mimemapper import mimemapper
from cloudooo.application.openoffice import openoffice from cloudooo.application.openoffice import openoffice
from cloudooo.document import FileSystemDocument from cloudooo.document import FileSystemDocument
from cloudooo.utils import extractModuleName
class TestUnoConverter(cloudoooTestCase): class TestUnoConverter(cloudoooTestCase):
"""Test case to test all features of the unoconverter script""" """Test case to test all features of the unoconverter script"""
...@@ -58,7 +57,7 @@ class TestUnoConverter(cloudoooTestCase): ...@@ -58,7 +57,7 @@ class TestUnoConverter(cloudoooTestCase):
mimemapper_pickled = jsonpickle.encode(mimemapper) mimemapper_pickled = jsonpickle.encode(mimemapper)
command = [self.python_path, command = [self.python_path,
"-c", "-c",
"'from %s import main;main()'" % extractModuleName("unoconverter"), "'from cloudooo.bin.unoconverter import main;main()'",
"'--convert'", "'--convert'",
"'--uno_path=%s'" % self.uno_path, "'--uno_path=%s'" % self.uno_path,
"'--office_bin_path=%s'" % self.office_bin_path, "'--office_bin_path=%s'" % self.office_bin_path,
...@@ -87,7 +86,7 @@ class TestUnoConverter(cloudoooTestCase): ...@@ -87,7 +86,7 @@ class TestUnoConverter(cloudoooTestCase):
"""Test script unoconverter without mimemapper serialized""" """Test script unoconverter without mimemapper serialized"""
command = [self.python_path, command = [self.python_path,
"-c", "-c",
"'from %s import main;main()'" % extractModuleName("unoconverter"), "'from cloudooo.bin.unoconverter import main;main()'",
"'--convert'", "'--convert'",
"'--uno_path=%s'" % self.uno_path, "'--uno_path=%s'" % self.uno_path,
"'--office_bin_path=%s'" % self.office_bin_path, "'--office_bin_path=%s'" % self.office_bin_path,
......
...@@ -31,7 +31,6 @@ from cloudooo.application.openoffice import openoffice ...@@ -31,7 +31,6 @@ from cloudooo.application.openoffice import openoffice
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from os import environ from os import environ
from cloudoooTestCase import cloudoooTestCase, make_suite from cloudoooTestCase import cloudoooTestCase, make_suite
from cloudooo.utils import extractModuleName
class TestUnoMimeMapper(cloudoooTestCase): class TestUnoMimeMapper(cloudoooTestCase):
"""Test Case to test all features of script unomimemapper""" """Test Case to test all features of script unomimemapper"""
...@@ -53,7 +52,7 @@ class TestUnoMimeMapper(cloudoooTestCase): ...@@ -53,7 +52,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
hostname, host = openoffice.getAddress() hostname, host = openoffice.getAddress()
command = [self.python_path, command = [self.python_path,
"-c", "-c",
"'from %s import main; main()'" % extractModuleName("unomimemapper"), "'from cloudooo.bin.unomimemapper import main; main()'",
"'--uno_path=%s'" % self.uno_path, "'--uno_path=%s'" % self.uno_path,
"'--office_bin_path=%s'" % self.uno_path, "'--office_bin_path=%s'" % self.uno_path,
"'--hostname=%s'" % self.hostname, "'--hostname=%s'" % self.hostname,
...@@ -74,7 +73,7 @@ class TestUnoMimeMapper(cloudoooTestCase): ...@@ -74,7 +73,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
hostname, host = openoffice.getAddress() hostname, host = openoffice.getAddress()
command = [self.python_path, command = [self.python_path,
"-c", "-c",
"'from %s import main; main()'" % extractModuleName("unomimemapper"), "'from cloudooo.bin.unomimemapper import main; main()'",
"'--hostname=%s'" % self.hostname, "'--hostname=%s'" % self.hostname,
"'--port=%s'" % self.openoffice_port] "'--port=%s'" % self.openoffice_port]
stdout, stderr = Popen(' '.join(command), shell=True, stdout, stderr = Popen(' '.join(command), shell=True,
...@@ -89,7 +88,7 @@ class TestUnoMimeMapper(cloudoooTestCase): ...@@ -89,7 +88,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
openoffice.stop() openoffice.stop()
command = [self.python_path, command = [self.python_path,
"-c", "-c",
"'from %s import main; main()'" % extractModuleName("unomimemapper"), "'from cloudooo.bin.unomimemapper import main; main()'",
"'--uno_path=%s'" % self.uno_path, "'--uno_path=%s'" % self.uno_path,
"'--office_bin_path=%s'" % self.uno_path, "'--office_bin_path=%s'" % self.uno_path,
"'--hostname=%s'" % self.hostname, "'--hostname=%s'" % self.hostname,
......
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
import unittest import unittest
import logging import logging
from cloudooo.utils import logger, configureLogger, convertStringToBool, \ from cloudooo.utils import logger, configureLogger, convertStringToBool
extractModuleName
from cloudoooTestCase import make_suite from cloudoooTestCase import make_suite
class TestUtils(unittest.TestCase): class TestUtils(unittest.TestCase):
...@@ -52,13 +51,6 @@ class TestUtils(unittest.TestCase): ...@@ -52,13 +51,6 @@ class TestUtils(unittest.TestCase):
self.assertEquals(convertStringToBool('faLse'), False) self.assertEquals(convertStringToBool('faLse'), False)
self.assertEquals(convertStringToBool(''), None) self.assertEquals(convertStringToBool(''), None)
def testExtractModuleName(self):
"""Test if the module name resturns correctly"""
self.assertEquals(extractModuleName("unoconverter"),
"cloudooo.bin.unoconverter")
self.assertEquals(extractModuleName("unomimemapper"),
"cloudooo.bin.unomimemapper")
def test_suite(): def test_suite():
return make_suite(TestUtils) return make_suite(TestUtils)
......
...@@ -122,13 +122,3 @@ def convertStringToBool(string): ...@@ -122,13 +122,3 @@ def convertStringToBool(string):
return False return False
else: else:
return None return None
def extractModuleName(script_name):
"""it extracts the module name from pkg_resources
"""
import pkg_resources
resources = pkg_resources.get_distribution("cloudooo")
console_script_list = resources.get_entry_map()['console_scripts']
return console_script_list[script_name].module_name
from setuptools import setup, find_packages from setuptools import setup, find_packages
from os import path from os import path
version = '1.0.8' version = '1.0.9'
folder_path = path.abspath(path.dirname(__file__)) + "/cloudooo" folder_path = path.abspath(path.dirname(__file__)) + "/cloudooo"
......
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