def test_history(): sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) form = pandokia.pcgi.form test_name = form.getvalue("test_name") context = form.getvalue("context") host = form.getvalue("host") test_run = form.getvalue("test_run") project = form.getvalue("project") tb = text_table.text_table() tb.set_html_table_attributes("border=1") row = 0 tb.set_value(row, 0, "project") tb.set_value(row, 1, project) row += 1 tb.set_value(row, 0, "host") tb.set_value(row, 1, host) row += 1 tb.set_value(row, 0, "context") tb.set_value(row, 1, context) row += 1 tb.set_value(row, 0, "test_name") tb.set_value(row, 1, test_name) row += 1 print(tb.get_html()) print("<br>") tb = text_table.text_table() tb.set_html_table_attributes("border=1") c = pdk_db.execute( "SELECT test_run, status, key_id FROM result_scalar WHERE " "test_name = :1 AND context = :2 AND host = :3 AND project = :4 ORDER BY test_run DESC", (test_name, context, host, project)) row = 0 for x in c: r_test_run, status, key_id = x tb.set_value(row, 1, r_test_run, link=common.selflink( {'key_id': key_id}, linkmode='detail')) tb.set_value(row, 2, status) if test_run == r_test_run: tb.set_value(row, 0, '->') row = row + 1 print(tb.get_html())
def test_history(): sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) form = pandokia.pcgi.form test_name = form["test_name"].value context = form["context"].value host = form["host"].value test_run = form["test_run"].value project = form["project"].value tb = text_table.text_table() tb.set_html_table_attributes("border=1") row = 0 tb.set_value(row, 0, "project") tb.set_value(row, 1, project) row += 1 tb.set_value(row, 0, "host") tb.set_value(row, 1, host) row += 1 tb.set_value(row, 0, "context") tb.set_value(row, 1, context) row += 1 tb.set_value(row, 0, "test_name") tb.set_value(row, 1, test_name) row += 1 print(tb.get_html()) print("<br>") tb = text_table.text_table() tb.set_html_table_attributes("border=1") c = pdk_db.execute( "SELECT test_run, status, key_id FROM result_scalar WHERE " "test_name = :1 AND context = :2 AND host = :3 AND project = :4 ORDER BY test_run DESC", (test_name, context, host, project)) row = 0 for x in c: r_test_run, status, key_id = x tb.set_value(row, 1, r_test_run, link=common.selflink({'key_id': key_id}, linkmode='detail')) tb.set_value(row, 2, status) if test_run == r_test_run: tb.set_value(row, 0, '->') row = row + 1 print(tb.get_html())
def delete_confirmed(): form = pandokia.pcgi.form test_run = form.getfirst("test_run") project = form.getfirst('project', '*') context = form.getfirst('context', '*') custom = form.getfirst('custom', '*') host = form.getfirst('host', '*') where_str, where_dict = pdk_db.where_dict([('test_run', test_run), ('project', project), ('context', context), ('custom', custom), ('host', host)]) sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) if pandokia.cleaner.check_valuable(test_run): print("valuable test run - There should not be a link that comes here") return my_run_prefix = 'user_' + common.current_user() admin = common.current_user() in common.cfg.admin_user_list if not (admin or test_run.startswith(my_run_prefix)): print("You (%s) can't do that" % common.current_user()) else: print("Deleteing...") sys.stdout.flush() # make a dummy record, so we know that we can never delete the # last record created. pandokia.cleaner.block_last_record() # delete_run is chatty, so we <pre> around it print("<pre>") print("working...") sys.stdout.flush() cleaner.delete_by_query(where_str, where_dict) if project == '*' and context == '*' and host == '*': print("delete from index") pdk_db.execute("DELETE FROM distinct_test_run WHERE test_run = :1", (test_run, )) pdk_db.commit() print("done.") print("</pre>") sys.stdout.flush()
def delete_confirmed(): form = pandokia.pcgi.form test_run = form.getfirst("test_run") project = form.getfirst('project', '*') context = form.getfirst('context', '*') custom = form.getfirst('custom', '*') host = form.getfirst('host', '*') where_str, where_dict = pdk_db.where_dict( [('test_run', test_run), ('project', project), ('context', context), ('custom', custom), ('host', host)]) sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) if pandokia.cleaner.check_valuable(test_run): print("valuable test run - There should not be a link that comes here") return my_run_prefix = 'user_' + common.current_user() admin = common.current_user() in common.cfg.admin_user_list if not (admin or test_run.startswith(my_run_prefix)): print("You (%s) can't do that" % common.current_user()) else: print("Deleteing...") sys.stdout.flush() # make a dummy record, so we know that we can never delete the # last record created. pandokia.cleaner.block_last_record() # delete_run is chatty, so we <pre> around it print("<pre>") print("working...") sys.stdout.flush() cleaner.delete_by_query(where_str, where_dict) if project == '*' and context == '*' and host == '*': print("delete from index") pdk_db.execute( "DELETE FROM distinct_test_run WHERE test_run = :1", (test_run,)) pdk_db.commit() print("done.") print("</pre>") sys.stdout.flush()
def delete_are_you_sure(): form = pandokia.pcgi.form test_run = form.getfirst("test_run") project = form.getfirst('project', '*') context = form.getfirst('context', '*') custom = form.getfirst('custom', '*') host = form.getfirst('host', '*') sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) if pandokia.cleaner.check_valuable(test_run): print("valuable test run - There should not be a link that comes here") return print("Delete data for:<br>") tt = text_table.text_table() tt.set_html_table_attributes("border=1") tt.set_value(0, 0, 'test_run') tt.set_value(0, 1, test_run) tt.set_value(1, 0, 'project') tt.set_value(1, 1, project) tt.set_value(2, 0, 'host') tt.set_value(2, 1, host) tt.set_value(3, 0, 'context') tt.set_value(3, 1, context) tt.set_value(4, 0, 'custom') tt.set_value(4, 1, custom) print(tt.get_html()) print("<br>") where_str, where_dict = pdk_db.where_dict( [('test_run', test_run), ('project', project), ('context', context), ('custom', custom), ('host', host)]) print("%s<br>" % where_str) print("%s<br>" % where_dict) c = pdk_db.execute( 'SELECT count(*) FROM result_scalar %s' % where_str, where_dict) (x,) = c.fetchone() print("%d records<br>" % x) print( '<a href="%s">Confirm delete</a>' % common.selflink( { 'test_run': test_run, 'project': project, 'context': context, 'custom': custom, 'host': host}, 'delete_run.conf'))
def delete_are_you_sure(): form = pandokia.pcgi.form test_run = form.getfirst("test_run") project = form.getfirst('project', '*') context = form.getfirst('context', '*') custom = form.getfirst('custom', '*') host = form.getfirst('host', '*') sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) if pandokia.cleaner.check_valuable(test_run): print("valuable test run - There should not be a link that comes here") return print("Delete data for:<br>") tt = text_table.text_table() tt.set_html_table_attributes("border=1") tt.set_value(0, 0, 'test_run') tt.set_value(0, 1, test_run) tt.set_value(1, 0, 'project') tt.set_value(1, 1, project) tt.set_value(2, 0, 'host') tt.set_value(2, 1, host) tt.set_value(3, 0, 'context') tt.set_value(3, 1, context) tt.set_value(4, 0, 'custom') tt.set_value(4, 1, custom) print(tt.get_html()) print("<br>") where_str, where_dict = pdk_db.where_dict([('test_run', test_run), ('project', project), ('context', context), ('custom', custom), ('host', host)]) print("%s<br>" % where_str) print("%s<br>" % where_dict) c = pdk_db.execute('SELECT count(*) FROM result_scalar %s' % where_str, where_dict) (x, ) = c.fetchone() print("%d records<br>" % x) print('<a href="%s">Confirm delete</a>' % common.selflink( { 'test_run': test_run, 'project': project, 'context': context, 'custom': custom, 'host': host }, 'delete_run.conf'))
def run(): if cfg.debug: cgitb.enable() if cfg.server_maintenance: sys.stdout.write( "content-type: text/html\n\n\nWeb page unavailable because of pandokia server maintenance<p>\n\n" ) if isinstance(cfg.server_maintenance, basestring): sys.stdout.write("%s\n" % cfg.server_maintenance) sys.exit(0) ###### # # check authentication # #--#--# CGI if not common.check_auth(): # If authentication fails, I'm not concerned about giving # a particularly useful message. sys.stdout.write( "content-type: text/html\n\n\nAUTHENTICATION FAILED\n\n") sys.exit(0) ###### # # various forms of links to ourself # # cginame is the name of the cgi, for use in generating html links to ourself. # This is NOT the full URL -- it is only the path on this host. We cannot # know the host name part of the URL (e.g. if the web connection is coming # through an ssh tunnel). # #--#--# CGI global cginame cginame = os.getenv("SCRIPT_NAME") ###### # # fetch the cgi parameters # global form form = cgi.FieldStorage(keep_blank_values=1) ###### # # output_format is the output format requested; each query type must # either know what to do for each possible format # possible values are: # 'html' (MUST be default) # 'csv' global output_format if 'format' in form: output_format = form['format'].value else: output_format = "html" ###### # # if we don't have a query field, show the top-level menu and we are done. # #--#--# CGI if not form.has_key("query"): import re sys.stdout.write("Content-type: text/html\n\n") f = os.path.dirname(os.path.abspath(__file__)) + '/top_level.html' header = common.page_header() f = open(f, "r") x = f.read() f.close() if common.current_user() in common.cfg.admin_user_list: x = re.sub("ADMINLINK", '<br> <a href=CGINAME?query=admin>Admin</a> <br>', x) else: x = re.sub("ADMINLINK", '', x) x = re.sub("CGINAME", cginame, x) x = re.sub("PAGEHEADER", header, x) sys.stdout.write(x) sys.exit(0) ###### # # if we get here, we are processing a query. # # There various modules to implement the known query types. #--#--# CGI query = form["query"].value if query == "treewalk": import pandokia.pcgi_treewalk as x x.treewalk() sys.exit(0) if query == "qid_op": import pandokia.pcgi_qid_op as x x.run() sys.exit(0) if query == 'qid_list': import pandokia.pcgi_qid_op as x x.qid_list() sys.exit(0) if query == "treewalk.linkout": import pandokia.pcgi_treewalk as x x.linkout() sys.exit(0) if query == "summary": import pandokia.pcgi_summary as x x.run() sys.exit(0) if query == "detail": import pandokia.pcgi_detail as x x.run() sys.exit(0) if query == "test_history": import pandokia.pcgi_detail as x x.test_history() sys.exit(0) if query.startswith("day_report."): import pandokia.pcgi_day_report as x if query == "day_report.1": x.rpt1() if query == "day_report.2": x.rpt2() if query == "day_report.3": x.rpt3() sys.exit(0) if query.startswith("delete_run."): import pandokia.pcgi_delete as x if query == "delete_run.ays": x.delete_are_you_sure() if query == "delete_run.conf": x.delete_confirmed() sys.exit(0) if query == 'flagok': import pandokia.pcgi_flagok as x x.flagok() sys.exit(0) if query == 'action': import pandokia.pcgi_action as x x.run() sys.exit(0) if query == 'prefs': import pandokia.pcgi_preferences as x x.run() sys.exit(0) if query == 'killproc': print "content-type: text/html" print "" pid = form['pid'].value sig = form['sig'].value if common.current_user() in common.cfg.admin_user_list: os.kill(int(pid), int(sig)) print "done" sys.exit(0) if query == 'hostinfo': import pandokia.pcgi_misc as x x.hostinfo() sys.exit(0) if query == 'set_hostinfo': import pandokia.pcgi_misc as x x.set_hostinfo() sys.exit(0) if query == 'magic_html_log': import pandokia.pcgi_detail as x x.magic_html_log() sys.exit(0) if query == 'expected': import pandokia.pcgi_misc as x x.expected() sys.exit(0) if query == 'new': import pandokia.pcgi_reports as x x.cluster_report() sys.exit(0) if query == 'latest': import pandokia.pcgi_misc as x x.latest() sys.exit(0) error_1201() # # You can't get here by following links, so you must have typed in the # url directly. In that case, you are messing with us and you get no # friendly response. if cfg.debug or (common.current_user() in common.cfg.admin_user_list): print "YOU ARE ADMIN, DEBUG FOLLOWS" for x in form: if isinstance(form[x], list): for y in form[x]: print x, y, "<br>" else: print x, form[x], "<br>"
def run(): if cfg.debug: cgitb.enable() if cfg.server_maintenance: sys.stdout.write( "content-type: text/html\n\n\nWeb page unavailable because of pandokia server maintenance<p>\n\n") if isinstance(cfg.server_maintenance, str): sys.stdout.write("%s\n" % cfg.server_maintenance) sys.exit(0) ###### # # check authentication # #--#--# CGI if not common.check_auth(): # If authentication fails, I'm not concerned about giving # a particularly useful message. sys.stdout.write( "content-type: text/html\n\n\nAUTHENTICATION FAILED\n\n") sys.exit(0) ###### # # various forms of links to ourself # # cginame is the name of the cgi, for use in generating html links to ourself. # This is NOT the full URL -- it is only the path on this host. We cannot # know the host name part of the URL (e.g. if the web connection is coming # through an ssh tunnel). # #--#--# CGI global cginame cginame = os.getenv("SCRIPT_NAME") ###### # # fetch the cgi parameters # global form form = cgi.FieldStorage(keep_blank_values=1) ###### # # output_format is the output format requested; each query type must # either know what to do for each possible format # possible values are: # 'html' (MUST be default) # 'csv' global output_format if 'format' in form: output_format = form.getvalue('format') else: output_format = "html" ###### # # if we don't have a query field, show the top-level menu and we are done. # #--#--# CGI if "query" not in form: import re sys.stdout.write("Content-type: text/html\n\n") f = os.path.dirname(os.path.abspath(__file__)) + '/top_level.html' header = common.page_header() f = open(f, "r") x = f.read() f.close() if common.current_user() in common.cfg.admin_user_list: x = re.sub( "ADMINLINK", '<br> <a href=CGINAME?query=admin>Admin</a> <br>', x) else: x = re.sub("ADMINLINK", '', x) x = re.sub("CGINAME", cginame, x) x = re.sub("PAGEHEADER", header, x) sys.stdout.write(x) sys.exit(0) ###### # # if we get here, we are processing a query. # # There various modules to implement the known query types. #--#--# CGI query = form.getvalue("query") if query == "treewalk": import pandokia.pcgi_treewalk as x x.treewalk() sys.exit(0) if query == "qid_op": import pandokia.pcgi_qid_op as x x.run() sys.exit(0) if query == 'qid_list': import pandokia.pcgi_qid_op as x x.qid_list() sys.exit(0) if query == "treewalk.linkout": import pandokia.pcgi_treewalk as x x.linkout() sys.exit(0) if query == "summary": import pandokia.pcgi_summary as x x.run() sys.exit(0) if query == "detail": import pandokia.pcgi_detail as x x.run() sys.exit(0) if query == "test_history": import pandokia.pcgi_detail as x x.test_history() sys.exit(0) if query.startswith("day_report."): import pandokia.pcgi_day_report as x if query == "day_report.1": x.rpt1() if query == "day_report.2": x.rpt2() if query == "day_report.3": x.rpt3() sys.exit(0) if query.startswith("delete_run."): import pandokia.pcgi_delete as x if query == "delete_run.ays": x.delete_are_you_sure() if query == "delete_run.conf": x.delete_confirmed() sys.exit(0) if query == 'flagok': import pandokia.pcgi_flagok as x x.flagok() sys.exit(0) if query == 'action': import pandokia.pcgi_action as x x.run() sys.exit(0) if query == 'prefs': import pandokia.pcgi_preferences as x x.run() sys.exit(0) if query == 'killproc': print("content-type: text/html") print("") pid = form.getvalue('pid') sig = form.getvalue('sig') if common.current_user() in common.cfg.admin_user_list: os.kill(int(pid), int(sig)) print("done") sys.exit(0) if query == 'hostinfo': import pandokia.pcgi_misc as x x.hostinfo() sys.exit(0) if query == 'set_hostinfo': import pandokia.pcgi_misc as x x.set_hostinfo() sys.exit(0) if query == 'magic_html_log': import pandokia.pcgi_detail as x x.magic_html_log() sys.exit(0) if query == 'expected': import pandokia.pcgi_misc as x x.expected() sys.exit(0) if query == 'new': import pandokia.pcgi_reports as x x. cluster_report() sys.exit(0) if query == 'latest': import pandokia.pcgi_misc as x x.latest() sys.exit(0) error_1201() # # You can't get here by following links, so you must have typed in the # url directly. In that case, you are messing with us and you get no # friendly response. if cfg.debug or (common.current_user() in common.cfg.admin_user_list): print("YOU ARE ADMIN, DEBUG FOLLOWS") for x in form: if isinstance(form[x], list): for y in form[x]: print("%s %s<br>" % (x, y)) else: print("%s %s<br>" % (x, form.getvalue(x)))
def rpt1(): form = pandokia.pcgi.form if form.has_key("test_run"): test_run = form["test_run"].value else: test_run = '*' if test_run == '-me': test_run = 'user_' + common.current_user() + '_*' my_run_prefix = 'user_' + common.current_user() admin = common.current_user() in common.cfg.admin_user_list # c = db.execute("SELECT DISTINCT test_run FROM result_scalar WHERE test_run GLOB ? ORDER BY test_run DESC ",( test_run,)) where_str, where_dict = pdk_db.where_dict([('test_run', test_run)]) sql = "SELECT test_run, valuable, record_count, note, min_time, max_time FROM distinct_test_run %s ORDER BY test_run DESC " % where_str c = pdk_db.execute(sql, where_dict) table = text_table.text_table() table.set_html_table_attributes("border=1") table.define_column('addval', showname='') table.define_column('run', showname='test_run') table.define_column('tree', showname='') table.define_column('del', showname='') table.define_column('min', showname='start') table.define_column('max', showname='end') table.define_column('tdiff', showname='duration') table.define_column('count', showname='records') table.define_column('note', showname='note') # query parameters for various links # link to day_report # link to tree walk of test run tquery = {'project': '*', 'host': '*'} # link to declare a run as valuable vquery = {'valuable_run': 1} # link to update the count in a test run cquery = {} row = 0 for x, val, record_count, note, min_time, max_time in c: if x is None: continue tquery["test_run"] = x vquery["test_run"] = x cquery["count_run"] = x # mark as valuable: # https://ssb.stsci.edu/pandokia/c41.cgi?query=action&test_run=daily_2011-08-24&valuable_run=1 table.set_value(row, 'addval', html='<a href="%s">!</a> ' % common.selflink(vquery, "action")) table.set_value(row, 'run', text=x, link=common.selflink(tquery, "day_report.2")) table.set_value(row, 'tree', text='(tree display)', link=common.selflink(tquery, "treewalk")) if val == '0': if x.startswith(my_run_prefix): table.set_value(row, 'del', text='(delete)', link=common.selflink(tquery, "delete_run.ays")) else: table.set_value(row, 'del', text='(delete)', html='<font color=gray>(delete)</font>', link=common.selflink(tquery, "delete_run.ays")) else: table.set_value(row, 'del', text='(valuable)') if note is None: table.set_value(row, 'note', text='') else: table.set_value(row, 'note', text=note) if min_time is not None and max_time is not None: table.set_value(row, 'tdiff', str(lib.time_diff(max_time, min_time))) min_time = str(min_time).split('.')[0] max_time = str(max_time).split('.')[0] t1 = min_time.split() t2 = max_time.split() if len(t2) > 1 and len(t1) > 1 and t1[0] == t2[0] and len(t2) > 1: max_time = t2[1] table.set_value(row, 'min', text=min_time) table.set_value(row, 'max', text=max_time) else: if min_time is not None: min_time = str(min_time).split('.')[0] table.set_value(row, 'min', text=min_time) if max_time is not None: max_time = str(max_time).split('.')[0] table.set_value(row, 'max', text=max_time) table.set_value(row, 'tdiff', '') # update the count field # https://ssb.stsci.edu/pandokia/c41.cgi?query=action&count_run=daily_2011-08-24 update_count = common.selflink(cquery, 'action') if record_count is None or record_count <= 0: record_count = ' ' table.set_value(row, 'count', html=str(record_count), link=update_count) row = row + 1 if pandokia.pcgi.output_format == 'html': sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) sys.stdout.write('<h2>%s</h2>' % cgi.escape(test_run)) sys.stdout.write(table.get_html(headings=1)) sys.stdout.write( "<br>Click on the ! to mark a test run as too valuable to delete\n" ) sys.stdout.write( "<br>Click on record count to check the count and update it\n") sys.stdout.write("""<style> table { border-collapse: collapse; } table, th, td { border: 2px solid black; padding: 3px; } </style> """) elif pandokia.pcgi.output_format == 'csv': sys.stdout.write(common.cgi_header_csv) sys.stdout.write(table.get_csv()) sys.stdout.flush() return
def rpt2(): form = pandokia.pcgi.form if form.has_key("test_run"): test_run = form["test_run"].value else: # no parameter? I think somebody is messing with us... # no matter - just give them a the list of all the test_runs rpt1() return # test_run = common.find_test_run(test_run) # create list of projects projects = None host = None context = None chronic = '0' if form.has_key("project"): projects = form.getlist("project") if form.has_key("host"): host = form.getlist("host") if form.has_key("context"): context = form.getlist("context") if form.has_key("chronic"): chronic = form.getlist("chronic")[0] c = pdk_db.execute( "SELECT note, valuable FROM distinct_test_run WHERE test_run = :1", (test_run, )) x = c.fetchone() if x is None: sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) sys.stdout.write('No such test run') return test_run_note, test_run_valuable = x if test_run_note is None: test_run_note = '' if test_run_valuable is None: test_run_valuable = 0 else: test_run_valuable = int(test_run_valuable) # create the actual table (table, projects) = gen_daily_table(test_run, projects, context, host, valuable=test_run_valuable, chronic=chronic == '1') # # # # # # # # # # if pandokia.pcgi.output_format == 'html': header = "<big><big><b>" + cgi.escape(test_run) + "</b></big></big>\n" if 1: # if it looks like there is a date in it, try to show the day of the week # dates must look like 2011-01-01 and do not occur at the beginning of the name t = common.looks_like_a_date(test_run) try: import datetime t = t.group(1).split('-') (year, month, day) = (int(t[0]), int(t[1]), int(t[2])) t = datetime.date(year, month, day) t = t.strftime("%A") header = header + "<big>(" + str(t) + ")</big>" except: pass header = header + "<p>" recurring_prefix = common.recurring_test_run(test_run) if recurring_prefix: # # If we have a recurring run, create a special header. # Include links to the previous / next in the sequence l = [] prev = common.run_previous(recurring_prefix, test_run) if prev: l.append( common.self_href(query_dict={'test_run': prev}, linkmode='day_report.2', text=prev)) next = common.run_next(recurring_prefix, test_run) if next: l.append( common.self_href(query_dict={'test_run': next}, linkmode='day_report.2', text=next)) latest = common.run_latest(recurring_prefix) if latest and (latest != next) and (latest != test_run): l.append( common.self_href(query_dict={'test_run': latest}, linkmode='day_report.2', text=latest)) header = header + '( %s )' % (' / '.join(l)) if 1: if test_run_note.startswith('*'): header = header + '<p>\nNote: %s</p>' % ( cgi.escape(test_run_note)) else: header = header + '<p><form action=%s>\nNote: <input type=text name=note value="%s" size=%d>\n<input type=hidden name=test_run value="%s">\n<input type=hidden name=query value=action></form></p>' % ( common.get_cgi_name(), cgi.escape(test_run_note), len(test_run_note) + 20, test_run) if test_run_valuable: header = header + '<p>valuable ' else: header = header + '<p>not valuable ' header = header + '(<a href=%s>change</a>)' % (common.selflink( { 'test_run': test_run, 'valuable_run': int(not test_run_valuable) }, linkmode='action')) sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) sys.stdout.write(header) # write links to the top of each project sys.stdout.write('<p>\n') for p in projects: p = cgi.escape(p) sys.stdout.write('<a href="#%s">%s</a> ' % (p, p)) sys.stdout.write('</p>\n') # write the report table sys.stdout.write(table.get_html(headings=0)) elif pandokia.pcgi.output_format == 'csv': sys.stdout.write(common.cgi_header_csv) sys.stdout.write(table.get_csv())
def run(): sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) form = pandokia.pcgi.form if "test_name" in form: test_name = form.getvalue("test_name") else: test_name = "" if "context" in form: context = form.getvalue("context") else: context = "*" if "custom" in form: custom = form.getvalue("custom") else: custom = "*" if "host" in form: host = form.getvalue("host") else: host = "*" if "test_run" in form: test_run = form.getvalue("test_run") else: test_run = "*" if "project" in form: project = form.getvalue("project") else: project = "*" if "status" in form: status = form.getvalue("status") else: status = "*" if "test_name" in form: cmp_run = form.getvalue("test_name") if cmp_run == '': cmp_run = common.run_previous(None, test_run) if cmp_run is not None: cmp_run = common.find_test_run(cmp_run) else: cmp_run = '' else: cmp_run = common.find_test_run(cmp_run) else: cmp_run = "" if "key_id" in form: key_id = form.getvalue("key_id") else: key_id = "" if "qid" in form: qid = form.getvalue("qid") else: qid = "" # # main heading # sys.stdout.write("<h1>Test detail</h1>\n") # # this query finds all the test results that are an interesting part of this request # if key_id != "": n = do_result(key_id) elif qid != "": c1 = pdk_db.execute("SELECT key_id FROM query WHERE qid = :1 ", (qid, )) l = [] for x in c1: l.append(x[0]) del c1 n = 0 for key_id in l: n = n + do_result(key_id) else: c1 = pdk_db.execute( "SELECT key_id FROM result_scalar WHERE test_run = :1 AND project = :2 AND host = :3 AND test_name = :4 AND context = :5 AND custom = :6 ", (test_run, project, host, test_name, context, custom)) n = 0 for x in c1: (key_id, ) = x n = n + do_result(key_id) if n == 0: sys.stdout.write("no tests match\n") d_in = { 'project': project, 'host': host, 'context': context, 'custom': custom, 'test_run': test_run, 'test_name': test_name } t = next_prev(d_in, test_run) if t != '': sys.stdout.write(t)
def run(): sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) form = pandokia.pcgi.form if "test_name" in form: test_name = form.getvalue("test_name") else: test_name = "" if "context" in form: context = form.getvalue("context") else: context = "*" if "host" in form: host = form.getvalue("host") else: host = "*" if "test_run" in form: test_run = form.getvalue("test_run") else: test_run = "*" if "project" in form: project = form.getvalue("project") else: project = "*" if "status" in form: status = form.getvalue("status") else: status = "*" if "test_name" in form: cmp_run = form.getvalue("test_name") if cmp_run == '': cmp_run = common.run_previous(None, test_run) if cmp_run is not None: cmp_run = common.find_test_run(cmp_run) else: cmp_run = '' else: cmp_run = common.find_test_run(cmp_run) else: cmp_run = "" if "key_id" in form: key_id = form.getvalue("key_id") else: key_id = "" if "qid" in form: qid = form.getvalue("qid") else: qid = "" # # main heading # sys.stdout.write("<h1>Test detail</h1>\n") # # this query finds all the test results that are an interesting part of this request # if key_id != "": n = do_result(key_id) elif qid != "": c1 = pdk_db.execute("SELECT key_id FROM query WHERE qid = :1 ", (qid,)) l = [] for x in c1: l.append(x[0]) del c1 n = 0 for key_id in l: n = n + do_result(key_id) else: c1 = pdk_db.execute( "SELECT key_id FROM result_scalar WHERE test_run = :1 AND project = :2 AND host = :3 AND test_name = :4 AND context = :5 ", (test_run, project, host, test_name, context)) n = 0 for x in c1: (key_id, ) = x n = n + do_result(key_id) if n == 0: sys.stdout.write("no tests match\n") d_in = { 'project': project, 'host': host, 'context': context, 'test_run': test_run, 'test_name': test_name} t = next_prev(d_in, test_run) if t != '': sys.stdout.write(t)
def rpt1(): form = pandokia.pcgi.form if "test_run" in form: test_run = form.getvalue("test_run") else: test_run = '*' if test_run == '-me': test_run = 'user_' + common.current_user() + '_*' my_run_prefix = 'user_' + common.current_user() admin = common.current_user() in common.cfg.admin_user_list # c = db.execute("SELECT DISTINCT test_run FROM result_scalar WHERE test_run GLOB ? ORDER BY test_run DESC ",( test_run,)) where_str, where_dict = pdk_db.where_dict([('test_run', test_run)]) sql = "SELECT test_run, valuable, record_count, note, min_time, max_time FROM distinct_test_run %s ORDER BY test_run DESC " % where_str c = pdk_db.execute(sql, where_dict) table = text_table.text_table() table.set_html_table_attributes("border=1") table.define_column('addval', showname='') table.define_column('run', showname='test_run') table.define_column('tree', showname='') table.define_column('del', showname='') table.define_column('min', showname='start') table.define_column('max', showname='end') table.define_column('tdiff', showname='duration') table.define_column('count', showname='records') table.define_column('note', showname='note') # query parameters for various links # link to day_report # link to tree walk of test run tquery = {'project': '*', 'host': '*'} # link to declare a run as valuable vquery = {'valuable_run': 1} # link to update the count in a test run cquery = {} row = 0 for x, val, record_count, note, min_time, max_time in c: if x is None: continue tquery["test_run"] = x vquery["test_run"] = x cquery["count_run"] = x # mark as valuable: # https://ssb.stsci.edu/pandokia/c41.cgi?query=action&test_run=daily_2011-08-24&valuable_run=1 table.set_value( row, 'addval', html='<a href="%s">!</a> ' % common.selflink( vquery, "action")) table.set_value( row, 'run', text=x, link=common.selflink( tquery, "day_report.2")) table.set_value( row, 'tree', text='(tree display)', link=common.selflink( tquery, "treewalk")) if val == '0': if x.startswith(my_run_prefix): table.set_value( row, 'del', text='(delete)', link=common.selflink( tquery, "delete_run.ays")) else: table.set_value( row, 'del', text='(delete)', html='<font color=gray>(delete)</font>', link=common.selflink( tquery, "delete_run.ays")) else: table.set_value(row, 'del', text='(valuable)') if note is None: table.set_value(row, 'note', text='') else: table.set_value(row, 'note', text=note) if min_time is not None and max_time is not None: table.set_value( row, 'tdiff', str( lib.time_diff( max_time, min_time))) min_time = str(min_time).split('.')[0] max_time = str(max_time).split('.')[0] t1 = min_time.split() t2 = max_time.split() if len(t2) > 1 and len(t1) > 1 and t1[0] == t2[0] and len(t2) > 1: max_time = t2[1] table.set_value(row, 'min', text=min_time) table.set_value(row, 'max', text=max_time) else: if min_time is not None: min_time = str(min_time).split('.')[0] table.set_value(row, 'min', text=min_time) if max_time is not None: max_time = str(max_time).split('.')[0] table.set_value(row, 'max', text=max_time) table.set_value(row, 'tdiff', '') # update the count field # https://ssb.stsci.edu/pandokia/c41.cgi?query=action&count_run=daily_2011-08-24 update_count = common.selflink(cquery, 'action') if record_count is None or record_count <= 0: record_count = ' ' table.set_value( row, 'count', html=str(record_count), link=update_count) row = row + 1 if pandokia.pcgi.output_format == 'html': sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) sys.stdout.write('<h2>%s</h2>' % cgi.escape(test_run)) sys.stdout.write(table.get_html(headings=1)) sys.stdout.write( "<br>Click on the ! to mark a test run as too valuable to delete\n") sys.stdout.write( "<br>Click on record count to check the count and update it\n") sys.stdout.write("""<style> table { border-collapse: collapse; } table, th, td { border: 2px solid black; padding: 3px; } </style> """) elif pandokia.pcgi.output_format == 'csv': sys.stdout.write(common.cgi_header_csv) sys.stdout.write(table.get_csv()) sys.stdout.flush() return
def rpt2(): form = pandokia.pcgi.form if "test_run" in form: test_run = form.getvalue("test_run") else: # no parameter? I think somebody is messing with us... # no matter - just give them a the list of all the test_runs rpt1() return # test_run = common.find_test_run(test_run) # create list of projects projects = None host = None context = None chronic = '0' if "project" in form: projects = form.getlist("project") if "host" in form: host = form.getlist("host") if "context" in form: context = form.getlist("context") if "chronic" in form: chronic = form.getlist("chronic")[0] c = pdk_db.execute( "SELECT note, valuable FROM distinct_test_run WHERE test_run = :1", (test_run,)) x = c.fetchone() if x is None: sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) sys.stdout.write('No such test run') return test_run_note, test_run_valuable = x if test_run_note is None: test_run_note = '' if test_run_valuable is None: test_run_valuable = 0 else: test_run_valuable = int(test_run_valuable) # create the actual table (table, projects) = gen_daily_table(test_run, projects, context, host, valuable=test_run_valuable, chronic=chronic == '1') # # # # # # # # # # if pandokia.pcgi.output_format == 'html': header = "<big><big><b>" + cgi.escape(test_run) + "</b></big></big>\n" if 1: # if it looks like there is a date in it, try to show the day of the week # dates must look like 2011-01-01 and do not occur at the beginning # of the name t = common.looks_like_a_date(test_run) try: import datetime t = t.group(1).split('-') (year, month, day) = (int(t[0]), int(t[1]), int(t[2])) t = datetime.date(year, month, day) t = t.strftime("%A") header = header + "<big>(" + str(t) + ")</big>" except: pass header = header + "<p>" recurring_prefix = common.recurring_test_run(test_run) if recurring_prefix: # # If we have a recurring run, create a special header. # Include links to the previous / next in the sequence l = [] prev = common.run_previous(recurring_prefix, test_run) if prev: l.append( common.self_href( query_dict={ 'test_run': prev}, linkmode='day_report.2', text=prev)) next = common.run_next(recurring_prefix, test_run) if next: l.append( common.self_href( query_dict={ 'test_run': next}, linkmode='day_report.2', text=next)) latest = common.run_latest(recurring_prefix) if latest and (latest != next) and (latest != test_run): l.append( common.self_href( query_dict={ 'test_run': latest}, linkmode='day_report.2', text=latest)) header = header + '( %s )' % (' / '.join(l)) if 1: if test_run_note.startswith('*'): header = header + \ '<p>\nNote: %s</p>' % (cgi.escape(test_run_note)) else: header = header + '<p><form action=%s>\nNote: <input type=text name=note value="%s" size=%d>\n<input type=hidden name=test_run value="%s">\n<input type=hidden name=query value=action></form></p>' % ( common.get_cgi_name(), cgi.escape(test_run_note), len(test_run_note) + 20, test_run) if test_run_valuable: header = header + '<p>valuable ' else: header = header + '<p>not valuable ' header = header + '(<a href=%s>change</a>)' % (common.selflink( {'test_run': test_run, 'valuable_run': int(not test_run_valuable)}, linkmode='action')) sys.stdout.write(common.cgi_header_html) sys.stdout.write(common.page_header()) sys.stdout.write(header) # write links to the top of each project sys.stdout.write('<p>\n') for p in projects: p = cgi.escape(p) sys.stdout.write('<a href="#%s">%s</a> ' % (p, p)) sys.stdout.write('</p>\n') # write the report table sys.stdout.write(table.get_html(headings=0)) elif pandokia.pcgi.output_format == 'csv': sys.stdout.write(common.cgi_header_csv) sys.stdout.write(table.get_csv())