2014-12-24 08:47:14 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2014-12-24 09:06:15 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
import tornado.ioloop
|
|
|
|
import tornado.web
|
|
|
|
import urllib
|
2014-12-24 08:47:14 +00:00
|
|
|
|
2014-12-24 09:06:15 +00:00
|
|
|
class MainHandler(tornado.web.RequestHandler):
|
2014-12-28 04:29:20 +00:00
|
|
|
def get(self, project):
|
|
|
|
try:
|
|
|
|
with open('/tmp/%s-coverage' % project, 'rb') as f:
|
|
|
|
coverage = f.read().strip()
|
2014-12-28 07:06:22 +00:00
|
|
|
n = int(coverage.strip('%'))
|
|
|
|
if n > 80:
|
|
|
|
color = 'brightgreen'
|
|
|
|
else:
|
|
|
|
color = 'yellow'
|
2014-12-28 04:29:20 +00:00
|
|
|
self.redirect(('https://img.shields.io/badge/'
|
2014-12-28 07:06:22 +00:00
|
|
|
'coverage-%s-%s.svg'
|
2014-12-28 04:35:17 +00:00
|
|
|
'?style=flat') %
|
2014-12-28 07:06:22 +00:00
|
|
|
(urllib.quote(coverage), color))
|
2014-12-28 04:29:20 +00:00
|
|
|
except IOError:
|
|
|
|
raise tornado.web.HTTPError(404)
|
2014-12-24 08:47:14 +00:00
|
|
|
|
2014-12-24 09:06:15 +00:00
|
|
|
application = tornado.web.Application([
|
2014-12-28 07:00:29 +00:00
|
|
|
(r"/([a-zA-Z0-9\-_]+)", MainHandler),
|
2014-12-24 09:06:15 +00:00
|
|
|
])
|
2014-12-24 08:47:14 +00:00
|
|
|
|
2014-12-24 09:06:15 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
application.listen(8888, address='127.0.0.1')
|
|
|
|
tornado.ioloop.IOLoop.instance().start()
|