Changeset 2387 for 2011/26


Ignore:
Timestamp:
2011-07-01 09:25:23 (12 years ago)
Author:
tekrjant
Message:

Toinen skripti joka tekee raportin, jotta voidaan päivittää tiheämmin.

Location:
2011/26
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • 2011/26/build_games.py

    r2359 r2387  
    77from glob import * 
    88from subprocess import * 
    9 from xml.dom.minidom import Document 
     9from datetime import * 
    1010 
    1111 
    12 report_location = "\\\\eppu.it.jyu.fi\\kurssit\\npo\\temp" 
    1312output_dir = abspath("pelit") 
     13build_result_dir = abspath("build") 
    1414lib_dir_x86 = abspath('lib\\x86') 
    1515personal_dirs = [d for d in os.listdir(".") if isdir(d) and d not in ("lib", basename(output_dir), ".svn")] 
    1616projects_that_did_not_build = [] 
    17 report = Document() 
    18 table = None 
    1917msbuild = "msbuild" 
    2018 
    21 CSS = """ 
    22 tr { 
    23   color: white; 
    24 } 
    25  
    26 .success { 
    27   background-color: green; 
    28 } 
    29  
    30 .fail { 
    31   background-color: red; 
    32 } 
    33 """ 
    3419 
    3520 
     
    5237                        os.mkdir(join(output_dir, d)) 
    5338 
     39def create_build_result_directory(): 
     40        if not exists(build_result_dir): 
     41                os.mkdir(build_result_dir) 
     42 
     43 
    5444def build_games(): 
    5545        for d in personal_dirs: 
    56                 build_games_in_personal_dir(abspath(d)) 
     46                path = abspath(d) 
     47                time_of_update = datetime.now() 
     48                if exists(join(path, ".svn")): 
     49                        call("svn update " + path, shell=True) 
     50                build_games_in_personal_dir(path, time_of_update) 
    5751 
    5852 
    59 def addElement(parent, name): 
    60         node = report.createElement(name) 
    61         parent.appendChild(node) 
    62         return node 
     53counter = 1 
    6354 
    6455 
    65 def addTextElement(parent, name, value): 
    66         node = report.createElement(name) 
    67         parent.appendChild(node) 
    68         node.appendChild(report.createTextNode(str(value))) 
    69         return node 
     56def write_result(author, name, success, time_of_update): 
     57        global counter 
     58        with open(join(build_result_dir, str(counter)+".txt"), "w") as f: 
     59                f.write(author+"\n") 
     60                f.write(name+"\n") 
     61                result = "success" 
     62                if not success: 
     63                        result = "fail" 
     64                f.write(result+"\n") 
     65                f.write(str(time_of_update)+"\n") 
     66        counter += 1 
    7067 
    7168 
    72 def add_to_report(author, name, success): 
    73         style = "success" 
    74         if not success: 
    75                 style = "fail" 
    76         tr = addElement(table, "tr") 
    77         tr.setAttribute("class", style) 
    78         addTextElement(tr, "td", author) 
    79         addTextElement(tr, "td", name) 
    80  
    81  
    82 def build_games_in_personal_dir(personal_dir): 
     69def build_games_in_personal_dir(personal_dir, time_of_update): 
    8370        for root, dirs, files in os.walk(personal_dir): 
    8471                if '.svn' in dirs: 
     
    9380 
    9481                        success = build(projects[0]) 
    95                         add_to_report(author, project_name, success) 
     82                        write_result(author, project_name, success, time_of_update) 
    9683 
    9784                        if success: 
     
    118105 
    119106 
    120 def initialize_report(): 
    121         html = addElement(report, "html") 
    122  
    123         refresh_tag = addElement(html, "meta") 
    124         refresh_tag.setAttribute("http-equiv", "refresh") 
    125         refresh_tag.setAttribute("content", "30") 
    126  
    127         head = addElement(html, "head") 
    128         style = addTextElement(head, "style", CSS) 
    129         style.setAttribute("type", "text/css") 
    130         addTextElement(head, "title", "Build") 
    131  
    132         body = addElement(html, "body") 
    133         global table 
    134         table = addElement(body, "table") 
    135  
    136  
    137 def write_report(): 
    138         with open(join(report_location, "build_report.html"), "w") as f: 
    139                 f.write(report.toprettyxml()) 
    140  
    141107 
    142108def main(): 
    143109        try: 
    144110                check_requirements() 
    145                 initialize_report() 
    146111                create_output_directory() 
     112                create_build_result_directory() 
    147113                build_games() 
    148                 write_report() 
    149114        except KeyboardInterrupt: 
    150115                print "BUILD CANCELLED" 
Note: See TracChangeset for help on using the changeset viewer.