Ejemplo n.º 1
0
 def testConversion(self):
     """Test convertion to bool"""
     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)
Ejemplo n.º 2
0
 def testConversion(self):
   """Test convertion to bool"""
   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)
Ejemplo n.º 3
0
 def _testOpenOffice(self, host, port):
   """Test if OpenOffice was started correctly"""
   logger.debug("Test OpenOffice %s - Pid %s" % (self.getAddress()[-1],
                                                 self.pid()))
   python = join(self.office_binary_path, "python")
   args = [exists(python) and python or "python",
           pkg_resources.resource_filename("cloudooo",
                                     join('handler', 'ooo',
                                          "helper", "openoffice_tester.py")),
           "--hostname=%s" % host,
           "--port=%s" % port,
           "--uno_path=%s" % self.uno_path]
   logger.debug("Testing Openoffice Instance %s" % port)
   stdout, stderr = Popen(args, stdout=PIPE,
       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:
     logger.debug("Instance %s works" % port)
     return True
Ejemplo n.º 4
0
 def _testOpenOffice(self, host, port):
   """Test if OpenOffice was started correctly"""
   logger.debug("Test OpenOffice %s - Pid %s" % (self.getAddress()[-1],
                                                 self.pid()))
   python = join(self.office_binary_path, "python")
   args = [exists(python) and python or "python",
           pkg_resources.resource_filename("cloudooo",
                                     join('handler', 'ooo',
                                          "helper", "openoffice_tester.py")),
           "--hostname=%s" % host,
           "--port=%s" % port,
           "--uno_path=%s" % self.uno_path]
   logger.debug("Testing Openoffice Instance %s" % port)
   stdout, stderr = Popen(args, stdout=PIPE,
       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:
     logger.debug("Instance %s works" % port)
     return True
Ejemplo n.º 5
0
def application(global_config, **local_config):
  """Method to load all configuration of cloudooo and start the application.
  To start the application a number of params are required:
  Keyword arguments:
  debug_mode -- Mode as the application prints the messages.
      e.g debug_mode=logging.DEBUG
  working_path -- Full path to create the environment of the processes.
      e.g working_path='/var/run/cloudooo'
  application_hostname -- Sets the host to Openoffice.
  office_binary_path -- Folder where soffice.bin is installed.
      e.g office_binary_path='/opt/libreoffice/program'
  uno_path -- Folder where UNO library is installed.
      e.g uno_path='/opt/libreoffice/basis-link/program/'
  """
  prefix = 'env-'
  environment_dict = {}
  for parameter_name, value in local_config.iteritems():
    if parameter_name.startswith(prefix):
      value = value or ''
      variable_name = parameter_name[len(prefix):]
      if variable_name == 'PATH':
        # merge only for PATH
        current_value = environ.get(variable_name, '')
        if current_value:
          value = '%s:%s' % (value, current_value)
      environment_dict[variable_name] = value

  local_config["env"] = environment_dict

  gc.enable()
  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):
    mkdir(working_path)
  # directory to create temporary files
  cloudooo_path_tmp_dir = path.join(working_path, 'tmp')
  if not path.exists(cloudooo_path_tmp_dir):
    mkdir(cloudooo_path_tmp_dir)

  util.loadMimetypeList()

  mimetype_registry = local_config.get("mimetype_registry", "")
  local_config["mimetype_registry"] = handler_mapping_list = \
                                    filter(None, mimetype_registry.split("\n"))

  ooo_disable_filter_list = []
  for filter_name in local_config.get("ooo_disable_filter_list", "").split("\n"):
    filter_name = filter_name.strip()
    if filter_name and not filter_name in ooo_disable_filter_list:
      ooo_disable_filter_list.append(filter_name)
  local_config["ooo_disable_filter_list"] = ooo_disable_filter_list

  ooo_disable_filter_name_list = []
  for filter_name in local_config.get("ooo_disable_filter_name_list", "").split("\n"):
    filter_name = filter_name.strip()
    if filter_name and not filter_name in ooo_disable_filter_name_list:
      ooo_disable_filter_name_list.append(filter_name)
  local_config["ooo_disable_filter_name_list"] = ooo_disable_filter_name_list

  handler_dict = {}
  for line in handler_mapping_list:
    input_mimetype, output_mimetype, handler = line.strip().split()
    if handler not in handler_dict:
      import_path = "cloudooo.handler.%s.handler" % handler
      # Import Errors are not catched, check your configuration file
      module = __import__(import_path, globals(), locals(), [''])
      # Call the bootstraping method
      getattr(module, 'bootstrapHandler', lambda x: None)(local_config)
      handler_dict[handler] = module.Handler

  local_config['handler_dict'] = handler_dict
  from manager import Manager
  cloudooo_manager = Manager(cloudooo_path_tmp_dir, **local_config)
  return WSGIXMLRPCApplication(instance=cloudooo_manager)
Ejemplo n.º 6
0
def application(global_config, **local_config):
    """Method to load all configuration of cloudooo and start the application.
  To start the application a number of params are required:
  Keyword arguments:
  debug_mode -- Mode as the application prints the messages.
      e.g debug_mode=logging.DEBUG
  working_path -- Full path to create the environment of the processes.
      e.g working_path='/var/run/cloudooo'
  application_hostname -- Sets the host to Openoffice.
  office_binary_path -- Folder where soffice.bin is installed.
      e.g office_binary_path='/opt/libreoffice/program'
  uno_path -- Folder where UNO library is installed.
      e.g uno_path='/opt/libreoffice/basis-link/program/'
  """
    prefix = 'env-'
    environment_dict = {}
    for parameter_name, value in local_config.iteritems():
        if parameter_name.startswith(prefix):
            value = value or ''
            variable_name = parameter_name[len(prefix):]
            if variable_name == 'PATH':
                # merge only for PATH
                current_value = environ.get(variable_name, '')
                if current_value:
                    value = '%s:%s' % (value, current_value)
            environment_dict[variable_name] = value

    local_config["env"] = environment_dict

    gc.enable()
    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):
        mkdir(working_path)
    # directory to create temporary files
    cloudooo_path_tmp_dir = path.join(working_path, 'tmp')
    if not path.exists(cloudooo_path_tmp_dir):
        mkdir(cloudooo_path_tmp_dir)

    util.loadMimetypeList()

    mimetype_registry = local_config.get("mimetype_registry", "")
    local_config["mimetype_registry"] = handler_mapping_list = \
                                      filter(None, mimetype_registry.split("\n"))

    ooo_disable_filter_list = []
    for filter_name in local_config.get("ooo_disable_filter_list",
                                        "").split("\n"):
        filter_name = filter_name.strip()
        if filter_name and not filter_name in ooo_disable_filter_list:
            ooo_disable_filter_list.append(filter_name)
    local_config["ooo_disable_filter_list"] = ooo_disable_filter_list

    ooo_disable_filter_name_list = []
    for filter_name in local_config.get("ooo_disable_filter_name_list",
                                        "").split("\n"):
        filter_name = filter_name.strip()
        if filter_name and not filter_name in ooo_disable_filter_name_list:
            ooo_disable_filter_name_list.append(filter_name)
    local_config["ooo_disable_filter_name_list"] = ooo_disable_filter_name_list

    handler_dict = {}
    for line in handler_mapping_list:
        input_mimetype, output_mimetype, handler = line.strip().split()
        if handler not in handler_dict:
            import_path = "cloudooo.handler.%s.handler" % handler
            # Import Errors are not catched, check your configuration file
            module = __import__(import_path, globals(), locals(), [''])
            # Call the bootstraping method
            getattr(module, 'bootstrapHandler', lambda x: None)(local_config)
            handler_dict[handler] = module.Handler

    local_config['handler_dict'] = handler_dict
    from manager import Manager
    cloudooo_manager = Manager(cloudooo_path_tmp_dir, **local_config)
    return WSGIXMLRPCApplication(instance=cloudooo_manager)