X-Git-Url: https://git.ucc.asn.au/?p=progcomp2013.git;a=blobdiff_plain;f=qchess%2Fqchess.cgi;h=4b8e34c779d30b648100cdb9cfd6c075aa96dcde;hp=752fabf61432bea877e665493456d0ba82bcdc87;hb=87681496dec0b1bdadaf0733137010615997fb05;hpb=ef3a2d186de4f86b736dc357948a3ca319ef5423 diff --git a/qchess/qchess.cgi b/qchess/qchess.cgi index 752fabf..4b8e34c 100755 --- a/qchess/qchess.cgi +++ b/qchess/qchess.cgi @@ -71,6 +71,10 @@ def open_fifo(name, mode, timeout=None): raise w.exception return w.result +def force_quit(): + os.remove(path+client+".in") + os.remove(path+client+".out") + def quit(): if os.path.exists(path+client+".in") and os.path.exists(path+client+".out"): @@ -105,7 +109,7 @@ def quit(): def main(argv): - print "Content-Type: text/plain\r\n\r\n" + print "Content-Type: text/plain\r\n" #Removed the second new line. Makes parsing everything easier ~BG3 global client form = cgi.FieldStorage() @@ -137,7 +141,11 @@ def main(argv): x = int(form["x"].value) y = int(form["y"].value) except: - + if request == "force_quit": + force_quit() + quit() + return 0 + if os.path.exists(path+client+".in") and os.path.exists(path+client+".out"): if request == "quit": print "Quit." @@ -150,7 +158,7 @@ def main(argv): print "New game." args = path+"qchess.py --no-graphics" if mode == None or mode == "bishop": - args += " @fifo:../qchess-cgi-data/"+client+" @internal:AgentBishop" + args += " @fifo:../qchess-cgi-data/"+client+" @internal:AgentBishop --log=../qchess-cgi-data/"+client+".log" if mode == "random": args += " @fifo:../qchess-cgi-data/"+client+" @internal:AgentRandom" elif mode == "eigengame":