@@ -1076,33 +1076,43 @@ def idle(self):
10761076
10771077 if port :
10781078 import cherrypy #user can ignore installing this mudole if now need for http reporting
1079- conf = {'global' :
1080- {
1081- "server.socket_host" : '0.0.0.0' ,
1082- "server.socket_port" : port
1083- },
1084- 'log.screen' : False
1085- }
1086- import cherrypy
10871079 class root :
1088- def __init__ (self , reporter ):
1080+ def __init__ (self , reporter , bug_reporter ):
10891081 self .reporter = reporter
1082+ self .bug_reporter = bug_reporter
10901083
10911084 @cherrypy .expose
10921085 def index (self ):
10931086 res = '''<html style="weidth:100%"><body><h1>Bugs</h1><hr>
10941087 <b>what is this page?</b> this project is using a simple
10951088 web server to report bugs(exceptions) that found in a running program.
1096- <h2>Bug logs</h2><pre language="json" style="weidth:100%;overflow:auto">''' + html .escape (self .reporter .dumps ())+ '</pre></body></html>'
1089+ <h2>Bug logs</h2><pre language="json" style="weidth:100%;overflow:auto">''' + html .escape (self .bug_reporter .dumps ())+ '</pre></body></html>'
10971090 return res
10981091
1092+ @cherrypy .expose
1093+ def build_state (self ):
1094+ cherrypy .response .headers ['Content-Type' ] = "image/svg+xml;charset=utf-8"
1095+ if self .reporter .data ['bugs_count' ]> 0 :
1096+ return open ('Docs/build faling.svg' , 'rb' )
1097+ else :
1098+ return open ('Docs/build passing.svg' , 'rb' )
1099+
10991100 @cherrypy .expose
11001101 @cherrypy .tools .json_out ()
11011102 def json (self ):
1102- return self .reporter .reports
1103+ return self .bug_reporter .reports
11031104
1105+
1106+ cherrypy .log .access_log .propagate = False
1107+ cherrypy .tree .mount (root (reporter , bug_reporter ),'/' )
1108+ conf = {'global' :
1109+ {
1110+ "server.socket_host" : '0.0.0.0' ,
1111+ "server.socket_port" : port ,
1112+ 'log.screen' : False
1113+ }
1114+ }
11041115 cherrypy .config .update (conf )
1105- cherrypy .tree .mount (root (bug_reporter ),'/' )
11061116 cherrypy .engine .start ()
11071117 web_reporter = True
11081118
0 commit comments