changeset 99:349d49bb69f4

Porting on python3
author Magnus Schieder <mschieder@intevation.de>
date Tue, 19 Jun 2018 15:07:56 +0200
parents b2f96072b8d7
children bf1a998fff48
files castclient.py checkclient.py mergeclient.py odfcast/convert.py
diffstat 4 files changed, 23 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/castclient.py	Thu Jun 07 14:33:44 2018 +0200
+++ b/castclient.py	Tue Jun 19 15:07:56 2018 +0200
@@ -37,11 +37,11 @@
     if r.status_code == 200:
         with open(outfilename, "wb") as f:
             f.write(r.content)
-        print "OK"
+        print("OK")
     else:
-        print "An error has occured"
-        print r.status_code, r.headers
-        print r.text
+        print("An error has occured")
+        print((r.status_code, r.headers))
+        print((r.text))
         sys.exit(2)
 
 
--- a/checkclient.py	Thu Jun 07 14:33:44 2018 +0200
+++ b/checkclient.py	Tue Jun 19 15:07:56 2018 +0200
@@ -26,11 +26,11 @@
     r = requests.post(url, files=files)
 
     if r.status_code == 200:
-        print "OK"
+        print("OK")
     else:
-        print "An error has occured"
-        print r.status_code, r.headers
-        print r.text
+        print("An error has occured")
+        print((r.status_code, r.headers))
+        print((r.text))
         sys.exit(2)
 
 
--- a/mergeclient.py	Thu Jun 07 14:33:44 2018 +0200
+++ b/mergeclient.py	Tue Jun 19 15:07:56 2018 +0200
@@ -43,11 +43,11 @@
     if r.status_code == 200:
         with open(options.out, "wb") as f:
             f.write(r.content)
-        print "OK"
+        print("OK")
     else:
-        print "An error has occured"
-        print r.status_code, r.headers
-        print r.text
+        print("An error has occured")
+        print((r.status_code, r.headers))
+        print((r.text))
         sys.exit(2)
 
 if __name__ == "__main__":
--- a/odfcast/convert.py	Thu Jun 07 14:33:44 2018 +0200
+++ b/odfcast/convert.py	Tue Jun 19 15:07:56 2018 +0200
@@ -51,10 +51,10 @@
 
     def html(self, title, error_code, details):
         data = (
-            u'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n'
-            u'<title>%(code)s %(name)s</title>\n'
-            u'<h1>%(name)s</h1>\n'
-            u'%(details)s\n'
+            '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n'
+            '<title>%(code)s %(name)s</title>\n'
+            '<h1>%(name)s</h1>\n'
+            '%(details)s\n'
         ) % {
             "code": error_code,
             "name": escape(title),
@@ -154,14 +154,14 @@
                 outfile.close()
                 outfile = tfile
                 outfile.seek(0)
-            except Exception, e:
+            except Exception as e:
                 log.exception("Template error")
                 return TemplateErrorResponse(details=str(e))
 
         if fformat != "odt":
             try:
                 outfile = self.convert(outfile, fformat)
-            except Exception, e:
+            except Exception as e:
                 log.exception("Conversion error")
                 return ConversionErrorResponse(details=str(e))
 
@@ -210,14 +210,14 @@
 
         # allow files to have arbitray form names
         # order files by their form names
-        for key, value in sorted(request.files.iterlists(),
+        for key, value in sorted(request.files.lists(),
                                  key=lambda x: x[0].lower()):
             ffiles.extend(value)
 
         for ffile in ffiles:
             try:
                 merger.append(ffile, import_bookmarks=False)
-            except Exception, e:
+            except Exception as e:
                 log.exception("Error merging file %s" % ffile)
                 if self.is_ignore_file_errors():
                     continue
@@ -230,7 +230,7 @@
             merger.write(outfile)
             merger.close()
             outfile.seek(0)
-        except PyPdfError, e:
+        except PyPdfError as e:
             log.exception("Merge error")
             return MergeErrorResponse(details=str(e))
 
@@ -268,13 +268,13 @@
             merger = PdfFileMerger(strict=False)
             try:
                 merger.append(ffile, import_bookmarks=False)
-            except Exception, e:
+            except Exception as e:
                 log.exception("Error testing merger.append of %s" % ffile)
                 return MergeErrorResponse(details=str(e), http_error_code=422)
 
             try:
                 merger.write(outfile)
-            except Exception, e:
+            except Exception as e:
                 log.exception("Error testing merger.write of merged %s" % ffile)
                 return MergeErrorResponse(details=str(e), http_error_code=422)
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)