diff --git a/ods2xls.py b/ods2xls.py index 3533509..e8042b4 100755 --- a/ods2xls.py +++ b/ods2xls.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # ods2xls.py # adapted from ssconv.py # see also @@ -6,7 +6,7 @@ # http://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options # http://linuxsleuthing.blogspot.com/2012/01/unoconv-is-number-one.html # -# Copyright © 2013, Tom Marble. +# Copyright (C) 2013, Tom Marble. # # This software's license gives you freedom; you can copy, convey, # propogate, redistribute and/or modify this program under the terms of @@ -86,13 +86,13 @@ if __name__ == "__main__": ooutils.oo_shutdown_if_running() else: if len(argv) < 2: - print "USAGE:" - print " python %s INPUT-FILE [INPUT-FILE ...]" % argv[0] - print "OR" - print " python %s --shutdown" % argv[0] + print("USAGE:") + print(" python %s INPUT-FILE [INPUT-FILE ...]" % argv[0]) + print("OR") + print(" python %s --shutdown" % argv[0]) exit(255) if not isfile(argv[1]): - print "File not found: %s" % argv[1] + print("File not found: %s" % argv[1]) exit(1) try: @@ -101,10 +101,10 @@ if __name__ == "__main__": while i < len(argv): odsname = argv[i] xlsname = odsname.replace('.ods', '.xls') - print '%s => %s' % (odsname, xlsname) + print('%s => %s' % (odsname, xlsname)) converter.convert(odsname, xlsname) i += 1 - except ErrorCodeIOException, exception: - print "ERROR! ErrorCodeIOException %d" % exception.ErrCode + except ErrorCodeIOException as exception: + print("ERROR! ErrorCodeIOException %d" % exception.ErrCode) exit(1) diff --git a/ooutils.py b/ooutils.py index fac7afa..8b767b6 100644 --- a/ooutils.py +++ b/ooutils.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # ooutils.py # from http://www.linuxjournal.com/node/1007788 @@ -83,12 +83,12 @@ class OORunner: n += 1 if not context: - raise Exception, "Failed to connect to OpenOffice on port %d" % self.port + raise Exception("Failed to connect to OpenOffice on port %d" % self.port) desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context) if not desktop: - raise Exception, "Failed to create OpenOffice desktop on port %d" % self.port + raise Exception("Failed to create OpenOffice desktop on port %d" % self.port) if did_start: _started_desktops[self.port] = desktop @@ -113,11 +113,11 @@ class OORunner: try: pid = os.spawnve(os.P_NOWAIT, args[0], args, env) - except Exception, e: - raise Exception, "Failed to start OpenOffice on port %d: %s" % (self.port, e.message) + except Exception as e: + raise Exception("Failed to start OpenOffice on port %d: %s" % (self.port, e.message)) if pid <= 0: - raise Exception, "Failed to start OpenOffice on port %d" % self.port + raise Exception("Failed to start OpenOffice on port %d" % self.port) def shutdown(self): @@ -128,7 +128,7 @@ class OORunner: if _started_desktops.get(self.port): _started_desktops[self.port].terminate() del _started_desktops[self.port] - except Exception, e: + except Exception as e: pass @@ -142,7 +142,7 @@ def _shutdown_desktops(): try: if desktop: desktop.terminate() - except Exception, e: + except Exception as e: pass @@ -155,7 +155,7 @@ def oo_shutdown_if_running(port=OPENOFFICE_PORT): try: desktop = oorunner.connect(no_startup=True) desktop.terminate() - except Exception, e: + except Exception as e: pass