# HG changeset patch # User Magnus Schieder # Date 1529413676 -7200 # Node ID 349d49bb69f4dad20cd7b339979efde51b250f13 # Parent b2f96072b8d75c7b8ac1417912572b15ef1eb633 Porting on python3 diff -r b2f96072b8d7 -r 349d49bb69f4 castclient.py --- 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) diff -r b2f96072b8d7 -r 349d49bb69f4 checkclient.py --- 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) diff -r b2f96072b8d7 -r 349d49bb69f4 mergeclient.py --- 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__": diff -r b2f96072b8d7 -r 349d49bb69f4 odfcast/convert.py --- 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'\n' - u'%(code)s %(name)s\n' - u'

%(name)s

\n' - u'%(details)s\n' + '\n' + '%(code)s %(name)s\n' + '

%(name)s

\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)