Changeset 2250


Ignore:
Timestamp:
2011-06-29 09:59:50 (12 years ago)
Author:
tekrjant
Message:

Build report is html.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2011/24/build_games.py

    r2248 r2250  
    99 
    1010 
     11report_location = "\\\\eppu.it.jyu.fi\\kurssit\\npo\\temp" 
    1112output_dir = abspath("pelit") 
    1213lib_dir_x86 = abspath('lib\\x86') 
     
    1415projects_that_did_not_build = [] 
    1516report = Document() 
    16 document_root = "" 
     17table = "" 
    1718 
    1819def check_requirements(): 
     
    3334 
    3435 
    35 def addElement(parent, name, value): 
     36def addElement(parent, name): 
     37        node = report.createElement(name) 
     38        parent.appendChild(node) 
     39        return node 
     40 
     41 
     42def addTextElement(parent, name, value): 
    3643        node = report.createElement(name) 
    3744        parent.appendChild(node) 
    3845        node.appendChild(report.createTextNode(str(value))) 
     46        return node 
    3947 
    4048 
    4149def add_to_report(author, name, success): 
    42         e = report.createElement("game") 
    43         document_root.appendChild(e) 
    44  
    45         addElement(e, "author", author) 
    46         addElement(e, "name", name) 
    47         addElement(e, "success", success) 
     50        style = "success" 
     51        if not success: 
     52                style = "fail" 
     53        tr = addElement(table, "tr") 
     54        tr.setAttribute("class", style) 
     55        addTextElement(tr, "td", author) 
     56        addTextElement(tr, "td", name) 
    4857 
    4958 
     
    8796 
    8897def initialize_report(): 
    89         global document_root 
    90         document_root = report.createElement("games") 
    91         report.appendChild(document_root) 
     98        html = addElement(report, "html") 
     99 
     100        refresh_tag = addElement(html, "meta") 
     101        refresh_tag.setAttribute("http-equiv", "refresh") 
     102        refresh_tag.setAttribute("content", "30") 
     103 
     104        head = addElement(html, "head") 
     105        css_link = addElement(head, "link") 
     106        css_link.setAttribute("href", "build.css") 
     107        css_link.setAttribute("rel", "StyleSheet") 
     108        css_link.setAttribute("type", "text/css") 
     109        addTextElement(head, "title", "Build") 
     110 
     111        body = addElement(html, "body") 
     112        global table 
     113        table = addElement(body, "table") 
    92114         
    93115 
    94116def write_report(): 
    95         with open("build_report.xml", "w") as f: 
     117        with open(join(report_location, "build_report.html"), "w") as f: 
    96118                f.write(report.toprettyxml()) 
    97119 
Note: See TracChangeset for help on using the changeset viewer.