20 installpath = os.path.dirname(__file__)
22 timeofrequest = time.gmtime()
25 queryday = time.strftime(
"%y%m%d",timeofrequest)
26 queryid = time.strftime(
"%y%m%d%H%M%S",timeofrequest)
32 datapath =
'data/arq_%s/arq_%s' % (queryday,queryid)
36 fulldatapath =
'/%s' % datapath
37 os.makedirs(fulldatapath)
40 queryfile =
'%s/query.txt' % fulldatapath
41 fh =
open(queryfile,
"w")
46 logpath = fulldatapath
47 logfile =
'%s/log.txt' % logpath
48 fh =
open(logfile,
"a")
49 print >> fh,
"%s / [id %s] - received query: %s" % (timeofrequest, queryid, q
if q
else "none" )
52 com =
"cd %s; ./CoolRunQueryWrapper.sh fileindex %s" % (installpath,queryid)
55 from commands
import getoutput
57 logfile =
'%s/log.txt' % fulldatapath
58 fh =
open(logfile,
"w")
64 outputfile =
'%s/index.html' % fulldatapath
66 fh =
open(outputfile,
"r")
69 if not page.rstrip().endswith(
"</html>"):
72 page =
"<html><body>No web page created! Here the log file:<pre><br><br><br>%s</pre></body></html>" % (log.replace(
"<",
"<").
replace(
">",
">"))
74 return (page,fulldatapath)