git.ucc.asn.au
/
progcomp2013.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
e9e685c
)
Got cgi script to work
author
judge
<
[email protected]
>
Sun, 19 May 2013 06:40:16 +0000
(14:40 +0800)
committer
judge
<
[email protected]
>
Sun, 19 May 2013 06:40:16 +0000
(14:40 +0800)
qchess/qchess.cgi
patch
|
blob
|
history
diff --git
a/qchess/qchess.cgi
b/qchess/qchess.cgi
index
993a36e
..
752fabf
100755
(executable)
--- a/
qchess/qchess.cgi
+++ b/
qchess/qchess.cgi
@@
-1,4
+1,4
@@
-#!/usr/bin/python
+#!/usr/bin/python
-u
# CGI wrapper to qchess
# CGI wrapper to qchess
@@
-6,10
+6,10
@@
import sys
import os
import cgi
import os
import cgi
-import subprocess
import time
import threading
import datetime
import time
import threading
import datetime
+import subprocess
path = "../qchess-cgi-data/"
path = "../qchess-cgi-data/"
@@
-119,22
+119,23
@@
def main(argv):
try:
#request = argv[1]
try:
#request = argv[1]
- request = form["r"]
+ request = form["r"]
.value
except:
request = None
mode = None
else:
try:
except:
request = None
mode = None
else:
try:
- mode = form["m"]
+ mode = form["m"]
.value
except:
mode = None
except:
mode = None
+
try:
#x = int(argv[1])
#y = int(argv[2])
try:
#x = int(argv[1])
#y = int(argv[2])
- x =
form["x"]
- y =
form["y"]
+ x =
int(form["x"].value)
+ y =
int(form["y"].value)
except:
if os.path.exists(path+client+".in") and os.path.exists(path+client+".out"):
except:
if os.path.exists(path+client+".in") and os.path.exists(path+client+".out"):
@@
-147,14
+148,20
@@
def main(argv):
return 1
elif request == "start":
print "New game."
return 1
elif request == "start":
print "New game."
- args =
[path+"qchess.py", "--no-graphics"]
+ args =
path+"qchess.py --no-graphics"
if mode == None or mode == "bishop":
if mode == None or mode == "bishop":
- args +=
["@fifo:../qchess-cgi-data/"+client, "@internal:AgentBishop"]
+ args +=
" @fifo:../qchess-cgi-data/"+client+" @internal:AgentBishop"
if mode == "random":
if mode == "random":
- args +=
["@fifo:../qchess-cgi-data/"+client, "@internal:AgentRandom"]
+ args +=
" @fifo:../qchess-cgi-data/"+client+" @internal:AgentRandom"
elif mode == "eigengame":
elif mode == "eigengame":
- args += ["--server=progcomp.ucc.asn.au", "@fifo:../qchess-cgi-data/"+client]
- subprocess.Popen(args)
+ args += " --server=progcomp.ucc.asn.au @fifo:../qchess-cgi-data/"+client
+
+ os.system("echo '"+args+"' | at now")
+
+ # subprocess.Popen(args)
+ # os.spawnl(os.P_NOWAIT, args)
+
+
time.sleep(1)
log = open(path+client, "a")
time.sleep(1)
log = open(path+client, "a")
@@
-186,12
+193,13
@@
def main(argv):
except:
quit()
else:
except:
quit()
else:
- #
sys.stderr.write("O
pened fine\n")
+ #
sys.stderr.write("cgi o
pened fine\n")
s = fifo_in.readline().strip(" \r\n")
s = fifo_in.readline().strip(" \r\n")
-
+ #sys.stderr.write("cgi read first line: "+str(s)+"\n")
while s != "SELECT?" and s != "MOVE?" and not s.split(" ")[0] in ["white","black"]:
if s != "":
print s
while s != "SELECT?" and s != "MOVE?" and not s.split(" ")[0] in ["white","black"]:
if s != "":
print s
+ # sys.stderr.write("Read: " + str(s) + "\n")
s = fifo_in.readline().strip(" \r\n")
print s
s = fifo_in.readline().strip(" \r\n")
print s
@@
-200,7
+208,7
@@
def main(argv):
#sys.stderr.write("cgi quit!\n")
quit()
#sys.stderr.write("cgi quit!\n")
quit()
- #sys.stderr.write("Done\n")
+ #sys.stderr.write("
cgi qchess
Done\n")
return 0
return 0
@@
-209,5
+217,5
@@
if __name__ == "__main__":
sys.exit(main(sys.argv))
except Exception, e:
print e
sys.exit(main(sys.argv))
except Exception, e:
print e
- sys.stderr.write(str(e) + "\n")
+ sys.stderr.write(s
ys.argv[0] + ": " + s
tr(e) + "\n")
sys.exit(1)
sys.exit(1)
UCC
git Repository :: git.ucc.asn.au