-
Notifications
You must be signed in to change notification settings - Fork 1
/
status.py
executable file
·43 lines (37 loc) · 1.15 KB
/
status.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import cgi
import cgitb
import os
import sys
sys.path.append('/data/project/recitation-bot/')
import shutdown_bot_hack
cgitb.enable()
print "Content-Type: text/html" # HTML is following
print # blank line, end of headers
print "<TITLE>control recitation-bot</TITLE>"
print "<H1>control recitation-bot</H1>"
print "<html>"
print "<body>"
# standard single line text field
print "<form method='post'>"
actions = ['status', 'shutdown', 'shutdown_hard', 'start']
actions_text = ['show status', 'shutdown bot', 'shutdown bot HARD', 'start bot']
for var, text in zip(actions, actions_text):
print "<input type='radio' name='%s' />%s" % (var, text)
print ".<br /><input type='submit' value='execute' />"
print "</form>"
form = cgi.FieldStorage()
def wrap_pre(sidefun):
print '<pre>'
sidefun()
print '</pre>'
if 'status' in form:
wrap_pre(shutdown_bot_hack.qstat_simple)
if 'shutdown' in form:
wrap_pre(shutdown_bot_hack.qdel_python_method)
if 'shutdown_hard' in form:
wrap_pre(shutdown_bot_hack.do_suite)
if 'start' in form:
wrap_pre(shutdown_bot_hack.start_it)
print "</ul>"
print "</body>"
print "</html>"