X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=qchess%2Fqchess.cgi;h=035dce094e05fba13aeb1733fabd6ae059de7735;hb=068745c990538769b9c4fd48f467a0f938e4c0d6;hp=752fabf61432bea877e665493456d0ba82bcdc87;hpb=52068b63d49f02f4455a4415356ecfe38db72f59;p=progcomp2013.git diff --git a/qchess/qchess.cgi b/qchess/qchess.cgi index 752fabf..035dce0 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." @@ -149,13 +157,17 @@ def main(argv): elif request == "start": print "New game." args = path+"qchess.py --no-graphics" - if mode == None or mode == "bishop": + if mode == "black": + args += " @internal:AgentBishop @fifo:../qchess-cgi-data/"+client + elif mode == None or mode == "bishop": args += " @fifo:../qchess-cgi-data/"+client+" @internal:AgentBishop" - if mode == "random": + elif mode == "random": args += " @fifo:../qchess-cgi-data/"+client+" @internal:AgentRandom" elif mode == "eigengame": args += " --server=progcomp.ucc.asn.au @fifo:../qchess-cgi-data/"+client + args += " --log=@../qchess-cgi-data/"+client+".log"; + os.system("echo '"+args+"' | at now") # subprocess.Popen(args)