aboutsummaryrefslogtreecommitdiff
path: root/scripts/steuermann_report.cgi
diff options
context:
space:
mode:
authorcslocum <cslocum@d34015c8-bcbb-4646-8ac8-8ba5febf221d>2012-10-03 11:47:46 -0400
committercslocum <cslocum@d34015c8-bcbb-4646-8ac8-8ba5febf221d>2012-10-03 11:47:46 -0400
commitfacc392133a8fbe9dc71c8248843f28d1db8d260 (patch)
tree4ebf4f0e20890e55f1c0467d47a64509bfcdcbb3 /scripts/steuermann_report.cgi
parent6d20f77533a421205c9802ad4cfaecd7947e3453 (diff)
downloadsteuermann-facc392133a8fbe9dc71c8248843f28d1db8d260.tar.gz
link to run logs from SM report
git-svn-id: https://svn.stsci.edu/svn/ssb/etal/steuermann/trunk@806 d34015c8-bcbb-4646-8ac8-8ba5febf221d
Diffstat (limited to 'scripts/steuermann_report.cgi')
-rw-r--r--scripts/steuermann_report.cgi80
1 files changed, 63 insertions, 17 deletions
diff --git a/scripts/steuermann_report.cgi b/scripts/steuermann_report.cgi
index e9be990..f85aa11 100644
--- a/scripts/steuermann_report.cgi
+++ b/scripts/steuermann_report.cgi
@@ -66,6 +66,27 @@ def normalize_run_name(db, name) :
return name
+
+# make sure the name provided is valid
+def validate_name(form):
+ name = re.match('(.*)/(.*):(.*)/(.*)', form['name'].value)
+ run = name.group(1)
+ host = name.group(2)
+ table = name.group(3)
+ cmd = name.group(4)
+
+ db = steuermann.config.open_db()
+ c = db.cursor()
+ c.execute("SELECT status, start_time, end_time, notes FROM sm_status WHERE run = ? AND host = ? AND tablename = ? AND cmd = ?",(
+ run, host, table, cmd ) )
+ x = c.fetchone()
+ if x is None :
+ print "No such record in database",run,host,table,cmd
+ sys.exit(0)
+
+ return run, host, table, cmd, x
+
+
##########
# if no action specified, show the list of runs
#
@@ -229,23 +250,8 @@ elif action == 'log' :
print 'content-type: text/plain'
print ''
- # crack apart the parameter run/host:table/cmd
- name = re.match('(.*)/(.*):(.*)/(.*)', form['name'].value)
- run = name.group(1)
- host = name.group(2)
- table = name.group(3)
- cmd = name.group(4)
-
-
- db = steuermann.config.open_db()
- c = db.cursor()
- c.execute("SELECT status, start_time, end_time, notes FROM sm_status WHERE run = ? AND host = ? AND tablename = ? AND cmd = ?",(
- run, host, table, cmd ) )
- x = c.fetchone()
- if x is None :
- print "No such record in database",run,host,table,cmd
- sys.exit(0)
-
+ run, host, table, cmd, x = validate_name(form)
+
status, start_time, end_time, notes = x
print "%s %s:%s/%s"%(run, host, table, cmd)
@@ -294,6 +300,46 @@ elif action == 'log' :
sys.exit(0)
+
+elif action == 'run_log':
+ run, host, table, cmd, x = validate_name(form)
+
+ print html_header %{'title': form['name'].value}
+
+ host_logs = steuermann.config.host_logs
+ run_logs = os.path.join(host_logs, form['name'].value)
+ print run_logs
+ print '<br/><br/>'
+
+ for log in os.listdir(run_logs):
+ print "<a href='%s?action=show_run_log&name=%s&log_name=%s'>%s</a><br/>" %(cginame, form['name'].value, log, log)
+
+ print html_trailer
+
+ sys.exit(0)
+
+
+elif action == 'show_run_log':
+ run, host, table, cmd, x = validate_name(form)
+
+ log_name = form['log_name'].value
+ host_logs = steuermann.config.host_logs
+ log = os.path.join(host_logs, form['name'].value, log_name)
+
+ print html_header %{'title': '%s' %log}
+
+ if not os.path.exists(log):
+ print 'ERROR - %s does not exist' %log
+ else:
+ file = open(log)
+ print file.read()
+ file.close()
+
+ print html_trailer
+
+ sys.exit(0)
+
+
##########
# info means show information about the system
#