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
=====
......
......@@ -37,7 +37,7 @@ from sys import executable as python_path
from xvfb import xvfb
from cloudooo.interfaces.lockable import ILockable
from cloudooo.utils import logger, waitStartDaemon, removeDirectory, \
waitStopDaemon, convertStringToBool, extractModuleName
waitStopDaemon, convertStringToBool
class OpenOffice(Application):
"""Object to control one OOo Instance and all features instance."""
......@@ -60,7 +60,7 @@ class OpenOffice(Application):
logger.debug("Test OpenOffice %s - Pid %s" % (self.getAddress()[-1], self.pid()))
command = [python_path
, "'-c'"
, "'from %s import main;main()'" % extractModuleName("openoffice_tester")
, "'from cloudooo.bin.openoffice_tester import main;main()'"
, "'--hostname=%s'" % host
, "'--port=%s'" % port
, "'--uno_path=%s'" % self.uno_path]
......
......@@ -32,9 +32,8 @@ from application.xvfb import xvfb
from wsgixmlrpcapplication import WSGIXMLRPCApplication
from utils import convertStringToBool, configureLogger
from os import path, mkdir
from sys import executable
from mimemapper import mimemapper
import monitor, gc, pkg_resources
import monitor, gc
def stopProcesses():
monitor.stop()
......@@ -56,9 +55,6 @@ def application(global_config, **local_config):
application_hostname -- Sets the host to Xvfb and Openoffice.
virtual_screen -- Use to define the screen to Xvfb
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.
e.g office_bin_path='/opt/openoffice.org3/program'
uno_path -- Full path to pyuno library.
......
......@@ -36,7 +36,7 @@ from cloudooo.interfaces.handler import IHandler
from cloudooo.mimemapper import mimemapper
from cloudooo.document import FileSystemDocument
from cloudooo.monitor.timeout import MonitorTimeout
from cloudooo.utils import logger, extractModuleName
from cloudooo.utils import logger
from psutil import pid_exists
from sys import executable as python_path
......@@ -72,7 +72,7 @@ class OOHandler:
kw['port'] = port
command_list = [python_path
, "-c"
, "'from %s import main;main()'" % extractModuleName("unoconverter")
, "'from cloudooo.bin.unoconverter import main;main()'"
, "--uno_path='%s'" % self.uno_path
, "--office_bin_path='%s'" % self.office_bin_path
, "--document_url='%s'" % self.document.getUrl()]
......
......@@ -34,7 +34,6 @@ from os import environ
from sys import executable as python_path
from interfaces.mimemapper import IMimemapper
from types import InstanceType
from utils import extractModuleName
class MimeMapper(object):
"""Load all filters from OOo. You can get the of the filter you want or all
......@@ -107,7 +106,7 @@ class MimeMapper(object):
office_bin_path = kw.get("office_bin_path", environ.get('office_bin_path'))
command = [python_path
, "'-c'"
, "'from %s import main;main()'" % extractModuleName("unomimemapper")
, "'from cloudooo.bin.unomimemapper import main;main()'"
, "'--uno_path=%s'" % uno_path
, "'--office_bin_path=%s'" % office_bin_path
, "'--hostname=%s'" % hostname, "--port=%s" % port]
......
......@@ -46,23 +46,6 @@ def check_folder(path_dir_run_cloudooo, tmp_dir_path):
if not path.exists(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):
"""Function is used to run all tests together"""
suite = unittest.TestSuite()
......@@ -108,24 +91,18 @@ def startFakeEnvironment(start_openoffice=True, conf_path=None):
virtual_screen='1')
xvfb.start()
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:
openoffice.loadSettings(hostname,
openoffice_port,
path_dir_run_cloudooo,
virtual_display_id,
office_bin_path,
uno_path,
openoffice_tester_bin=openoffice_tester_bin)
uno_path)
openoffice.start()
openoffice.acquire()
hostname, port = openoffice.getAddress()
kw = dict(unomimemapper_bin=unomimemapper_bin,
uno_path=config.get("app:main", "uno_path"),
kw = dict(uno_path=config.get("app:main", "uno_path"),
office_bin_path=config.get("app:main", "office_bin_path"))
if not mimemapper.isLoaded():
mimemapper.loadFilterList(hostname, port, **kw)
......@@ -147,12 +124,6 @@ class cloudoooTestCase(unittest.TestCase):
def setUp(self):
"""Creates a environment to run the tests. Is called always before the
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.cloudooo_port = config.get("server:main", "port")
self.openoffice_port = config.get("app:main", "openoffice_port")
......
......@@ -34,7 +34,6 @@ from cloudoooTestCase import cloudoooTestCase, make_suite
from cloudooo.mimemapper import mimemapper
from cloudooo.application.openoffice import openoffice
from cloudooo.document import FileSystemDocument
from cloudooo.utils import extractModuleName
class TestUnoConverter(cloudoooTestCase):
"""Test case to test all features of the unoconverter script"""
......@@ -58,7 +57,7 @@ class TestUnoConverter(cloudoooTestCase):
mimemapper_pickled = jsonpickle.encode(mimemapper)
command = [self.python_path,
"-c",
"'from %s import main;main()'" % extractModuleName("unoconverter"),
"'from cloudooo.bin.unoconverter import main;main()'",
"'--convert'",
"'--uno_path=%s'" % self.uno_path,
"'--office_bin_path=%s'" % self.office_bin_path,
......@@ -87,7 +86,7 @@ class TestUnoConverter(cloudoooTestCase):
"""Test script unoconverter without mimemapper serialized"""
command = [self.python_path,
"-c",
"'from %s import main;main()'" % extractModuleName("unoconverter"),
"'from cloudooo.bin.unoconverter import main;main()'",
"'--convert'",
"'--uno_path=%s'" % self.uno_path,
"'--office_bin_path=%s'" % self.office_bin_path,
......
......@@ -31,7 +31,6 @@ from cloudooo.application.openoffice import openoffice
from subprocess import Popen, PIPE
from os import environ
from cloudoooTestCase import cloudoooTestCase, make_suite
from cloudooo.utils import extractModuleName
class TestUnoMimeMapper(cloudoooTestCase):
"""Test Case to test all features of script unomimemapper"""
......@@ -53,7 +52,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
hostname, host = openoffice.getAddress()
command = [self.python_path,
"-c",
"'from %s import main; main()'" % extractModuleName("unomimemapper"),
"'from cloudooo.bin.unomimemapper import main; main()'",
"'--uno_path=%s'" % self.uno_path,
"'--office_bin_path=%s'" % self.uno_path,
"'--hostname=%s'" % self.hostname,
......@@ -74,7 +73,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
hostname, host = openoffice.getAddress()
command = [self.python_path,
"-c",
"'from %s import main; main()'" % extractModuleName("unomimemapper"),
"'from cloudooo.bin.unomimemapper import main; main()'",
"'--hostname=%s'" % self.hostname,
"'--port=%s'" % self.openoffice_port]
stdout, stderr = Popen(' '.join(command), shell=True,
......@@ -89,7 +88,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
openoffice.stop()
command = [self.python_path,
"-c",
"'from %s import main; main()'" % extractModuleName("unomimemapper"),
"'from cloudooo.bin.unomimemapper import main; main()'",
"'--uno_path=%s'" % self.uno_path,
"'--office_bin_path=%s'" % self.uno_path,
"'--hostname=%s'" % self.hostname,
......
......@@ -28,8 +28,7 @@
import unittest
import logging
from cloudooo.utils import logger, configureLogger, convertStringToBool, \
extractModuleName
from cloudooo.utils import logger, configureLogger, convertStringToBool
from cloudoooTestCase import make_suite
class TestUtils(unittest.TestCase):
......@@ -52,13 +51,6 @@ class TestUtils(unittest.TestCase):
self.assertEquals(convertStringToBool('faLse'), False)
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():
return make_suite(TestUtils)
......
......@@ -122,13 +122,3 @@ def convertStringToBool(string):
return False
else:
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 os import path
version = '1.0.8'
version = '1.0.9'
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