From 7dd2537c94a992f456da85236fe70be2d93e2a60 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Jul 10 2015 11:57:51 +0000 Subject: new upstream release 0.7 --- diff --git a/.gitignore b/.gitignore index fad94ff..a1bdbc0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ unoconv-0.3.tar.bz2 /unoconv-0.4.tar.bz2 /unoconv-0.5.tar.bz2 /unoconv-0.6.tar.gz +/unoconv-0.7.tar.gz diff --git a/0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch b/0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch deleted file mode 100644 index 264a279..0000000 --- a/0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 3c20d6ec49a97c24cfb1fe9fd61ac80944819088 Mon Sep 17 00:00:00 2001 -From: Dag Wieers -Date: Fri, 28 Sep 2012 19:33:01 +0200 -Subject: [PATCH] Fix a broken --export option and add -V as alternative to - --version - -This closes #93. ---- - unoconv | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/unoconv b/unoconv -index 972e962..30e6706 100755 ---- a/unoconv -+++ b/unoconv -@@ -524,8 +524,8 @@ class Options: - - ### Get options from the commandline - try: -- opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:T:t:v', -- ['connection=', 'debug', 'doctype=', 'export', 'format=', -+ opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:T:t:vV', -+ ['connection=', 'debug', 'doctype=', 'export=', 'format=', - 'help', 'import', 'listener', 'no-launch', 'output=', - 'outputpath', 'password=', 'pipe=', 'port=', 'server=', - 'timeout=', 'show', 'stdout', 'template', 'verbose', -@@ -609,7 +609,7 @@ class Options: - self.timeout = int(arg) - elif opt in ['-v', '--verbose']: - self.verbose = self.verbose + 1 -- elif opt in ['--version']: -+ elif opt in ['-V', '--version']: - self.version() - sys.exit(255) - --- -1.7.11.7 - 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 deleted file mode 100644 index e96aa8c..0000000 --- a/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 3249fd3df136f1a859ac0272f75fcbf010926d58 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= -Date: Thu, 7 Nov 2013 13:33:37 +0000 -Subject: [PATCH] Resolves: fdo#70309 can't write bytes direct to stdout in - python3 - ---- - unoconv | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/unoconv b/unoconv -index a4f9490..2b0b0eb 100755 ---- a/unoconv -+++ b/unoconv -@@ -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 --- -1.8.5.3 - diff --git a/0001-Updated-ChangeLog.patch b/0001-Updated-ChangeLog.patch new file mode 100644 index 0000000..66c477b --- /dev/null +++ b/0001-Updated-ChangeLog.patch @@ -0,0 +1,40 @@ +From b02c77cc669715858a2e6a658cb1988e5e89cf3b Mon Sep 17 00:00:00 2001 +From: Dag Wieers +Date: Thu, 9 Jul 2015 01:47:52 +0200 +Subject: [PATCH] Updated ChangeLog + +--- + ChangeLog | 19 ++++++++++++++++++- + 1 file changed, 18 insertions(+), 1 deletion(-) + +diff --git a/ChangeLog b/ChangeLog +index 0c21fb4..7ca8755 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,5 +1,22 @@ + * 0.7 - released 2015-07-09 +-- ++- Ported to Python 3 (Riccardo Magliocchetti) ++- Update Indexes (eg. TOC) during conversion (Peter Demin) ++- Added XLSX support (Josias Montag) ++- Fix output to non-existing directory ++- Ensure that LibreOfficeDev release are using new long options (Chia-liang Kao) ++- Set output format based on output filename extension (Patrick McAndrew) ++- Accept 'office' as binary on MacOSX (Andreas Jung) ++- Added Microsoft WPS import filter (Josias Montag) ++- Fix --stdout output on Python 3 (Caolán McNamara) ++- Added -F/--field option to update user fields during conversion (Raphaël Pinson) ++- Added OpenOffice search path on MacOSX (Vittal Aithal) ++- Cycle through all images references before conversion ++- Added --preserve option to preserve timestamp and permissions (Vincent Bernat) ++- Added --stdin option to read from standard input ++- Accept remote URLs as input filename ++- Fix exit code 81 and recover from initial failure (Daniel Vandersluis) ++- Improve documentation related to error codes and using unoconv with Nginx/Apache/PHP ++ + + * 0.6 - released 2012-09-10 + - Implement debugging output (-vvv) +-- +2.1.0 + diff --git a/0001-libreoffice-or-OO.o-has-never-had-wps-export.patch b/0001-libreoffice-or-OO.o-has-never-had-wps-export.patch new file mode 100644 index 0000000..70c24f4 --- /dev/null +++ b/0001-libreoffice-or-OO.o-has-never-had-wps-export.patch @@ -0,0 +1,24 @@ +From aa46d3cbcec14ae46a176165852089558c524ff2 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Fri, 10 Jul 2015 12:55:13 +0200 +Subject: [PATCH] libreoffice (or OO.o) has never had wps export + +--- + unoconv | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/unoconv b/unoconv +index 2e56d3c..1158374 100755 +--- a/unoconv ++++ b/unoconv +@@ -377,7 +377,6 @@ fmts.add('document', 'uot', 'uot', 'Unified Office Format text','UOF text') ### + fmts.add('document', 'vor', 'vor', 'StarWriter 5.0 Template', 'StarWriter 5.0 Vorlage/Template') ### 6 + fmts.add('document', 'vor4', 'vor', 'StarWriter 4.0 Template', 'StarWriter 4.0 Vorlage/Template') ### 5 + fmts.add('document', 'vor3', 'vor', 'StarWriter 3.0 Template', 'StarWriter 3.0 Vorlage/Template') ### 4 +-fmts.add('document', 'wps', 'wps', 'Microsoft Works', 'MS_Works') + fmts.add('document', 'xhtml', 'html', 'XHTML Document', 'XHTML Writer File') ### 33 + + ### WebDocument +-- +2.1.0 + diff --git a/0001-python3-added-compatibility.2.patch b/0001-python3-added-compatibility.2.patch deleted file mode 100644 index d5416c7..0000000 --- a/0001-python3-added-compatibility.2.patch +++ /dev/null @@ -1,384 +0,0 @@ -From 34bbe9fa679d39921fd67002e01e7a9bf93b009a Mon Sep 17 00:00:00 2001 -From: 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 ' -@@ -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 deleted file mode 100644 index 18216c9..0000000 --- a/0001-python3-added-compatibility.3.patch +++ /dev/null @@ -1,629 +0,0 @@ -From 21b9a845ac7e8805b41d7dab1a6fbf8076689ae8 Mon Sep 17 00:00:00 2001 -From: 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 ' -- 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 ') -+ 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-python3-added-compatibility.patch b/0001-python3-added-compatibility.patch new file mode 100644 index 0000000..84ed36b --- /dev/null +++ b/0001-python3-added-compatibility.patch @@ -0,0 +1,22 @@ +From 21b9a845ac7e8805b41d7dab1a6fbf8076689ae8 Mon Sep 17 00:00:00 2001 +From: 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 +-- +1.9.0 + diff --git a/sources b/sources index 23edf65..1971310 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -eeda0d358ce4bacd5dd84303012c416d unoconv-0.6.tar.gz +eff96b17a62876abfef09c16d0516d09 unoconv-0.7.tar.gz diff --git a/unoconv.spec b/unoconv.spec index f87068b..d5bcaa6 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,21 +1,18 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv -Version: 0.6 -Release: 12%{?dist} +Version: 0.7 +Release: 1%{?dist} License: GPLv2 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 -%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 -Patch4: 0001-make-LaTeX-export-usable-with-writer2latex-ext.patch -Patch5: 0002-remove-export-formats-dropped-by-LibreOffice.patch + +Patch0: 0001-python3-added-compatibility.patch +Patch1: 0001-update-FSF-address.patch +Patch2: 0001-make-LaTeX-export-usable-with-writer2latex-ext.patch +Patch3: 0001-libreoffice-or-OO.o-has-never-had-wps-export.patch +Patch4: 0002-remove-export-formats-dropped-by-LibreOffice.patch +Patch5: 0001-Updated-ChangeLog.patch BuildArch: noarch Requires: libreoffice-filters @@ -41,11 +38,14 @@ RTF, Docbook (.xml), and more. make install DESTDIR="%{buildroot}" %files -%doc AUTHORS ChangeLog COPYING README.asciidoc WISHLIST doc/*.txt tests/ +%doc AUTHORS ChangeLog COPYING README.adoc doc/*.adoc %{_mandir}/man1/%{name}.1* %{_bindir}/%{name} %changelog +* Fri Jul 10 2015 David Tardon - 0.7-1 +- new upstream release + * Fri Jun 19 2015 Fedora Release Engineering - 0.6-12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild