The Gatekeeper, or a project gating system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.8 KiB

# Copyright 2012 Hewlett-Packard Development Company, L.P.
# Copyright 2013 OpenStack Foundation
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import logging
import threading
from paste import httpserver
from webob import Request
class WebApp(threading.Thread):
log = logging.getLogger("zuul.WebApp")
def __init__(self, scheduler, port=8001):
self.scheduler = scheduler
self.port = port
def run(self):
self.server = httpserver.serve(, host='',
port=self.port, start_loop=False)
def stop(self):
def app(self, environ, start_response):
request = Request(environ)
if request.path == '/status.json':
ret = self.scheduler.formatStatusJSON()
self.log.exception("Exception formatting status:")
start_response('200 OK', [('content-type', 'application/json'),
('Access-Control-Allow-Origin', '*')])
return [ret]
start_response('404 Not Found', [('content-type', 'text/plain')])
return ['Not found.']