[Erp5-report] r38571 gabriel - in /erp5/trunk/utils/cloudooo/cloudooo: bin/ helper/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Sep 23 02:05:14 CEST 2010
Author: gabriel
Date: Thu Sep 23 02:05:12 2010
New Revision: 38571
URL: http://svn.erp5.org?rev=38571&view=rev
Log:
move openoffice_tester.py and add helper_utils.py to remove code duplicated
Added:
erp5/trunk/utils/cloudooo/cloudooo/helper/helper_utils.py
erp5/trunk/utils/cloudooo/cloudooo/helper/openoffice_tester.py
- copied, changed from r38533, erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py
Removed:
erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py
Modified:
erp5/trunk/utils/cloudooo/cloudooo/helper/unoconverter.py
erp5/trunk/utils/cloudooo/cloudooo/helper/unomimemapper.py
Removed: erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py?rev=38570&view=auto
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py (removed)
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-import sys
-from getopt import getopt, GetoptError
-from cloudooo.utils import usage
-from cloudooo import ooolib
-from os import environ
-
-def test_openoffice(hostname, port):
- try:
- ooolib.getServiceManager(hostname, port)
- return True
- except Exception, err:
- print err
- return False
-
-def main():
- try:
- opt_list, arg_list = getopt(sys.argv[1:], "",
- ["port=","hostname=","uno_path="])
- except GetoptError, e:
- usage(sys.stderr, "%s \nUse --port and --hostname" % e)
- sys.exit(2)
-
- for opt, arg in opt_list:
- if opt == "--port":
- port = arg
- elif opt == "--hostname":
- hostname = arg
- elif opt == "--uno_path":
- environ["uno_path"] = arg
-
- print test_openoffice(hostname, port)
-
-
-if __name__ == "__main__":
- main()
Added: erp5/trunk/utils/cloudooo/cloudooo/helper/helper_utils.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/helper/helper_utils.py?rev=38571&view=auto
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/helper/helper_utils.py (added)
+++ erp5/trunk/utils/cloudooo/cloudooo/helper/helper_utils.py [utf8] Thu Sep 23 02:05:12 2010
@@ -0,0 +1,14 @@
+def getServiceManager(host, port):
+ """Get the ServiceManager from the running OpenOffice.org."""
+ 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
Copied: erp5/trunk/utils/cloudooo/cloudooo/helper/openoffice_tester.py (from r38533, erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py)
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/helper/openoffice_tester.py?p2=erp5/trunk/utils/cloudooo/cloudooo/helper/openoffice_tester.py&p1=erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py&r1=38533&r2=38571&rev=38571&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/bin/openoffice_tester.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/helper/openoffice_tester.py [utf8] Thu Sep 23 02:05:12 2010
@@ -1,13 +1,12 @@
#!/usr/bin/env python
import sys
+import helper_utils
from getopt import getopt, GetoptError
-from cloudooo.utils import usage
-from cloudooo import ooolib
from os import environ
def test_openoffice(hostname, port):
try:
- ooolib.getServiceManager(hostname, port)
+ helper_utils.getServiceManager(hostname, port)
return True
except Exception, err:
print err
Modified: erp5/trunk/utils/cloudooo/cloudooo/helper/unoconverter.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/helper/unoconverter.py?rev=38571&r1=38570&r2=38571&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/helper/unoconverter.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/helper/unoconverter.py [utf8] Thu Sep 23 02:05:12 2010
@@ -29,6 +29,7 @@
import sys
import jsonpickle
+import helper_utils
from types import UnicodeType, InstanceType
from os import environ, putenv
from os.path import dirname, exists
@@ -108,21 +109,6 @@ class UnoConverter(object):
property.Value = value
return property
- def _getServiceManager(self, host, port):
- """Get the ServiceManager from the running OpenOffice.org."""
- 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 _createSpecificProperty(self, filter_name):
"""Creates a property according to the filter"""
import uno
@@ -173,7 +159,7 @@ class UnoConverter(object):
def _load(self):
"""Create one document with basic properties"""
- service_manager = self._getServiceManager(self.hostname, self.port)
+ service_manager = helper_utils.getServiceManager(self.hostname, self.port)
desktop = service_manager.createInstance("com.sun.star.frame.Desktop")
uno_url = self.systemPathToFileUrl(self.document_url)
uno_document = desktop.loadComponentFromURL(uno_url, "_blank", 0, ())
@@ -225,7 +211,7 @@ class UnoConverter(object):
if field_value_str:
fieldname = document_info.getUserFieldName(number)
metadata[fieldname] = field_value_str
- service_manager = self._getServiceManager(self.hostname, self.port)
+ service_manager = helper_utils.getServiceManager(self.hostname, self.port)
uno_file_access = service_manager.createInstance("com.sun.star.ucb.SimpleFileAccess")
doc = uno_file_access.openFileRead(self.systemPathToFileUrl(self.document_url))
property_list = []
Modified: erp5/trunk/utils/cloudooo/cloudooo/helper/unomimemapper.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/helper/unomimemapper.py?rev=38571&r1=38570&r2=38571&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/helper/unomimemapper.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/helper/unomimemapper.py [utf8] Thu Sep 23 02:05:12 2010
@@ -28,6 +28,7 @@
##############################################################################
import sys
+import helper_utils
from os import environ, path, putenv
from getopt import getopt, GetoptError
from types import InstanceType
@@ -55,7 +56,7 @@ class UnoMimemapper(object):
""" Receives hostname and port from openoffice and create a service manager"""
self._setUpUnoEnvironment(kw.get("uno_path"),
kw.get("office_binary_path"))
- self.service_manager = self._getServiceManager(hostname, port)
+ self.service_manager = helper_utils.getServiceManager(hostname, port)
def _getElementNameByService(self, uno_service, ignore_name_list=[]):
"""Returns an dict with elements."""
@@ -95,21 +96,6 @@ class UnoMimemapper(object):
not environ.has_key('URE_BOOTSTRAP'):
putenv('URE_BOOTSTRAP','vnd.sun.star.pathname:%s' % fundamentalrc_file)
- def _getServiceManager(self, host, port):
- """Get the ServiceManager from the running OpenOffice.org."""
- 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 getFilterDict(self):
"""Return all filters and your properties"""
filter_service = self.service_manager.createInstance("com.sun.star.document.FilterFactory")
More information about the Erp5-report
mailing list