[svn] r5803 - trunk/tools/unoconv

packagers at lists.rpmforge.net packagers at lists.rpmforge.net
Sat Sep 1 06:01:18 CEST 2007


Author: dag
Date: 2007-09-01 06:01:18 +0200 (Sat, 01 Sep 2007)
New Revision: 5803

Modified:
   trunk/tools/unoconv/ChangeLog
   trunk/tools/unoconv/unoconv
   trunk/tools/unoconv/unoconv.spec
Log:
Now properly check if there is a GUI attached and terminate() or -unaccept instance

Modified: trunk/tools/unoconv/ChangeLog
===================================================================
--- trunk/tools/unoconv/ChangeLog	2007-09-01 03:28:53 UTC (rev 5802)
+++ trunk/tools/unoconv/ChangeLog	2007-09-01 04:01:18 UTC (rev 5803)
@@ -1,3 +1,6 @@
+* 0.3svn - released 01/09/2007
+- Now properly check if there is a GUI attached and terminate() or -unaccept instance
+
 * 0.3 - released 31/08/2007
 - Determine doctype from input filename (if not specified)
 - Created a seperate class and allow to use as a library (like DocumentConverter.py)

Modified: trunk/tools/unoconv/unoconv
===================================================================
--- trunk/tools/unoconv/unoconv	2007-09-01 03:28:53 UTC (rev 5802)
+++ trunk/tools/unoconv/unoconv	2007-09-01 04:01:18 UTC (rev 5803)
@@ -34,6 +34,7 @@
 
 from com.sun.star.beans import PropertyValue
 from com.sun.star.connection import NoConnectException
+from com.sun.star.lang import DisposedException
 from com.sun.star.io import IOException, XOutputStream
 from com.sun.star.script import CannotConvertException
 from com.sun.star.uno import Exception as UnoException
@@ -41,7 +42,7 @@
 __version__ = "$Revision$"
 # $Source$
 
-VERSION = '0.3'
+VERSION = '0.3svn'
 
 doctypes = ('document', 'graphics', 'presentation', 'spreadsheet')
 
@@ -518,21 +519,42 @@
 def die(ret, str=None):
     "Print error and exit with errorcode"
     global oopid
+    global convertor
+
     if str:
         error(0, 'Error: %s' % str)
-    if oopid:
-        error(2, 'Taking down OpenOffice with pid %s.' % oopid)
+
+    ### Did we start a process and is it bound to a GUI ?
+    if oopid and not convertor.desktop.getCurrentFrame():
+#        error(2, 'Taking down OpenOffice with pid %s.' % oopid)
+        try:
+            ### FIXME: Send terminate event to perfectly good OpenOffice GUI
+            convertor.desktop.terminate()
+        except DisposedException:
+            error(2, 'OpenOffice instance successfully terminated.')
+
+    ### Otherwise -unaccept connection
+    elif convertor.desktop.getCurrentFrame():
+        for bin in ('soffice.bin', 'soffice', ):
+            try:
+                os.spawnvp(os.P_NOWAIT, bin, [bin, "-nologo", "-nodefault", "-unaccept=%s" % op.connection]);
+                error(2, 'OpenOffice listener successfully disabled.')
+                break
+            except Exception, e:
+                continue
+
 #        os.setpgid(oopid, 0)
 #        os.killpg(os.getpgid(oopid), 15)
-        try:
-            os.kill(oopid, 15)
-            error(2, 'Waiting for OpenOffice with pid %s to disappear.' % oopid)
-            os.waitpid(oopid, os.WUNTRACED)
-        except:
-            error(2, 'No OpenOffice with pid %s to take down' % oopid)
+#        try:
+#            os.kill(oopid, 15)
+#            error(2, 'Waiting for OpenOffice with pid %s to disappear.' % oopid)
+#            os.waitpid(oopid, os.WUNTRACED)
+#        except:
+#            error(2, 'No OpenOffice with pid %s to take down' % oopid)
     sys.exit(ret)
 
 def main():
+    global convertor
     try:
         if op.listener:
             listener = Listener()
@@ -555,6 +577,8 @@
     except OSError:
         error(0, "Warning: failed to launch OpenOffice. Aborting.")
 
+convertor = None
+
 ### Main entrance
 if __name__ == '__main__':
     exitcode = 0

Modified: trunk/tools/unoconv/unoconv.spec
===================================================================
--- trunk/tools/unoconv/unoconv.spec	2007-09-01 03:28:53 UTC (rev 5802)
+++ trunk/tools/unoconv/unoconv.spec	2007-09-01 04:01:18 UTC (rev 5803)
@@ -8,7 +8,7 @@
 
 Summary: Tool to convert between any document format supported by OpenOffice
 Name: unoconv
-Version: 0.3
+Version: 0.3svn
 Release: 1
 License: GPL
 Group: System Environment/Base
@@ -57,6 +57,9 @@
 %{_bindir}/unoconv
 
 %changelog
+* Sat Sep 01 2007 Dag Wieers <dag at wieers.com> - 0.3svn-1
+- Updated to release 0.3svn.
+
 * Fri Aug 31 2007 Dag Wieers <dag at wieers.com> - 0.3-1
 - Updated to release 0.3.
 



More information about the svn-commits mailing list