From da35d6193c338390518d75907ca02194cc0e8bcf Mon Sep 17 00:00:00 2001 From: Gabriel Monnerat <gabriel@tiolive.com> Date: Wed, 22 Sep 2010 15:48:26 +0000 Subject: [PATCH] - 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 --- cloudooo/application/openoffice.py | 2 - cloudooo/bin/cloudooo_tester.py | 5 +- cloudooo/ooolib.py | 110 ----------------------------- cloudooo/utils.py | 5 -- 4 files changed, 2 insertions(+), 120 deletions(-) delete mode 100644 cloudooo/ooolib.py diff --git a/cloudooo/application/openoffice.py b/cloudooo/application/openoffice.py index c4dad85..86e4b08 100644 --- a/cloudooo/application/openoffice.py +++ b/cloudooo/application/openoffice.py @@ -30,7 +30,6 @@ from os import environ from os.path import exists, join from subprocess import Popen, PIPE from threading import Lock -from cloudooo.ooolib import setUpUnoEnvironment from zope.interface import implements from application import Application from sys import executable as python_path @@ -89,7 +88,6 @@ class OpenOffice(Application): uno_path -- Full path of the Uno Library """ Application.loadSettings(self, hostname, port, path_run_dir, display_id) - setUpUnoEnvironment(uno_path, office_binary_path) self.office_binary_path = office_binary_path self.uno_path = uno_path self.process_name = "soffice.bin" diff --git a/cloudooo/bin/cloudooo_tester.py b/cloudooo/bin/cloudooo_tester.py index 1ac8ae6..0858088 100755 --- a/cloudooo/bin/cloudooo_tester.py +++ b/cloudooo/bin/cloudooo_tester.py @@ -5,7 +5,6 @@ import sys from base64 import encodestring from xmlrpclib import ServerProxy from getopt import getopt, GetoptError -from cloudooo.utils import usage DOCUMENT_STRING = "MemoryMonitor - TimeoutMonitor - RequestMonitor\n\nOOHandler\n\nMimemapper\n\nERP5\n" HOSTNAME = PORT = None @@ -44,7 +43,7 @@ def main(): opt_list, arg_list = getopt(sys.argv[1:], "", ["port=","hostname="]) except GetoptError, e: - usage(sys.stderr, "%s \nUse --port and --hostname" % e) + print >> sys.stderr, "%s \nUse --port and --hostname" % e sys.exit(2) for opt, arg in opt_list: @@ -54,7 +53,7 @@ def main(): HOSTNAME = arg if not HOSTNAME and not PORT: - usage(sys.stderr, "Use --port and --hostname") + print >> sys.stderr, "Use --port and --hostname" sys.exit(2) suite = unittest.TestLoader().loadTestsFromTestCase(CloudoooTestCase) unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/cloudooo/ooolib.py b/cloudooo/ooolib.py deleted file mode 100644 index 94b1820..0000000 --- a/cloudooo/ooolib.py +++ /dev/null @@ -1,110 +0,0 @@ -############################################################################## -# -# 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) diff --git a/cloudooo/utils.py b/cloudooo/utils.py index 7540384..d5647f4 100644 --- a/cloudooo/utils.py +++ b/cloudooo/utils.py @@ -67,11 +67,6 @@ def waitStopDaemon(daemon, attempts=5): if not daemon.status(): break -def usage(stream, msg=None): - """Print the message""" - if msg: - print >>stream, msg - def configureLogger(level=None, debug_mode=False): """Configure logger. -- 2.30.9