Commit da35d619 authored by Gabriel Monnerat's avatar Gabriel Monnerat

- remove ooolib.py because the code was splited in unoconverter.py and...

- remove ooolib.py because the code was splited in unoconverter.py and unomimemapper.py. With this, the helper scripts don't have cloudooo as dependency.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@38553 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f53bbcb2
...@@ -30,7 +30,6 @@ from os import environ ...@@ -30,7 +30,6 @@ from os import environ
from os.path import exists, join from os.path import exists, join
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from threading import Lock from threading import Lock
from cloudooo.ooolib import setUpUnoEnvironment
from zope.interface import implements from zope.interface import implements
from application import Application from application import Application
from sys import executable as python_path from sys import executable as python_path
...@@ -89,7 +88,6 @@ class OpenOffice(Application): ...@@ -89,7 +88,6 @@ class OpenOffice(Application):
uno_path -- Full path of the Uno Library uno_path -- Full path of the Uno Library
""" """
Application.loadSettings(self, hostname, port, path_run_dir, display_id) Application.loadSettings(self, hostname, port, path_run_dir, display_id)
setUpUnoEnvironment(uno_path, office_binary_path)
self.office_binary_path = office_binary_path self.office_binary_path = office_binary_path
self.uno_path = uno_path self.uno_path = uno_path
self.process_name = "soffice.bin" self.process_name = "soffice.bin"
......
...@@ -5,7 +5,6 @@ import sys ...@@ -5,7 +5,6 @@ import sys
from base64 import encodestring from base64 import encodestring
from xmlrpclib import ServerProxy from xmlrpclib import ServerProxy
from getopt import getopt, GetoptError from getopt import getopt, GetoptError
from cloudooo.utils import usage
DOCUMENT_STRING = "MemoryMonitor - TimeoutMonitor - RequestMonitor\n\nOOHandler\n\nMimemapper\n\nERP5\n" DOCUMENT_STRING = "MemoryMonitor - TimeoutMonitor - RequestMonitor\n\nOOHandler\n\nMimemapper\n\nERP5\n"
HOSTNAME = PORT = None HOSTNAME = PORT = None
...@@ -44,7 +43,7 @@ def main(): ...@@ -44,7 +43,7 @@ def main():
opt_list, arg_list = getopt(sys.argv[1:], "", opt_list, arg_list = getopt(sys.argv[1:], "",
["port=","hostname="]) ["port=","hostname="])
except GetoptError, e: except GetoptError, e:
usage(sys.stderr, "%s \nUse --port and --hostname" % e) print >> sys.stderr, "%s \nUse --port and --hostname" % e
sys.exit(2) sys.exit(2)
for opt, arg in opt_list: for opt, arg in opt_list:
...@@ -54,7 +53,7 @@ def main(): ...@@ -54,7 +53,7 @@ def main():
HOSTNAME = arg HOSTNAME = arg
if not HOSTNAME and not PORT: if not HOSTNAME and not PORT:
usage(sys.stderr, "Use --port and --hostname") print >> sys.stderr, "Use --port and --hostname"
sys.exit(2) sys.exit(2)
suite = unittest.TestLoader().loadTestsFromTestCase(CloudoooTestCase) suite = unittest.TestLoader().loadTestsFromTestCase(CloudoooTestCase)
unittest.TextTestRunner(verbosity=2).run(suite) unittest.TextTestRunner(verbosity=2).run(suite)
##############################################################################
#
# Copyright (c) 2002-2010 Nexedi SA and Contributors. All Rights Reserved.
# Gabriel M. Monnerat <gabriel@tiolive.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from os import environ, putenv
from sys import path
from os.path import exists
def setUpUnoEnvironment(uno_path=None, office_binary_path=None):
"""Set up the environment to use the uno library and connect with the
openoffice by socket"""
if uno_path is not None:
environ['uno_path'] = uno_path
else:
uno_path = environ.get('uno_path')
if office_binary_path is not None:
environ['office_binary_path'] = office_binary_path
else:
office_binary_path = environ.get('office_binary_path')
# Add in sys.path the path of pyuno
if uno_path not in path:
path.append(uno_path)
fundamentalrc_file = '%s/fundamentalrc' % office_binary_path
if exists(fundamentalrc_file) and \
not environ.has_key('URE_BOOTSTRAP'):
putenv('URE_BOOTSTRAP','vnd.sun.star.pathname:%s' % fundamentalrc_file)
def createProperty(name, value):
"""Create property"""
setUpUnoEnvironment()
from com.sun.star.beans import PropertyValue
property = PropertyValue()
property.Name = name
property.Value = value
return property
# XXX - method duplicated
def createSpecificProperty(filter_name):
"""Creates a property according to the filter"""
setUpUnoEnvironment()
import uno
from com.sun.star.beans import PropertyValue
if filter_name == "impress_html_Export":
property = PropertyValue('FilterData', 0,
uno.Any('[]com.sun.star.beans.PropertyValue',
(PropertyValue('IsExportNotes', 0, True, 0),
PropertyValue('Format', 0, 2, 0),),), 0)
elif filter_name == "impress_pdf_Export":
property = PropertyValue('FilterData', 0,
uno.Any('[]com.sun.star.beans.PropertyValue',
(PropertyValue('ExportNotesPages', 0, True, 0),),), 0)
elif filter_name in ("draw_html_Export", "HTML (StarCalc)"):
property = PropertyValue('FilterData', 0,
uno.Any('[]com.sun.star.beans.PropertyValue',
(PropertyValue('Format', 0, 2, 0),),), 0)
elif filter_name == "Text (encoded)":
property = PropertyValue('FilterFlags', 0, 'UTF8,LF', 0)
else:
return []
return [property,]
def getServiceManager(host, port):
"""Get the ServiceManager from the running OpenOffice.org."""
setUpUnoEnvironment()
import uno
# Get the uno component context from the PyUNO runtime
uno_context = uno.getComponentContext()
# Create the UnoUrlResolver on the Python side.
url_resolver = "com.sun.star.bridge.UnoUrlResolver"
resolver = uno_context.ServiceManager.createInstanceWithContext(url_resolver,
uno_context)
# Connect to the running OpenOffice.org and get its
# context.
uno_connection = resolver.resolve("uno:socket,host=%s,port=%s;urp;StarOffice.ComponentContext" % (host, port))
# Get the ServiceManager object
return uno_connection.ServiceManager
def systemPathToFileUrl(path):
"""Returns a path in uno library patterns"""
setUpUnoEnvironment()
from unohelper import systemPathToFileUrl
return systemPathToFileUrl(path)
...@@ -67,11 +67,6 @@ def waitStopDaemon(daemon, attempts=5): ...@@ -67,11 +67,6 @@ def waitStopDaemon(daemon, attempts=5):
if not daemon.status(): if not daemon.status():
break break
def usage(stream, msg=None):
"""Print the message"""
if msg:
print >>stream, msg
def configureLogger(level=None, debug_mode=False): def configureLogger(level=None, debug_mode=False):
"""Configure logger. """Configure logger.
......
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