diff --git a/call.cgi b/call.cgi index 2f7af7f..61e9ae4 100755 --- a/call.cgi +++ b/call.cgi @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # encoding: utf-8 import os import sys @@ -8,7 +8,6 @@ import sqlite3 from datetime import datetime from datetime import timedelta -import pprint if sys.argv[-1] == "--test": logdir="./" @@ -71,7 +70,7 @@ c = conn.cursor() query= "SELECT number, name_kanji, name_kana, depart_name, pos_code FROM user WHERE id = ?" -for machine in db.keys(): +for machine in list(db.keys()): candidate = [] active = False reject = False @@ -147,8 +146,8 @@ conn.close() if not "excel" in form: - print "Content-Type: application/json" - print "" + print("Content-Type: application/json") + print("") json.dump(lines, sys.stdout) else: @@ -162,9 +161,9 @@ lines.sort(lambda x,y: cmp(x[4]+x[1],y[4]+y[1])) for room in ["GRL", "ML1", "ML2", "IML"]: - wb.remove(wb[room+u"出席表"]) + wb.remove(wb[room+"出席表"]) if room in form: - ws = wb.create_sheet(title = room+u"出席表") + ws = wb.create_sheet(title = room+"出席表") ws.sheet_properties.pageSetUpPr.fitToPage = True if room == "IML": prefix = "HSJ" @@ -243,16 +242,16 @@ tab.tableStyleInfo = style ws.add_table(tab) else: - wb.remove(wb[room+u"座席表"]) + wb.remove(wb[room+"座席表"]) filename="attendancebook"+fr.strftime("%Y%m%d%H%M")+".xlsx" tname= tempfile.mktemp(filename) wb.save(tname) with open(tname,"rb") as f: finfo = os.stat(tname) - print "Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" - print 'Content-Disposition: attachment; filename="'+filename+'"' - print 'Content-Length: '+str(finfo.st_size) - print "" + print("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") + print('Content-Disposition: attachment; filename="'+filename+'"') + print('Content-Length: '+str(finfo.st_size)) + print("") sys.stdout.write(f.read())