A few days ago I asked the question: "Is there an equivalent python function to com.sun.star.comp.helper.Bootstrap.bootstrap()?"
The answer was: there is no counterpart Bootstrap.bootstrap() in pyuno core as far as i know. You should have a look at the java implementation to see what it does ( http://udk.openoffice.org/source/browse/udk/javaunohelper/com/sun/star/comp/helper/Bootstrap.java?rev=1.13&content-type=text/vnd.viewcvs-markup ). Basically it starts the office executable before it connects to the office, so your code just does the latter part. As suggested I had a look at Bootstrap.java. Here's the result. I hope someone finds it to be useful. Kim
<?xml version="1.0"?> <!-- $RCSfile: $ last change: $Revision: $ $Author: $ $Date: $ (c)2003 by the copyright holders listed with the author-tags. If no explicit copyright holder is mentioned with a certain author, the author him-/herself is the copyright holder. All rights reserved. Public Documentation License Notice: The contents of this Documentation are subject to the Public Documentation License Version 1.0 (the "License"); you may only use this Documentation if you comply with the terms of this License. A copy of the License is available at http://www.openoffice.org/licenses/PDL.html The Original Documentation can be found in the CVS archives of openoffice.org at the place specified by RCSfile: in this header. The Initial Writer(s) of the Original Documentation are listed with the author-tags below. The Contributor(s) are listed with the author-tags below without the marker for being an initial author. All Rights Reserved. --> <snippet language="Python" application="Office"> <keywords> <keyword>Bootstrap</keyword> </keywords> <authors> <author id="kulak" initial="false" email="[EMAIL PROTECTED]">Kim Kulak</author> </authors> <question heading="Python Bootstrap module">Is there an equivalent python function to com.sun.star.comp.helper.Bootstrap.bootstrap()? <p>there is no counterpart Bootstrap.bootstrap() in pyuno core as far as i know.</p> </question> <answer> <p>I've looked at the bootstrap() function in Bootstrap.java and</p> <p>a similar function for Python.</p> <listing>###/************************************************************************* ### * ### * OpenOffice.org - a multi-platform office productivity suite ### * ### * $RCSfile: Bootstrap.java,v $ ### * ### * $Revision: 1.13 $ ### * ### * last change: $Author: rt $ $Date: 2005/09/07 18:35:19 $ ### * ### * The Contents of this file are made available subject to ### * the terms of GNU Lesser General Public License Version 2.1. ### * ### * ### * GNU Lesser General Public License Version 2.1 ### * ============================================= ### * Copyright 2005 by Sun Microsystems, Inc. ### * 901 San Antonio Road, Palo Alto, CA 94303, USA ### * ### * This library is free software; you can redistribute it and/or ### * modify it under the terms of the GNU Lesser General Public ### * License version 2.1, as published by the Free Software Foundation. ### * ### * This library 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 ### * Lesser General Public License for more details. ### * ### * You should have received a copy of the GNU Lesser General Public ### * License along with this library; if not, write to the Free Software ### * Foundation, Inc., 59 Temple Place, Suite 330, Boston, ### * MA 02111-1307 USA ### * ### ************************************************************************/ # # Translated to python from "Bootstrap.java" by Kim Kulak # import sys import os import random import time import traceback import uno from com.sun.star.connection import NoConnectException from com.sun.star.uno import Exception as UnoException class BootstrapException(UnoException): pass def bootstrap(): """Bootsrap an Uno application environment by starting an soffice server and then connecting to it. """ try: # Create default local component context. xLocalContext = uno.getComponentContext() # Name of the executable. if os.name in ('posix',): sOffice = "soffice" #elif os.name in ('nt','os2','ce'): # sOffice = "soffice.exe" else: raise BootstrapException("Not ported to %s."%(os.name,),None) # Generate a random pipe name. sPipeName = "uno" + str(int(random.random() * 0x7fffffffffffffffL)) # Command arguments. cmdArray = (sOffice,"-nologo","-nodefault","-accept=pipe,name=" + sPipeName + ";urp;") # Start the office process. p = os.spawnvp(os.P_NOWAIT,sOffice,cmdArray) status = os.waitpid(p, os.WNOHANG) if status[1] != 0: raise BootstrapException("Could not start %s."%(sOffice,),None) # Create URL resolver. resolver = xLocalContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver",xLocalContext) # connection string sConnect = "uno:pipe,name=" + sPipeName + ";urp;StarOffice.ComponentContext" # Wait until an office is started, but loop only nLoop times. nLoop = 20 while True: try: xContext = resolver.resolve(sConnect) break except NoConnectException: nLoop -= 1 if nLoop <= 0: raise BootstrapException("Cannot connect to soffice server.",None) time.sleep(0.5) # Sleep 1/2 second. except BootstrapException: raise except Exception,e: # Any other exception raise BootstrapException("Caught exception " + str(e),None) return xContext </listing> </answer> <versions> <version number="2.0.x" status="tested"/> </versions> <operating-systems> <operating-system name="Linux"/> </operating-systems> <changelog> <change author-id="kulak" date="2005-09-14">Initial version</change> </changelog> </snippet>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
