- Timestamp:
- 2011-07-01 09:25:23 (12 years ago)
- Location:
- 2011/26
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/26/build_games.py
r2359 r2387 7 7 from glob import * 8 8 from subprocess import * 9 from xml.dom.minidom import Document9 from datetime import * 10 10 11 11 12 report_location = "\\\\eppu.it.jyu.fi\\kurssit\\npo\\temp"13 12 output_dir = abspath("pelit") 13 build_result_dir = abspath("build") 14 14 lib_dir_x86 = abspath('lib\\x86') 15 15 personal_dirs = [d for d in os.listdir(".") if isdir(d) and d not in ("lib", basename(output_dir), ".svn")] 16 16 projects_that_did_not_build = [] 17 report = Document()18 table = None19 17 msbuild = "msbuild" 20 18 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 """34 19 35 20 … … 52 37 os.mkdir(join(output_dir, d)) 53 38 39 def create_build_result_directory(): 40 if not exists(build_result_dir): 41 os.mkdir(build_result_dir) 42 43 54 44 def build_games(): 55 45 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) 57 51 58 52 59 def addElement(parent, name): 60 node = report.createElement(name) 61 parent.appendChild(node) 62 return node 53 counter = 1 63 54 64 55 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 56 def 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 70 67 71 68 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): 69 def build_games_in_personal_dir(personal_dir, time_of_update): 83 70 for root, dirs, files in os.walk(personal_dir): 84 71 if '.svn' in dirs: … … 93 80 94 81 success = build(projects[0]) 95 add_to_report(author, project_name, success)82 write_result(author, project_name, success, time_of_update) 96 83 97 84 if success: … … 118 105 119 106 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 table134 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 141 107 142 108 def main(): 143 109 try: 144 110 check_requirements() 145 initialize_report()146 111 create_output_directory() 112 create_build_result_directory() 147 113 build_games() 148 write_report()149 114 except KeyboardInterrupt: 150 115 print "BUILD CANCELLED"
Note: See TracChangeset
for help on using the changeset viewer.