示例#1
0
def startFakeEnvironment(start_openoffice=True, conf_path=None):
    """Create a fake environment"""

    config.read(conf_path)
    uno_path = config.get("app:main", "uno_path")
    working_path = config.get("app:main", "working_path")
    hostname = config.get("server:main", "host")
    openoffice_port = int(config.get("app:main", "openoffice_port"))
    office_binary_path = config.get("app:main", "office_binary_path")
    environment_dict = {}
    for item in config.options("app:main"):
        if item.startswith("env-"):
            environment_dict[item[4:].upper()] = config.get("app:main", item)
    tmp_dir = path.join(working_path, 'tmp')
    check_folder(working_path, tmp_dir)
    if not environ.get('uno_path'):
        environ['uno_path'] = uno_path
    office_binary_path = config.get("app:main", "office_binary_path")
    if not environ.get('office_binary_path'):
        environ['office_binary_path'] = office_binary_path

    if uno_path not in sys.path:
        sys.path.append(uno_path)

    fundamentalrc_file = '%s/fundamentalrc' % office_binary_path
    if path.exists(fundamentalrc_file) and \
        'URE_BOOTSTRAP' not in environ:
        putenv('URE_BOOTSTRAP',
               'vnd.sun.star.pathname:%s' % fundamentalrc_file)

    if start_openoffice:
        default_language = config.get(
            'app:main', 'openoffice_user_interface_language', False,
            {'openoffice_user_interface_language': 'en'})
        openoffice.loadSettings(hostname, openoffice_port, working_path,
                                office_binary_path, uno_path, default_language,
                                environment_dict)
        openoffice.start()
        openoffice.acquire()
        hostname, port = openoffice.getAddress()
        kw = dict(uno_path=config.get("app:main", "uno_path"),
                  office_binary_path=config.get("app:main",
                                                "office_binary_path"))
        if not mimemapper.isLoaded():
            mimemapper.loadFilterList(hostname, port, **kw)
        openoffice.release()
        return openoffice
示例#2
0
def bootstrapHandler(configuration_dict):
    # Bootstrap handler
    from signal import signal, SIGINT, SIGQUIT, SIGHUP
    from cloudooo.handler.ooo.mimemapper import mimemapper
    from cloudooo.handler.ooo.application.openoffice import openoffice
    import cloudooo.handler.ooo.monitor as monitor

    def stopProcesses(signum, frame):
        monitor.stop()
        openoffice.stop()

    # Signal to stop all processes
    signal(SIGINT, stopProcesses)
    signal(SIGQUIT, stopProcesses)
    signal(SIGHUP, stopProcesses)

    working_path = configuration_dict.get('working_path')
    application_hostname = configuration_dict.get('application_hostname')
    openoffice_port = int(configuration_dict.get('openoffice_port'))
    environment_dict = configuration_dict['env']
    # Loading Configuration to start OOo Instance and control it
    openoffice.loadSettings(
        application_hostname,
        openoffice_port,
        working_path,
        configuration_dict.get('office_binary_path'),
        configuration_dict.get('uno_path'),
        configuration_dict.get('openoffice_user_interface_language', 'en'),
        environment_dict=environment_dict,
    )
    openoffice.start()
    monitor.load(configuration_dict)

    timeout_response = int(configuration_dict.get('timeout_response'))
    kw = dict(uno_path=configuration_dict.get('uno_path'),
              office_binary_path=configuration_dict.get('office_binary_path'),
              timeout=timeout_response,
              ooo_disable_filter_list=configuration_dict.get(
                  'ooo_disable_filter_list'),
              ooo_disable_filter_name_list=configuration_dict.get(
                  'ooo_disable_filter_name_list'))

    # Load all filters
    openoffice.acquire()
    mimemapper.loadFilterList(application_hostname, openoffice_port, **kw)
    openoffice.release()
示例#3
0
def bootstrapHandler(configuration_dict):
  # Bootstrap handler
  from signal import signal, SIGINT, SIGQUIT, SIGHUP
  from cloudooo.handler.ooo.mimemapper import mimemapper
  from cloudooo.handler.ooo.application.openoffice import openoffice
  import cloudooo.handler.ooo.monitor as monitor

  def stopProcesses(signum, frame):
    monitor.stop()
    openoffice.stop()

  # Signal to stop all processes
  signal(SIGINT, stopProcesses)
  signal(SIGQUIT, stopProcesses)
  signal(SIGHUP, stopProcesses)

  working_path = configuration_dict.get('working_path')
  application_hostname = configuration_dict.get('application_hostname')
  openoffice_port = int(configuration_dict.get('openoffice_port'))
  environment_dict = configuration_dict['env']
  # Loading Configuration to start OOo Instance and control it
  openoffice.loadSettings(application_hostname,
                          openoffice_port,
                          working_path,
                          configuration_dict.get('office_binary_path'),
                          configuration_dict.get('uno_path'),
                          configuration_dict.get('openoffice_user_interface_language',
                                                 'en'),
                          environment_dict=environment_dict,
                          )
  openoffice.start()
  monitor.load(configuration_dict)

  timeout_response = int(configuration_dict.get('timeout_response'))
  kw = dict(uno_path=configuration_dict.get('uno_path'),
            office_binary_path=configuration_dict.get('office_binary_path'),
            timeout=timeout_response,
            ooo_disable_filter_list=configuration_dict.get('ooo_disable_filter_list'),
            ooo_disable_filter_name_list=configuration_dict.get('ooo_disable_filter_name_list'))

  # Load all filters
  openoffice.acquire()
  mimemapper.loadFilterList(application_hostname,
                            openoffice_port, **kw)
  openoffice.release()
示例#4
0
def startFakeEnvironment(start_openoffice=True, conf_path=None):
    """Create a fake environment"""

    config.read(conf_path)
    uno_path = config.get("app:main", "uno_path")
    working_path = config.get("app:main", "working_path")
    hostname = config.get("server:main", "host")
    openoffice_port = int(config.get("app:main", "openoffice_port"))
    office_binary_path = config.get("app:main", "office_binary_path")
    environment_dict = {}
    for item in config.options("app:main"):
        if item.startswith("env-"):
            environment_dict[item[4:].upper()] = config.get("app:main", item)
    tmp_dir = path.join(working_path, "tmp")
    check_folder(working_path, tmp_dir)
    if not environ.get("uno_path"):
        environ["uno_path"] = uno_path
    office_binary_path = config.get("app:main", "office_binary_path")
    if not environ.get("office_binary_path"):
        environ["office_binary_path"] = office_binary_path

    if uno_path not in sys.path:
        sys.path.append(uno_path)

    fundamentalrc_file = "%s/fundamentalrc" % office_binary_path
    if path.exists(fundamentalrc_file) and "URE_BOOTSTRAP" not in environ:
        putenv("URE_BOOTSTRAP", "vnd.sun.star.pathname:%s" % fundamentalrc_file)

    if start_openoffice:
        default_language = config.get(
            "app:main", "openoffice_user_interface_language", False, {"openoffice_user_interface_language": "en"}
        )
        openoffice.loadSettings(
            hostname, openoffice_port, working_path, office_binary_path, uno_path, default_language, environment_dict
        )
        openoffice.start()
        openoffice.acquire()
        hostname, port = openoffice.getAddress()
        kw = dict(
            uno_path=config.get("app:main", "uno_path"), office_binary_path=config.get("app:main", "office_binary_path")
        )
        if not mimemapper.isLoaded():
            mimemapper.loadFilterList(hostname, port, **kw)
        openoffice.release()
        return openoffice