[unoconv] simplify python3 patch
David Tardon
dtardon at fedoraproject.org
Sat Apr 19 10:30:39 UTC 2014
commit e94c2df7ec6b331ddb4833146c389e6445b22183
Author: David Tardon <dtardon at redhat.com>
Date: Sat Apr 19 12:11:44 2014 +0200
simplify python3 patch
...o-70309-can-t-write-bytes-direct-to-stdou.patch | 19 +-
0001-python3-added-compatibility.2.patch | 384 +++
0001-python3-added-compatibility.3.patch | 629 ++++
0001-python3-added-compatibility.patch | 3628 --------------------
0001-update-FSF-address.patch | 28 -
unoconv.spec | 16 +-
6 files changed, 1021 insertions(+), 3683 deletions(-)
---
diff --git a/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch b/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch
index 24dca0d..e96aa8c 100644
--- a/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch
+++ b/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch
@@ -8,23 +8,10 @@ Subject: [PATCH] Resolves: fdo#70309 can't write bytes direct to stdout in
unoconv | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-diff --git a/unoconv2.py b/unoconv2.py
+diff --git a/unoconv b/unoconv
index a4f9490..2b0b0eb 100755
---- a/unoconv2.py
-+++ b/unoconv2.py
-@@ -1146,7 +1146,7 @@ if __name__ == '__main__':
- self.closed = 1
-
- def writeBytes( self, seq ):
-- sys.stdout.write( seq.value )
-+ sys.stdout.buffer.write( seq.value )
-
- def flush( self ):
- pass
-diff --git a/unoconv3.py b/unoconv3.py
-index a4f9490..2b0b0eb 100755
---- a/unoconv3.py
-+++ b/unoconv3.py
+--- a/unoconv
++++ b/unoconv
@@ -1146,7 +1146,7 @@ if __name__ == '__main__':
self.closed = 1
diff --git a/0001-python3-added-compatibility.2.patch b/0001-python3-added-compatibility.2.patch
new file mode 100644
index 0000000..d5416c7
--- /dev/null
+++ b/0001-python3-added-compatibility.2.patch
@@ -0,0 +1,384 @@
+From 34bbe9fa679d39921fd67002e01e7a9bf93b009a Mon Sep 17 00:00:00 2001
+From: rpm-build <rpm-build>
+Date: Sat, 19 Apr 2014 12:05:04 +0200
+Subject: [PATCH] 0001-python3-added-compatibility.2.patch
+
+---
+ unoconv | 142 +++++++++++++++++++++++++++++++++++++++-------------------------
+ 1 file changed, 86 insertions(+), 56 deletions(-)
+
+diff --git a/unoconv b/unoconv
+index 30e6706..8c45ad9 100755
+--- a/unoconv
++++ b/unoconv
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python
+
+ ### 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
+@@ -203,7 +203,7 @@ def office_environ(office):
+ ### Set UNO_PATH so that "officehelper.bootstrap()" can find soffice executable:
+ os.environ['UNO_PATH'] = office.unopath
+
+- ### Set URE_BOOTSTRAP so that "uno.getComponentContext()" bootstraps a complete
++ ### Set URE_BOOTSTRAP so that "global_uno.getComponentContext()" bootstraps a complete
+ ### UNO environment
+ if os.name in ( 'nt', 'os2' ):
+ os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamental.ini')
+@@ -277,6 +277,7 @@ def python_switch(office):
+
+ try:
+ os.execvpe(office.python, [office.python, ] + sys.argv[0:], os.environ)
++ print(office.python, [office.python, ] + sys.argv[0:], osenviron)
+ except OSError:
+ ### Mac OS X versions prior to 10.6 do not support execv in
+ ### a process that contains multiple threads. Instead of
+@@ -553,14 +554,14 @@ class Options:
+ if name in ('FilterOptions'):
+ self.exportfilteroptions = value
+ elif value in ('True', 'true'):
+- self.exportfilter.append( PropertyValue( name, 0, True, 0 ) )
++ self.exportfilter.append( UnoPropertyValue( name, 0, True, 0 ) )
+ elif value in ('False', 'false'):
+- self.exportfilter.append( PropertyValue( name, 0, False, 0 ) )
++ self.exportfilter.append( UnoPropertyValue( name, 0, False, 0 ) )
+ else:
+ try:
+- self.exportfilter.append( PropertyValue( name, 0, int(value), 0 ) )
++ self.exportfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) )
+ except ValueError:
+- self.exportfilter.append( PropertyValue( name, 0, value, 0 ) )
++ self.exportfilter.append( UnoPropertyValue( name, 0, value, 0 ) )
+ else:
+ print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg
+ elif opt in ['-f', '--format']:
+@@ -572,14 +573,14 @@ class Options:
+ if name in ('FilterOptions'):
+ self.importfilteroptions = value
+ elif value in ('True', 'true'):
+- self.importfilter.append( PropertyValue( name, 0, True, 0 ) )
++ self.importfilter.append( UnoPropertyValue( name, 0, True, 0 ) )
+ elif value in ('False', 'false'):
+- self.importfilter.append( PropertyValue( name, 0, False, 0 ) )
++ self.importfilter.append( UnoPropertyValue( name, 0, False, 0 ) )
+ else:
+ try:
+- self.importfilter.append( PropertyValue( name, 0, int(value), 0 ) )
++ self.importfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) )
+ except ValueError:
+- self.importfilter.append( PropertyValue( name, 0, value, 0 ) )
++ self.importfilter.append( UnoPropertyValue( name, 0, value, 0 ) )
+ else:
+ print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg
+ elif opt in ['-l', '--listener']:
+@@ -657,7 +658,7 @@ class Options:
+
+ def version(self):
+ ### Get office product information
+- product = uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product"))
++ product = global_uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product"))
+
+ print 'unoconv %s' % VERSION
+ print 'Written by Dag Wieers <dag at wieers.com>'
+@@ -706,7 +707,7 @@ class Convertor:
+ unocontext = None
+
+ ### Do the LibreOffice component dance
+- self.context = uno.getComponentContext()
++ self.context = global_uno.getComponentContext()
+ self.svcmgr = self.context.ServiceManager
+ resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context)
+
+@@ -714,7 +715,7 @@ class Convertor:
+ info(3, 'Connection type: %s' % op.connection)
+ try:
+ unocontext = resolver.resolve("uno:%s" % op.connection)
+- except NoConnectException, e:
++ except UnoNoConnectException, e:
+ # info(3, "Existing listener not found.\n%s" % e)
+ info(3, "Existing listener not found.")
+
+@@ -724,7 +725,7 @@ class Convertor:
+ ### Start our own OpenOffice instance
+ info(3, "Launching our own listener using %s." % office.binary)
+ try:
+- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product"))
++ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product"))
+ if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'):
+ ooproc = subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection], env=os.environ)
+ else:
+@@ -742,7 +743,7 @@ class Convertor:
+ try:
+ unocontext = resolver.resolve("uno:%s" % op.connection)
+ break
+- except NoConnectException:
++ except UnoNoConnectException:
+ time.sleep(0.5)
+ timeout += 0.5
+ except:
+@@ -759,7 +760,7 @@ class Convertor:
+ ### And some more LibreOffice magic
+ unosvcmgr = unocontext.ServiceManager
+ self.desktop = unosvcmgr.createInstanceWithContext("com.sun.star.frame.Desktop", unocontext)
+- self.cwd = unohelper.systemPathToFileUrl( os.getcwd() )
++ self.cwd = global_unohelper.systemPathToFileUrl( os.getcwd() )
+
+ ### List all filters
+ # self.filters = unosvcmgr.createInstanceWithContext( "com.sun.star.document.FilterFactory", unocontext)
+@@ -824,22 +825,22 @@ class Convertor:
+ phase = "import"
+
+ ### Load inputfile
+- inputprops = UnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=QUIET_UPDATE)
++ inputprops = GlobalUnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=UNO_QUIET_UPDATE)
+
+ # if op.password:
+-# info = UnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash")
+-# inputprops += UnoProps(ModifyPasswordInfo=info)
++# info = GlobalUnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash")
++# inputprops += GlobalUnoProps(ModifyPasswordInfo=info)
+
+- ### Cannot use UnoProps for FilterData property
++ ### Cannot use GlobalUnoProps for FilterData property
+ if op.importfilteroptions:
+ # print "Import filter options: %s" % op.importfilteroptions
+- inputprops += UnoProps(FilterOptions=op.importfilteroptions)
++ inputprops += GlobalUnoProps(FilterOptions=op.importfilteroptions)
+
+- ### Cannot use UnoProps for FilterData property
++ ### Cannot use GlobalUnoProps for FilterData property
+ if op.importfilter:
+- inputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), )
++ inputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), )
+
+- inputurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(inputfn))
++ inputurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(inputfn))
+ document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops )
+
+ if not document:
+@@ -850,8 +851,8 @@ class Convertor:
+ if op.template:
+ if os.path.exists(op.template):
+ info(1, "Template file: %s" % op.template)
+- templateprops = UnoProps(OverwriteStyles=True)
+- templateurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(op.template))
++ templateprops = GlobalUnoProps(OverwriteStyles=True)
++ templateurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(op.template))
+ document.StyleFamilies.loadStylesFromURL(templateurl, templateprops)
+ else:
+ print >>sys.stderr, 'unoconv: template file `%s\' does not exist.' % op.template
+@@ -885,26 +886,26 @@ class Convertor:
+ ### Export phase
+ phase = "export"
+
+- outputprops = UnoProps(FilterName=outputfmt.filter, OutputStream=OutputStream(), Overwrite=True)
++ outputprops = GlobalUnoProps(FilterName=outputfmt.filter, OutputStream=GlobalOutputStream(), Overwrite=True)
+
+ ### Set default filter options
+ if op.exportfilteroptions:
+ # print "Export filter options: %s" % op.exportfilteroptions
+- outputprops += UnoProps(FilterOptions=op.exportfilteroptions)
++ outputprops += GlobalUnoProps(FilterOptions=op.exportfilteroptions)
+ else:
+ if outputfmt.filter == 'Text (encoded)':
+- outputprops += UnoProps(FilterOptions="76,LF")
++ outputprops += GlobalUnoProps(FilterOptions="76,LF")
+
+ elif outputfmt.filter == 'Text':
+- outputprops += UnoProps(FilterOptions="76")
++ outputprops += GlobalUnoProps(FilterOptions="76")
+
+ elif outputfmt.filter == 'Text - txt - csv (StarCalc)':
+- outputprops += UnoProps(FilterOptions="44,34,76")
++ outputprops += GlobalUnoProps(FilterOptions="44,34,76")
+
+
+- ### Cannot use UnoProps for FilterData property
++ ### Cannot use GlobalUnoProps for FilterData property
+ if op.exportfilter:
+- outputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), )
++ outputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), )
+
+ if not op.stdout:
+ (outputfn, ext) = os.path.splitext(inputfn)
+@@ -917,14 +918,14 @@ class Convertor:
+ else:
+ outputfn = op.output
+
+- outputurl = unohelper.absolutize( self.cwd, unohelper.systemPathToFileUrl(outputfn) )
++ outputurl = global_unohelper.absolutize( self.cwd, global_unohelper.systemPathToFileUrl(outputfn) )
+ info(1, "Output file: %s" % outputfn)
+ else:
+ outputurl = "private:stream"
+
+ try:
+ document.storeToURL(outputurl, tuple(outputprops) )
+- except IOException, e:
++ except UnoIOException, e:
+ raise UnoException("Unable to store document to %s (ErrCode %d)\n\nProperties: %s" % (outputurl, e.ErrCode, outputprops), None)
+
+ phase = "dispose"
+@@ -935,24 +936,24 @@ class Convertor:
+ error("unoconv: SystemError during %s phase:\n%s" % (phase, e))
+ exitcode = 1
+
+- except RuntimeException, e:
++ except UnoRuntimeException, e:
+ error("unoconv: RuntimeException during %s phase:\nOffice probably died. %s" % (phase, e))
+ exitcode = 6
+
+- except DisposedException, e:
++ except UnoDisposedException, e:
+ error("unoconv: DisposedException during %s phase:\nOffice probably died. %s" % (phase, e))
+ exitcode = 7
+
+- except IllegalArgumentException, e:
++ except UnoIllegalArgumentException, e:
+ error("UNO IllegalArgument during %s phase:\nSource file cannot be read. %s" % (phase, e))
+ exitcode = 8
+
+- except IOException, e:
++ except UnoIOException, e:
+ # for attr in dir(e): print '%s: %s', (attr, getattr(e, attr))
+ error("unoconv: IOException during %s phase:\n%s" % (phase, e.Message))
+ exitcode = 3
+
+- except CannotConvertException, e:
++ except UnoCannotConvertException, e:
+ # for attr in dir(e): print '%s: %s', (attr, getattr(e, attr))
+ error("unoconv: CannotConvertException during %s phase:\n%s" % (phase, e.Message))
+ exitcode = 4
+@@ -975,14 +976,14 @@ class Listener:
+ global product
+
+ info(1, "Start listener on %s:%s" % (op.server, op.port))
+- self.context = uno.getComponentContext()
++ self.context = global_uno.getComponentContext()
+ self.svcmgr = self.context.ServiceManager
+ try:
+ resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context)
+- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product"))
++ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product"))
+ try:
+ unocontext = resolver.resolve("uno:%s" % op.connection)
+- except NoConnectException, e:
++ except UnoNoConnectException, e:
+ pass
+ else:
+ info(1, "Existing %s listener found, nothing to do." % product.ooName)
+@@ -1039,7 +1040,7 @@ def die(ret, msg=None):
+ info(3, 'Terminating %s instance.' % product.ooName)
+ try:
+ convertor.desktop.terminate()
+- except DisposedException:
++ except UnoDisposedException:
+ info(2, '%s instance unsuccessfully closed, sending TERM signal.' % product.ooName)
+ try:
+ ooproc.terminate()
+@@ -1080,7 +1081,7 @@ def main():
+ for inputfn in op.filenames:
+ convertor.convert(inputfn)
+
+- except NoConnectException, e:
++ except UnoNoConnectException, e:
+ error("unoconv: could not find an existing connection to LibreOffice at %s:%s." % (op.server, op.port))
+ if op.connection:
+ info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"%s\"" % (op.server, op.server, op.port, op.connection))
+@@ -1094,7 +1095,8 @@ def main():
+ error("Warning: failed to launch Office suite. Aborting.")
+
+ ### Main entrance
+-if __name__ == '__main__':
++def run():
++ global exitcode
+ exitcode = 0
+
+ info(3, 'sysname=%s, platform=%s, python=%s, python-version=%s' % (os.name, sys.platform, sys.executable, sys.version))
+@@ -1105,7 +1107,12 @@ if __name__ == '__main__':
+ office_environ(of)
+ # debug_office()
+ try:
+- import uno, unohelper
++ global global_uno
++ global global_unohelper
++
++ import uno as global_uno
++ import unohelper as global_unohelper
++ global office
+ office = of
+ break
+ except:
+@@ -1121,17 +1128,30 @@ if __name__ == '__main__':
+ sys.exit(1)
+
+ ### Now that we have found a working pyuno library, let's import some classes
+- from com.sun.star.beans import PropertyValue
+- from com.sun.star.connection import NoConnectException
+- from com.sun.star.document.UpdateDocMode import QUIET_UPDATE
+- from com.sun.star.lang import DisposedException, IllegalArgumentException
+- from com.sun.star.io import IOException, XOutputStream
+- from com.sun.star.script import CannotConvertException
++ global UnoPropertyValue
++ global UnoNoConnectException
++ global UNO_QUIET_UPDATE
++ global UnoDisposedException
++ global UnoIllegalArgumentException
++ global UnoIOException
++ global UnoXOutputStream
++ global UnoCannotConvertException
++ global UnoException
++ global UnoRuntimeException
++
++ from com.sun.star.beans import PropertyValue as UnoPropertyValue
++ from com.sun.star.connection import NoConnectException as UnoNoConnectException
++ from com.sun.star.document.UpdateDocMode import QUIET_UPDATE as UNO_QUIET_UPDATE
++ from com.sun.star.lang import DisposedException as UnoDisposedException
++ from com.sun.star.lang import IllegalArgumentException as UnoIllegalArgumentException
++ from com.sun.star.io import IOException as UnoIOException
++ from com.sun.star.io import XOutputStream as UnoXOutputStream
++ from com.sun.star.script import CannotConvertException as UnoCannotConvertException
+ from com.sun.star.uno import Exception as UnoException
+- from com.sun.star.uno import RuntimeException
++ from com.sun.star.uno import RuntimeException as UnoRuntimeException
+
+ ### And now that we have those classes, build on them
+- class OutputStream( unohelper.Base, XOutputStream ):
++ class OutputStream( global_unohelper.Base, UnoXOutputStream ):
+ def __init__( self ):
+ self.closed = 0
+
+@@ -1144,15 +1164,22 @@ if __name__ == '__main__':
+ def flush( self ):
+ pass
+
++ global GlobalOutputStream
++ GlobalOutputStream = OutputStream
++
+ def UnoProps(**args):
+ props = []
+ for key in args:
+- prop = PropertyValue()
++ prop = UnoPropertyValue()
+ prop.Name = key
+ prop.Value = args[key]
+ props.append(prop)
+ return tuple(props)
+
++ global GlobalUnoProps
++ GlobalUnoProps = UnoProps
++
++ global op
+ op = Options(sys.argv[1:])
+
+ info(2, "Using office base path: %s" % office.basepath)
+@@ -1163,3 +1190,6 @@ if __name__ == '__main__':
+ except KeyboardInterrupt, e:
+ die(6, 'Exiting on user request')
+ die(exitcode)
++
++if __name__ == '__main__':
++ run()
+--
+1.9.0
+
diff --git a/0001-python3-added-compatibility.3.patch b/0001-python3-added-compatibility.3.patch
new file mode 100644
index 0000000..18216c9
--- /dev/null
+++ b/0001-python3-added-compatibility.3.patch
@@ -0,0 +1,629 @@
+From 21b9a845ac7e8805b41d7dab1a6fbf8076689ae8 Mon Sep 17 00:00:00 2001
+From: rpm-build <rpm-build>
+Date: Sat, 19 Apr 2014 12:06:27 +0200
+Subject: [PATCH] 0001-python3-added-compatibility.3.patch
+
+---
+ unoconv | 248 ++++++++++++++++++++++++++++++++++++----------------------------
+ 1 file changed, 139 insertions(+), 109 deletions(-)
+
+diff --git a/unoconv b/unoconv
+index 30e6706..a13db44 100755
+--- a/unoconv
++++ b/unoconv
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python3
+
+ ### 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
+@@ -77,11 +77,11 @@ def find_offices():
+ else:
+
+ if os.name in ( 'nt', 'os2' ):
+- if 'PROGRAMFILES' in os.environ.keys():
++ if 'PROGRAMFILES' in list(os.environ.keys()):
+ extrapaths += glob.glob(os.environ['PROGRAMFILES']+'\\LibreOffice*') + \
+ glob.glob(os.environ['PROGRAMFILES']+'\\OpenOffice.org*')
+
+- if 'PROGRAMFILES(X86)' in os.environ.keys():
++ if 'PROGRAMFILES(X86)' in list(os.environ.keys()):
+ extrapaths += glob.glob(os.environ['PROGRAMFILES(X86)']+'\\LibreOffice*') + \
+ glob.glob(os.environ['PROGRAMFILES(X86)']+'\\OpenOffice.org*')
+
+@@ -203,7 +203,7 @@ def office_environ(office):
+ ### Set UNO_PATH so that "officehelper.bootstrap()" can find soffice executable:
+ os.environ['UNO_PATH'] = office.unopath
+
+- ### Set URE_BOOTSTRAP so that "uno.getComponentContext()" bootstraps a complete
++ ### Set URE_BOOTSTRAP so that "global_uno.getComponentContext()" bootstraps a complete
+ ### UNO environment
+ if os.name in ( 'nt', 'os2' ):
+ os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamental.ini')
+@@ -233,18 +233,18 @@ def office_environ(office):
+
+ def debug_office():
+ if 'URE_BOOTSTRAP' in os.environ:
+- print >>sys.stderr, 'URE_BOOTSTRAP=%s' % os.environ['URE_BOOTSTRAP']
++ print('URE_BOOTSTRAP=%s' % os.environ['URE_BOOTSTRAP'], file=sys.stderr)
+ if 'UNO_PATH' in os.environ:
+- print >>sys.stderr, 'UNO_PATH=%s' % os.environ['UNO_PATH']
++ print('UNO_PATH=%s' % os.environ['UNO_PATH'], file=sys.stderr)
+ if 'UNO_TYPES' in os.environ:
+- print >>sys.stderr, 'UNO_TYPES=%s' % os.environ['UNO_TYPES']
+- print 'PATH=%s' % os.environ['PATH']
++ print('UNO_TYPES=%s' % os.environ['UNO_TYPES'], file=sys.stderr)
++ print('PATH=%s' % os.environ['PATH'])
+ if 'PYTHONHOME' in os.environ:
+- print >>sys.stderr, 'PYTHONHOME=%s' % os.environ['PYTHONHOME']
++ print('PYTHONHOME=%s' % os.environ['PYTHONHOME'], file=sys.stderr)
+ if 'PYTHONPATH' in os.environ:
+- print >>sys.stderr, 'PYTHONPATH=%s' % os.environ['PYTHONPATH']
++ print('PYTHONPATH=%s' % os.environ['PYTHONPATH'], file=sys.stderr)
+ if 'LD_LIBRARY_PATH' in os.environ:
+- print >>sys.stderr, 'LD_LIBRARY_PATH=%s' % os.environ['LD_LIBRARY_PATH']
++ print('LD_LIBRARY_PATH=%s' % os.environ['LD_LIBRARY_PATH'], file=sys.stderr)
+
+ def python_switch(office):
+ if office.pythonhome:
+@@ -277,6 +277,7 @@ def python_switch(office):
+
+ try:
+ os.execvpe(office.python, [office.python, ] + sys.argv[0:], os.environ)
++ print((office.python, [office.python, ] + sys.argv[0:], osenviron))
+ except OSError:
+ ### Mac OS X versions prior to 10.6 do not support execv in
+ ### a process that contains multiple threads. Instead of
+@@ -335,11 +336,11 @@ class FmtList:
+ return ret
+
+ def display(self, doctype):
+- print >>sys.stderr, "The following list of %s formats are currently available:\n" % doctype
++ print("The following list of %s formats are currently available:\n" % doctype, file=sys.stderr)
+ for fmt in self.list:
+ if fmt.doctype == doctype:
+- print >>sys.stderr, " %-8s - %s" % (fmt.name, fmt)
+- print >>sys.stderr
++ print(" %-8s - %s" % (fmt.name, fmt), file=sys.stderr)
++ print(file=sys.stderr)
+
+ fmts = FmtList()
+
+@@ -530,14 +531,14 @@ class Options:
+ 'outputpath', 'password=', 'pipe=', 'port=', 'server=',
+ 'timeout=', 'show', 'stdout', 'template', 'verbose',
+ 'version'] )
+- except getopt.error, exc:
+- print 'unoconv: %s, try unoconv -h for a list of all the options' % str(exc)
++ except getopt.error as exc:
++ print('unoconv: %s, try unoconv -h for a list of all the options' % str(exc))
+ sys.exit(255)
+
+ for opt, arg in opts:
+ if opt in ['-h', '--help']:
+ self.usage()
+- print
++ print()
+ self.help()
+ sys.exit(1)
+ elif opt in ['-c', '--connection']:
+@@ -553,16 +554,16 @@ class Options:
+ if name in ('FilterOptions'):
+ self.exportfilteroptions = value
+ elif value in ('True', 'true'):
+- self.exportfilter.append( PropertyValue( name, 0, True, 0 ) )
++ self.exportfilter.append( UnoPropertyValue( name, 0, True, 0 ) )
+ elif value in ('False', 'false'):
+- self.exportfilter.append( PropertyValue( name, 0, False, 0 ) )
++ self.exportfilter.append( UnoPropertyValue( name, 0, False, 0 ) )
+ else:
+ try:
+- self.exportfilter.append( PropertyValue( name, 0, int(value), 0 ) )
++ self.exportfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) )
+ except ValueError:
+- self.exportfilter.append( PropertyValue( name, 0, value, 0 ) )
++ self.exportfilter.append( UnoPropertyValue( name, 0, value, 0 ) )
+ else:
+- print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg
++ print('Warning: Option %s cannot be parsed, ignoring.' % arg, file=sys.stderr)
+ elif opt in ['-f', '--format']:
+ self.format = arg
+ elif opt in ['-i', '--import']:
+@@ -572,16 +573,16 @@ class Options:
+ if name in ('FilterOptions'):
+ self.importfilteroptions = value
+ elif value in ('True', 'true'):
+- self.importfilter.append( PropertyValue( name, 0, True, 0 ) )
++ self.importfilter.append( UnoPropertyValue( name, 0, True, 0 ) )
+ elif value in ('False', 'false'):
+- self.importfilter.append( PropertyValue( name, 0, False, 0 ) )
++ self.importfilter.append( UnoPropertyValue( name, 0, False, 0 ) )
+ else:
+ try:
+- self.importfilter.append( PropertyValue( name, 0, int(value), 0 ) )
++ self.importfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) )
+ except ValueError:
+- self.importfilter.append( PropertyValue( name, 0, value, 0 ) )
++ self.importfilter.append( UnoPropertyValue( name, 0, value, 0 ) )
+ else:
+- print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg
++ print('Warning: Option %s cannot be parsed, ignoring.' % arg, file=sys.stderr)
+ elif opt in ['-l', '--listener']:
+ self.listener = True
+ elif opt in ['-n', '--no-launch']:
+@@ -589,7 +590,7 @@ class Options:
+ elif opt in ['-o', '--output']:
+ self.output = arg
+ elif opt in ['--outputpath']:
+- print >>sys.stderr, 'Warning: This option is deprecated by --output.'
++ print('Warning: This option is deprecated by --output.', file=sys.stderr)
+ self.output = arg
+ elif opt in ['--password']:
+ self.password = arg
+@@ -615,13 +616,13 @@ class Options:
+
+ ### Enable verbosity
+ if self.verbose >= 2:
+- print >>sys.stderr, 'Verbosity set to level %d' % self.verbose
++ print('Verbosity set to level %d' % self.verbose, file=sys.stderr)
+
+ self.filenames = args
+
+ if not self.listener and not self.showlist and self.doctype != 'list' and not self.filenames:
+- print >>sys.stderr, 'unoconv: you have to provide a filename as argument'
+- print >>sys.stderr, 'Try `unoconv -h\' for more information.'
++ print('unoconv: you have to provide a filename as argument', file=sys.stderr)
++ print('Try `unoconv -h\' for more information.', file=sys.stderr)
+ sys.exit(255)
+
+ ### Set connection string
+@@ -657,23 +658,23 @@ class Options:
+
+ def version(self):
+ ### Get office product information
+- product = uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product"))
+-
+- print 'unoconv %s' % VERSION
+- print 'Written by Dag Wieers <dag at wieers.com>'
+- print 'Homepage at http://dag.wieers.com/home-made/unoconv/'
+- print
+- print 'platform %s/%s' % (os.name, sys.platform)
+- print 'python %s' % sys.version
+- print product.ooName, product.ooSetupVersion
++ product = global_uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product"))
++
++ print('unoconv %s' % VERSION)
++ print('Written by Dag Wieers <dag at wieers.com>')
++ print('Homepage at http://dag.wieers.com/home-made/unoconv/')
++ print()
++ print('platform %s/%s' % (os.name, sys.platform))
++ print('python %s' % sys.version)
++ print(product.ooName, product.ooSetupVersion)
+ # print
+ # print 'build revision $Rev$'
+
+ def usage(self):
+- print >>sys.stderr, 'usage: unoconv [options] file [file2 ..]'
++ print('usage: unoconv [options] file [file2 ..]', file=sys.stderr)
+
+ def help(self):
+- print >>sys.stderr, '''Convert from and to any format supported by LibreOffice
++ print('''Convert from and to any format supported by LibreOffice
+
+ unoconv options:
+ -c, --connection=string use a custom connection string
+@@ -698,7 +699,7 @@ unoconv options:
+ -t, --template=file import the styles from template (.ott)
+ -T, --timeout=secs timeout after secs if connection to listener fails
+ -v, --verbose be more and more verbose (-vvv for debugging)
+-'''
++''', file=sys.stderr)
+
+ class Convertor:
+ def __init__(self):
+@@ -706,7 +707,7 @@ class Convertor:
+ unocontext = None
+
+ ### Do the LibreOffice component dance
+- self.context = uno.getComponentContext()
++ self.context = global_uno.getComponentContext()
+ self.svcmgr = self.context.ServiceManager
+ resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context)
+
+@@ -714,7 +715,7 @@ class Convertor:
+ info(3, 'Connection type: %s' % op.connection)
+ try:
+ unocontext = resolver.resolve("uno:%s" % op.connection)
+- except NoConnectException, e:
++ except UnoNoConnectException as e:
+ # info(3, "Existing listener not found.\n%s" % e)
+ info(3, "Existing listener not found.")
+
+@@ -724,7 +725,7 @@ class Convertor:
+ ### Start our own OpenOffice instance
+ info(3, "Launching our own listener using %s." % office.binary)
+ try:
+- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product"))
++ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product"))
+ if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'):
+ ooproc = subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection], env=os.environ)
+ else:
+@@ -742,14 +743,14 @@ class Convertor:
+ try:
+ unocontext = resolver.resolve("uno:%s" % op.connection)
+ break
+- except NoConnectException:
++ except UnoNoConnectException:
+ time.sleep(0.5)
+ timeout += 0.5
+ except:
+ raise
+ else:
+ error("Failed to connect to %s (pid=%s) in %d seconds.\n%s" % (office.binary, ooproc.pid, op.timeout, e))
+- except Exception, e:
++ except Exception as e:
+ raise
+ error("Launch of %s failed.\n%s" % (office.binary, e))
+
+@@ -759,7 +760,7 @@ class Convertor:
+ ### And some more LibreOffice magic
+ unosvcmgr = unocontext.ServiceManager
+ self.desktop = unosvcmgr.createInstanceWithContext("com.sun.star.frame.Desktop", unocontext)
+- self.cwd = unohelper.systemPathToFileUrl( os.getcwd() )
++ self.cwd = global_unohelper.systemPathToFileUrl( os.getcwd() )
+
+ ### List all filters
+ # self.filters = unosvcmgr.createInstanceWithContext( "com.sun.star.document.FilterFactory", unocontext)
+@@ -799,9 +800,9 @@ class Convertor:
+ ### No format found, throw error
+ if not outputfmt:
+ if doctype:
+- print >>sys.stderr, 'unoconv: format [%s/%s] is not known to unoconv.' % (op.doctype, op.format)
++ print('unoconv: format [%s/%s] is not known to unoconv.' % (op.doctype, op.format), file=sys.stderr)
+ else:
+- print >>sys.stderr, 'unoconv: format [%s] is not known to unoconv.' % op.format
++ print('unoconv: format [%s] is not known to unoconv.' % op.format, file=sys.stderr)
+ die(1)
+
+ return outputfmt
+@@ -813,10 +814,10 @@ class Convertor:
+ outputfmt = self.getformat(inputfn)
+
+ if op.verbose > 0:
+- print >>sys.stderr, 'Input file:', inputfn
++ print('Input file:', inputfn, file=sys.stderr)
+
+ if not os.path.exists(inputfn):
+- print >>sys.stderr, 'unoconv: file `%s\' does not exist.' % inputfn
++ print('unoconv: file `%s\' does not exist.' % inputfn, file=sys.stderr)
+ exitcode = 1
+
+ try:
+@@ -824,22 +825,22 @@ class Convertor:
+ phase = "import"
+
+ ### Load inputfile
+- inputprops = UnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=QUIET_UPDATE)
++ inputprops = GlobalUnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=UNO_QUIET_UPDATE)
+
+ # if op.password:
+-# info = UnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash")
+-# inputprops += UnoProps(ModifyPasswordInfo=info)
++# info = GlobalUnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash")
++# inputprops += GlobalUnoProps(ModifyPasswordInfo=info)
+
+- ### Cannot use UnoProps for FilterData property
++ ### Cannot use GlobalUnoProps for FilterData property
+ if op.importfilteroptions:
+ # print "Import filter options: %s" % op.importfilteroptions
+- inputprops += UnoProps(FilterOptions=op.importfilteroptions)
++ inputprops += GlobalUnoProps(FilterOptions=op.importfilteroptions)
+
+- ### Cannot use UnoProps for FilterData property
++ ### Cannot use GlobalUnoProps for FilterData property
+ if op.importfilter:
+- inputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), )
++ inputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), )
+
+- inputurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(inputfn))
++ inputurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(inputfn))
+ document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops )
+
+ if not document:
+@@ -850,11 +851,11 @@ class Convertor:
+ if op.template:
+ if os.path.exists(op.template):
+ info(1, "Template file: %s" % op.template)
+- templateprops = UnoProps(OverwriteStyles=True)
+- templateurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(op.template))
++ templateprops = GlobalUnoProps(OverwriteStyles=True)
++ templateurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(op.template))
+ document.StyleFamilies.loadStylesFromURL(templateurl, templateprops)
+ else:
+- print >>sys.stderr, 'unoconv: template file `%s\' does not exist.' % op.template
++ print('unoconv: template file `%s\' does not exist.' % op.template, file=sys.stderr)
+ exitcode = 1
+
+ ### Update document links
+@@ -885,26 +886,26 @@ class Convertor:
+ ### Export phase
+ phase = "export"
+
+- outputprops = UnoProps(FilterName=outputfmt.filter, OutputStream=OutputStream(), Overwrite=True)
++ outputprops = GlobalUnoProps(FilterName=outputfmt.filter, OutputStream=GlobalOutputStream(), Overwrite=True)
+
+ ### Set default filter options
+ if op.exportfilteroptions:
+ # print "Export filter options: %s" % op.exportfilteroptions
+- outputprops += UnoProps(FilterOptions=op.exportfilteroptions)
++ outputprops += GlobalUnoProps(FilterOptions=op.exportfilteroptions)
+ else:
+ if outputfmt.filter == 'Text (encoded)':
+- outputprops += UnoProps(FilterOptions="76,LF")
++ outputprops += GlobalUnoProps(FilterOptions="76,LF")
+
+ elif outputfmt.filter == 'Text':
+- outputprops += UnoProps(FilterOptions="76")
++ outputprops += GlobalUnoProps(FilterOptions="76")
+
+ elif outputfmt.filter == 'Text - txt - csv (StarCalc)':
+- outputprops += UnoProps(FilterOptions="44,34,76")
++ outputprops += GlobalUnoProps(FilterOptions="44,34,76")
+
+
+- ### Cannot use UnoProps for FilterData property
++ ### Cannot use GlobalUnoProps for FilterData property
+ if op.exportfilter:
+- outputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), )
++ outputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), )
+
+ if not op.stdout:
+ (outputfn, ext) = os.path.splitext(inputfn)
+@@ -917,47 +918,47 @@ class Convertor:
+ else:
+ outputfn = op.output
+
+- outputurl = unohelper.absolutize( self.cwd, unohelper.systemPathToFileUrl(outputfn) )
++ outputurl = global_unohelper.absolutize( self.cwd, global_unohelper.systemPathToFileUrl(outputfn) )
+ info(1, "Output file: %s" % outputfn)
+ else:
+ outputurl = "private:stream"
+
+ try:
+ document.storeToURL(outputurl, tuple(outputprops) )
+- except IOException, e:
++ except UnoIOException as e:
+ raise UnoException("Unable to store document to %s (ErrCode %d)\n\nProperties: %s" % (outputurl, e.ErrCode, outputprops), None)
+
+ phase = "dispose"
+ document.dispose()
+ document.close(True)
+
+- except SystemError, e:
++ except SystemError as e:
+ error("unoconv: SystemError during %s phase:\n%s" % (phase, e))
+ exitcode = 1
+
+- except RuntimeException, e:
++ except UnoRuntimeException as e:
+ error("unoconv: RuntimeException during %s phase:\nOffice probably died. %s" % (phase, e))
+ exitcode = 6
+
+- except DisposedException, e:
++ except UnoDisposedException as e:
+ error("unoconv: DisposedException during %s phase:\nOffice probably died. %s" % (phase, e))
+ exitcode = 7
+
+- except IllegalArgumentException, e:
++ except UnoIllegalArgumentException as e:
+ error("UNO IllegalArgument during %s phase:\nSource file cannot be read. %s" % (phase, e))
+ exitcode = 8
+
+- except IOException, e:
++ except UnoIOException as e:
+ # for attr in dir(e): print '%s: %s', (attr, getattr(e, attr))
+ error("unoconv: IOException during %s phase:\n%s" % (phase, e.Message))
+ exitcode = 3
+
+- except CannotConvertException, e:
++ except UnoCannotConvertException as e:
+ # for attr in dir(e): print '%s: %s', (attr, getattr(e, attr))
+ error("unoconv: CannotConvertException during %s phase:\n%s" % (phase, e.Message))
+ exitcode = 4
+
+- except UnoException, e:
++ except UnoException as e:
+ if hasattr(e, 'ErrCode'):
+ error("unoconv: UnoException during %s phase in %s (ErrCode %d)" % (phase, repr(e.__class__), e.ErrCode))
+ exitcode = e.ErrCode
+@@ -975,14 +976,14 @@ class Listener:
+ global product
+
+ info(1, "Start listener on %s:%s" % (op.server, op.port))
+- self.context = uno.getComponentContext()
++ self.context = global_uno.getComponentContext()
+ self.svcmgr = self.context.ServiceManager
+ try:
+ resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context)
+- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product"))
++ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product"))
+ try:
+ unocontext = resolver.resolve("uno:%s" % op.connection)
+- except NoConnectException, e:
++ except UnoNoConnectException as e:
+ pass
+ else:
+ info(1, "Existing %s listener found, nothing to do." % product.ooName)
+@@ -991,25 +992,25 @@ class Listener:
+ subprocess.call([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection], env=os.environ)
+ else:
+ subprocess.call([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nologo", "--nofirststartwizard", "--norestore", "--accept=%s" % op.connection], env=os.environ)
+- except Exception, e:
++ except Exception as e:
+ error("Launch of %s failed.\n%s" % (office.binary, e))
+ else:
+ info(1, "Existing %s listener found, nothing to do." % product.ooName)
+
+ def error(msg):
+ "Output error message"
+- print >>sys.stderr, msg
++ print(msg, file=sys.stderr)
+
+ def info(level, msg):
+ "Output info message"
+ if 'op' not in globals():
+ pass
+ elif op.verbose >= 3 and level >= 3:
+- print >>sys.stderr, "DEBUG:", msg
++ print("DEBUG:", msg, file=sys.stderr)
+ elif not op.stdout and level <= op.verbose:
+- print >>sys.stdout, msg
++ print(msg, file=sys.stdout)
+ elif level <= op.verbose:
+- print >>sys.stderr, msg
++ print(msg, file=sys.stderr)
+
+ def die(ret, msg=None):
+ "Print optional error and exit with errorcode"
+@@ -1031,7 +1032,7 @@ def die(ret, msg=None):
+ subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--unaccept=%s" % op.connection], env=os.environ)
+ ooproc.wait()
+ info(2, '%s listener successfully disabled.' % product.ooName)
+- except Exception, e:
++ except Exception as e:
+ error("Terminate using %s failed.\n%s" % (office.binary, e))
+
+ ### If there is no GUI attached to the instance, terminate instance
+@@ -1039,7 +1040,7 @@ def die(ret, msg=None):
+ info(3, 'Terminating %s instance.' % product.ooName)
+ try:
+ convertor.desktop.terminate()
+- except DisposedException:
++ except UnoDisposedException:
+ info(2, '%s instance unsuccessfully closed, sending TERM signal.' % product.ooName)
+ try:
+ ooproc.terminate()
+@@ -1080,7 +1081,7 @@ def main():
+ for inputfn in op.filenames:
+ convertor.convert(inputfn)
+
+- except NoConnectException, e:
++ except UnoNoConnectException as e:
+ error("unoconv: could not find an existing connection to LibreOffice at %s:%s." % (op.server, op.port))
+ if op.connection:
+ info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"%s\"" % (op.server, op.server, op.port, op.connection))
+@@ -1094,7 +1095,8 @@ def main():
+ error("Warning: failed to launch Office suite. Aborting.")
+
+ ### Main entrance
+-if __name__ == '__main__':
++def run():
++ global exitcode
+ exitcode = 0
+
+ info(3, 'sysname=%s, platform=%s, python=%s, python-version=%s' % (os.name, sys.platform, sys.executable, sys.version))
+@@ -1105,33 +1107,51 @@ if __name__ == '__main__':
+ office_environ(of)
+ # debug_office()
+ try:
+- import uno, unohelper
++ global global_uno
++ global global_unohelper
++
++ import uno as global_uno
++ import unohelper as global_unohelper
++ global office
+ office = of
+ break
+ except:
+ # debug_office()
+- print >>sys.stderr, "unoconv: Cannot find a suitable pyuno library and python binary combination in %s" % of
+- print >>sys.stderr, "ERROR:", sys.exc_info()[1]
+- print >>sys.stderr
++ print("unoconv: Cannot find a suitable pyuno library and python binary combination in %s" % of, file=sys.stderr)
++ print("ERROR:", sys.exc_info()[1], file=sys.stderr)
++ print(file=sys.stderr)
+ else:
+ # debug_office()
+- print >>sys.stderr, "unoconv: Cannot find a suitable office installation on your system."
+- print >>sys.stderr, "ERROR: Please locate your office installation and send your feedback to:"
+- print >>sys.stderr, " http://github.com/dagwieers/unoconv/issues"
++ print("unoconv: Cannot find a suitable office installation on your system.", file=sys.stderr)
++ print("ERROR: Please locate your office installation and send your feedback to:", file=sys.stderr)
++ print(" http://github.com/dagwieers/unoconv/issues", file=sys.stderr)
+ sys.exit(1)
+
+ ### Now that we have found a working pyuno library, let's import some classes
+- from com.sun.star.beans import PropertyValue
+- from com.sun.star.connection import NoConnectException
+- from com.sun.star.document.UpdateDocMode import QUIET_UPDATE
+- from com.sun.star.lang import DisposedException, IllegalArgumentException
+- from com.sun.star.io import IOException, XOutputStream
+- from com.sun.star.script import CannotConvertException
++ global UnoPropertyValue
++ global UnoNoConnectException
++ global UNO_QUIET_UPDATE
++ global UnoDisposedException
++ global UnoIllegalArgumentException
++ global UnoIOException
++ global UnoXOutputStream
++ global UnoCannotConvertException
++ global UnoException
++ global UnoRuntimeException
++
++ from com.sun.star.beans import PropertyValue as UnoPropertyValue
++ from com.sun.star.connection import NoConnectException as UnoNoConnectException
++ from com.sun.star.document.UpdateDocMode import QUIET_UPDATE as UNO_QUIET_UPDATE
++ from com.sun.star.lang import DisposedException as UnoDisposedException
++ from com.sun.star.lang import IllegalArgumentException as UnoIllegalArgumentException
++ from com.sun.star.io import IOException as UnoIOException
++ from com.sun.star.io import XOutputStream as UnoXOutputStream
++ from com.sun.star.script import CannotConvertException as UnoCannotConvertException
+ from com.sun.star.uno import Exception as UnoException
+- from com.sun.star.uno import RuntimeException
++ from com.sun.star.uno import RuntimeException as UnoRuntimeException
+
+ ### And now that we have those classes, build on them
+- class OutputStream( unohelper.Base, XOutputStream ):
++ class OutputStream( global_unohelper.Base, UnoXOutputStream ):
+ def __init__( self ):
+ self.closed = 0
+
+@@ -1144,15 +1164,22 @@ if __name__ == '__main__':
+ def flush( self ):
+ pass
+
++ global GlobalOutputStream
++ GlobalOutputStream = OutputStream
++
+ def UnoProps(**args):
+ props = []
+ for key in args:
+- prop = PropertyValue()
++ prop = UnoPropertyValue()
+ prop.Name = key
+ prop.Value = args[key]
+ props.append(prop)
+ return tuple(props)
+
++ global GlobalUnoProps
++ GlobalUnoProps = UnoProps
++
++ global op
+ op = Options(sys.argv[1:])
+
+ info(2, "Using office base path: %s" % office.basepath)
+@@ -1160,6 +1187,9 @@ if __name__ == '__main__':
+
+ try:
+ main()
+- except KeyboardInterrupt, e:
++ except KeyboardInterrupt as e:
+ die(6, 'Exiting on user request')
+ die(exitcode)
++
++if __name__ == '__main__':
++ run()
+--
+1.9.0
+
diff --git a/0001-update-FSF-address.patch b/0001-update-FSF-address.patch
index da5f208..925cf4f 100644
--- a/0001-update-FSF-address.patch
+++ b/0001-update-FSF-address.patch
@@ -139,34 +139,6 @@ index 30e6706..e4a1ac8 100755
-### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+### Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+### MA 02110-1301 USA.
-
- import sys
-
-diff --git a/unoconv2.py b/unoconv2.py
-index 30e6706..e4a1ac8 100755
---- a/unoconv2.py
-+++ b/unoconv2.py
-@@ -11,7 +11,8 @@
- ###
- ### 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.
-+### Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-+### MA 02110-1301 USA.
- ### Copyright 2007-2010 Dag Wieers <dag at wieers.com>
-
- from distutils.version import LooseVersion
-diff --git a/unoconv3.py b/unoconv3.py
-index 30e6706..e4a1ac8 100755
---- a/unoconv3.py
-+++ b/unoconv3.py
-@@ -11,7 +11,8 @@
- ###
- ### 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.
-+### Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-+### MA 02110-1301 USA.
### Copyright 2007-2010 Dag Wieers <dag at wieers.com>
from distutils.version import LooseVersion
diff --git a/unoconv.spec b/unoconv.spec
index 5fe9657..bb314cf 100644
--- a/unoconv.spec
+++ b/unoconv.spec
@@ -7,7 +7,11 @@ Group: System Environment/Base
URL: http://dag.wieers.com/home-made/unoconv/
Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz
Patch0: 0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch
-Patch1: 0001-python3-added-compatibility.patch
+%if 0%{?rhel}
+Patch1: 0001-python3-added-compatibility.2.patch
+%else
+Patch1: 0001-python3-added-compatibility.3.patch
+%endif
Patch2: 0001-update-FSF-address.patch
Patch3: 0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch
@@ -32,16 +36,6 @@ RTF, Docbook (.xml), and more.
%install
make install DESTDIR="%{buildroot}"
-pushd %{buildroot}/%{_bindir}
-%if 0%{?fedora} >= 19
- mv %{name}3.py %{name}
- rm %{name}2.py
-%else
- mv %{name}2.py %{name}
- rm %{name}3.py
-%endif
-popd
-
%files
%doc AUTHORS ChangeLog COPYING README.asciidoc WISHLIST doc/*.txt tests/
More information about the scm-commits
mailing list