def add_received_item_outcome(msg, module_part): if msg['hostkey']: host_elem = dom.document.getElementById(msg['hostkey']) glob.host_pending[msg['hostkey']].pop() count = len(glob.host_pending[msg['hostkey']]) host_elem.childNodes[0].nodeValue = '%s[%s]' % ( glob.host_dict[msg['hostkey']], count) td = create_elem("td") td.setAttribute("onmouseover", "show_info('%s')" % ( msg['fullitemname'],)) td.setAttribute("onmouseout", "hide_info()") item_name = msg['fullitemname'] # TODO: dispatch output if msg["passed"] == 'True': txt = create_text_elem(".") td.appendChild(txt) elif msg["skipped"] != 'None' and msg["skipped"] != "False": exported_methods.show_skip(item_name, skip_come_back) link = create_elem("a") link.setAttribute("href", "javascript:show_skip('%s')" % ( msg['fullitemname'],)) txt = create_text_elem('s') link.appendChild(txt) td.appendChild(link) else: link = create_elem("a") link.setAttribute("href", "javascript:show_traceback('%s')" % ( msg['fullitemname'],)) txt = create_text_elem('F') link.setAttribute('class', 'error') link.appendChild(txt) td.appendChild(link) exported_methods.show_fail(item_name, fail_come_back) if counters[msg['fullmodulename']] == 0: tr = create_elem("tr") module_part.appendChild(tr) name = msg['fullmodulename'] counters[name] += 1 counter_part = get_elem('_txt_' + name) newcontent = "%s[%d/%d]" % (short_item_names[name], counters[name], max_items[name]) counter_part.childNodes[0].nodeValue = newcontent module_part.childNodes[-1].appendChild(td)
def process(msg): if len(msg) == 0: return False elem = dom.document.getElementById("testmain") #elem.innerHTML += '%s<br/>' % msg['event'] main_t = dom.document.getElementById("main_table") if msg['type'] == 'ItemStart': # we start a new directory or what #if msg['itemtype'] == 'Module': tr = make_module_box(msg) main_t.appendChild(tr) elif msg['type'] == 'SendItem': host_elem = dom.document.getElementById(msg['hostkey']) glob.host_pending[msg['hostkey']].insert(0, msg['fullitemname']) count = len(glob.host_pending[msg['hostkey']]) host_elem.childNodes[0].nodeValue = '%s[%s]' % ( glob.host_dict[msg['hostkey']], count) elif msg['type'] == 'HostRSyncRootReady': host_elem = dom.document.getElementById(msg['hostkey']) host_elem.style.background = \ "#00ff00" host_elem.childNodes[0].nodeValue = '%s[0]' % ( glob.host_dict[msg['hostkey']],) elif msg['type'] == 'ReceivedItemOutcome': module_part = get_elem(msg['fullmodulename']) if not module_part: glob.pending.append(msg) return True add_received_item_outcome(msg, module_part) elif msg['type'] == 'TestFinished': text = "FINISHED %s run, %s failures, %s skipped" % (msg['run'], msg['fails'], msg['skips']) glob.finished = True dom.document.title = "Py.test %s" % text dom.document.getElementById("Tests").childNodes[0].nodeValue = \ "Tests [%s]" % text elif msg['type'] == 'FailedTryiter': module_part = get_elem(msg['fullitemname']) if not module_part: glob.pending.append(msg) return True tr = create_elem("tr") td = create_elem("td") a = create_elem("a") a.setAttribute("href", "javascript:show_traceback('%s')" % ( msg['fullitemname'],)) txt = create_text_elem("- FAILED TO LOAD MODULE") a.appendChild(txt) td.appendChild(a) tr.appendChild(td) module_part.appendChild(tr) item_name = msg['fullitemname'] exported_methods.show_fail(item_name, fail_come_back) elif msg['type'] == 'SkippedTryiter': module_part = get_elem(msg['fullitemname']) if not module_part: glob.pending.append(msg) return True tr = create_elem("tr") td = create_elem("td") txt = create_text_elem("- skipped (%s)" % (msg['reason'],)) td.appendChild(txt) tr.appendChild(td) module_part.appendChild(tr) elif msg['type'] == 'RsyncFinished': glob.rsync_done = True elif msg['type'] == 'InterruptedExecution': show_interrupt() elif msg['type'] == 'CrashedExecution': show_crash() if glob.data_empty: mbox = dom.document.getElementById('messagebox') scroll_down_if_needed(mbox) return True