Commit 82dda2eb authored by Gabriel Monnerat's avatar Gabriel Monnerat

refactor to don't use plurals, use sample and util instead of samples and utils

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@45491 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7fbc4f6b
......@@ -17,7 +17,7 @@ Create Configuration File
=========================
The configuration file is used to start the application using paster.
$ cp ./cloudooo/samples/samples.conf . # Copy to current folder
$ cp ./cloudooo/sample/sample.conf . # Copy to current folder
The next step is define some attributes in cloudooo.conf:
- working_path - folder to run the application. This folder need be created.
......
......@@ -4,6 +4,6 @@ import pkg_resources
def main():
cloudooo_conf_path = pkg_resources.resource_filename("cloudooo",
path.join("samples", "cloudooo.conf.in"))
path.join("sample", "cloudooo.conf.in"))
print open(cloudooo_conf_path).read()
......@@ -28,8 +28,8 @@
from zope.interface import implements
from cloudooo.interfaces.application import IApplication
from cloudooo.utils.utils import logger
from cloudooo.handler.ooo.utils.utils import waitStopDaemon
from cloudooo.util.util import logger
from cloudooo.handler.ooo.util.util import waitStopDaemon
from psutil import pid_exists, Process, AccessDenied
......
......@@ -34,8 +34,8 @@ from threading import Lock
from zope.interface import implements
from application import Application
from cloudooo.interfaces.lockable import ILockable
from cloudooo.utils.utils import logger, convertStringToBool
from cloudooo.handler.ooo.utils.utils import waitStartDaemon, \
from cloudooo.util.util import logger, convertStringToBool
from cloudooo.handler.ooo.util.util import waitStartDaemon, \
removeDirectory, waitStopDaemon, \
socketStatus
......
......@@ -30,7 +30,7 @@ from zipfile import ZipFile
from StringIO import StringIO
from lxml import etree
from os import path
from cloudooo.utils.utils import logger
from cloudooo.util.util import logger
from cloudooo.handler.ooo.document import OdfDocument
# URI Definitions.
......
......@@ -39,7 +39,7 @@ from cloudooo.handler.ooo.mimemapper import mimemapper
from cloudooo.handler.ooo.document import FileSystemDocument
from cloudooo.handler.ooo.monitor.timeout import MonitorTimeout
from cloudooo.handler.ooo.monitor import monitor_sleeping_time
from cloudooo.utils.utils import logger
from cloudooo.util.util import logger
from psutil import pid_exists
......
#!/usr/bin/env python
import sys
import helper_utils
import helper_util
from getopt import getopt, GetoptError
from os import environ
def test_openoffice(hostname, port):
try:
helper_utils.getServiceManager(hostname, port)
helper_util.getServiceManager(hostname, port)
return True
except Exception, err:
print err
......
......@@ -28,7 +28,7 @@
##############################################################################
import sys
import helper_utils
import helper_util
from types import UnicodeType, InstanceType
from os import environ, putenv
from os.path import dirname, exists
......@@ -159,7 +159,7 @@ class UnoConverter(object):
refresh argument tells to uno environment to
replace dynamic properties of document before conversion
"""
service_manager = helper_utils.getServiceManager(self.hostname, self.port)
service_manager = helper_util.getServiceManager(self.hostname, self.port)
desktop = service_manager.createInstance("com.sun.star.frame.Desktop")
uno_url = self.systemPathToFileUrl(self.document_url)
uno_document = desktop.loadComponentFromURL(uno_url, "_blank", 0, ())
......@@ -219,7 +219,7 @@ class UnoConverter(object):
if field_value_str:
fieldname = document_info.getUserFieldName(number)
metadata[fieldname] = field_value_str
service_manager = helper_utils.getServiceManager(self.hostname, self.port)
service_manager = helper_util.getServiceManager(self.hostname, self.port)
type_detection = service_manager.createInstance("com.sun.star.document.TypeDetection")
uno_file_access = service_manager.createInstance("com.sun.star.ucb.SimpleFileAccess")
doc = uno_file_access.openFileRead(self.systemPathToFileUrl(self.document_url))
......
......@@ -32,7 +32,7 @@ try:
import json
except ImportError:
import simplejson as json
import helper_utils
import helper_util
from os import environ, path, putenv
from getopt import getopt, GetoptError
from types import InstanceType
......@@ -61,7 +61,7 @@ class UnoMimemapper(object):
""" Receives hostname and port from openoffice and create a service manager"""
self._setUpUnoEnvironment(kw.get("uno_path"),
kw.get("office_binary_path"))
self.service_manager = helper_utils.getServiceManager(hostname, port)
self.service_manager = helper_util.getServiceManager(hostname, port)
def _getElementNameByService(self, uno_service, ignore_name_list=[]):
"""Returns an dict with elements."""
......
......@@ -29,7 +29,7 @@
from monitor import Monitor
from multiprocessing import Process
import psutil
from cloudooo.utils.utils import logger
from cloudooo.util.util import logger
from time import sleep
......
......@@ -28,7 +28,7 @@
from monitor import Monitor
from threading import Thread
from cloudooo.utils.utils import logger
from cloudooo.util.util import logger
from time import sleep
......
......@@ -28,7 +28,7 @@
from monitor import Monitor
from threading import Thread
from cloudooo.utils.utils import logger
from cloudooo.util.util import logger
from time import sleep, time
......
......@@ -29,7 +29,7 @@
from monitor import Monitor
from multiprocessing import Process
from time import sleep
from cloudooo.utils.utils import logger
from cloudooo.util.util import logger
class MonitorTimeout(Monitor, Process):
......
......@@ -28,7 +28,7 @@
from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
from cloudooo.handler.ooo.application.openoffice import OpenOffice
from cloudooo.handler.ooo.utils.utils import waitStopDaemon
from cloudooo.handler.ooo.util.util import waitStopDaemon
OPENOFFICE = True
......
......@@ -28,43 +28,43 @@
import unittest
import logging
from cloudooo.utils import utils
from cloudooo.util import util
from cloudooo.handler.tests.handlerTestCase import make_suite
import mimetypes
class TestUtils(unittest.TestCase):
class TestUtil(unittest.TestCase):
"""Test Utils"""
def testLog(self):
"""Instanciate Log and test __call__ called function log"""
utils.configureLogger(logging.DEBUG)
utils.logger.info("Test Log")
utils.logger.debug("Test Log")
utils.configureLogger(logging.INFO)
utils.logger.info("Test Log")
utils.logger.debug("Test Log")
util.configureLogger(logging.DEBUG)
util.logger.info("Test Log")
util.logger.debug("Test Log")
util.configureLogger(logging.INFO)
util.logger.info("Test Log")
util.logger.debug("Test Log")
def testConversion(self):
"""Test convertion to bool"""
self.assertTrue(utils.convertStringToBool('true'))
self.assertEquals(utils.convertStringToBool('false'), False)
self.assertTrue(utils.convertStringToBool('truE'))
self.assertEquals(utils.convertStringToBool('faLse'), False)
self.assertEquals(utils.convertStringToBool(''), None)
self.assertTrue(util.convertStringToBool('true'))
self.assertEquals(util.convertStringToBool('false'), False)
self.assertTrue(util.convertStringToBool('truE'))
self.assertEquals(util.convertStringToBool('faLse'), False)
self.assertEquals(util.convertStringToBool(''), None)
def testLoadMimetypelist(self):
"""Test if the file with mimetypes is loaded correctly"""
self.assertEquals(mimetypes.types_map.get(".ogv"), None)
self.assertEquals(mimetypes.types_map.get(".3gp"), None)
utils.loadMimetypeList()
util.loadMimetypeList()
self.assertEquals(mimetypes.types_map.get(".ogv"), "video/ogg")
self.assertEquals(mimetypes.types_map.get(".3gp"), "video/3gpp")
def test_suite():
return make_suite(TestUtils)
return make_suite(TestUtil)
if "__main__" == __name__:
suite = unittest.TestLoader().loadTestsFromTestCase(TestUtils)
suite = unittest.TestLoader().loadTestsFromTestCase(TestUtil)
unittest.TextTestRunner(verbosity=2).run(suite)
......@@ -31,7 +31,7 @@ from errno import EADDRINUSE
from time import sleep
from os import remove
from shutil import rmtree
from cloudooo.utils.utils import logger
from cloudooo.util.util import logger
def removeDirectory(path):
......
......@@ -9,7 +9,7 @@ from ConfigParser import ConfigParser
from argparse import ArgumentParser
from os import chdir, path, environ, curdir, remove
import psutil
from cloudooo.handler.ooo.utils.utils import socketStatus
from cloudooo.handler.ooo.util.util import socketStatus
from signal import SIGQUIT
......
......@@ -32,7 +32,7 @@ from mimetypes import guess_all_extensions, guess_extension
from base64 import encodestring, decodestring
from zope.interface import implements
from interfaces.manager import IManager, IERP5Compatibility
from utils.utils import logger
from util.util import logger
from cloudooo.interfaces.granulate import ITableGranulator
from cloudooo.interfaces.granulate import IImageGranulator
from cloudooo.interfaces.granulate import ITextGranulator
......
......@@ -30,7 +30,7 @@ import gc
from os import path, mkdir, environ
from cloudooo.wsgixmlrpcapplication import WSGIXMLRPCApplication
from cloudooo.utils import utils
from cloudooo.util import util
def application(global_config, **local_config):
......@@ -63,8 +63,8 @@ def application(global_config, **local_config):
local_config['environment_dict'] = environment_dict
gc.enable()
debug_mode = utils.convertStringToBool(local_config.get('debug_mode'))
utils.configureLogger(debug_mode=debug_mode)
debug_mode = util.convertStringToBool(local_config.get('debug_mode'))
util.configureLogger(debug_mode=debug_mode)
# path of directory to run cloudooo
working_path = local_config.get('working_path')
if not path.exists(working_path):
......@@ -74,7 +74,7 @@ def application(global_config, **local_config):
if not path.exists(cloudooo_path_tmp_dir):
mkdir(cloudooo_path_tmp_dir)
utils.loadMimetypeList()
util.loadMimetypeList()
mimetype_registry = local_config.get("mimetype_registry", "")
local_config["mimetype_registry"] = handler_mapping_list = \
......
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