Skip to content

Importing the OpenOffice uno module to your Windows python #3

Description

@SChalice

You need Python version 2.6 for this to work: http://www.python.org/download/releases/2.6.6/

from:

http://forum.openoffice.org/en/forum/viewtopic.php?f=45&t=36370&p=166783

Modify your word2mediawiki.py file to include the environment import (after the other imports):

import subprocess

def import_uno():

# Variables
python_oo_executable = 'c:\\Program Files\\OpenOffice.org 3\\program\\python.exe'
python_oo_script = '-cimport os ;print(os.environ["URE_BOOTSTRAP"]) ;print(os.environ["UNO_PATH"]) ;print(os.environ["PATH"])'
path_to_uno = 'C:\\Program Files\\OpenOffice.org 3\\Basis\\program'

# Get the environment variables from OO-Python using subprocess
process = subprocess.Popen([python_oo_executable, python_oo_script], stdout=subprocess.PIPE)
result = process.communicate()
environment_variables = result[0].split('\r\n')   # Three items in the list, one for each env var

os.environ['URE_BOOTSTRAP'] = environment_variables[0]
os.environ['UNO_PATH'] = environment_variables[1]

new_paths = environment_variables[2].split(';')
existing_paths = os.environ['PATH'].split(';')
for path in new_paths:
    if path not in existing_paths:
        existing_paths.append(path)
os.environ['PATH'] = ';'.join(existing_paths)

sys.path.append(path_to_uno)

return

import_uno()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions