else:
start_response('200 OK', [('Content-type', 'text/html')])
- yield "<html>"
- yield " <head>"
- yield " <title>samba.org build farm</title>"
- yield " <script language='javascript' src='/build_farm.js'></script>"
- yield " <meta name='keywords' contents='Samba SMB CIFS Build Farm'/>"
- yield " <meta name='description' contents='Home of the Samba Build Farm, the automated testing facility.'/>"
+ yield "<html>\n"
+ yield " <head>\n"
+ yield " <title>samba.org build farm</title>\n"
+ yield " <script language='javascript' src='/build_farm.js'></script>\n"
+ yield " <meta name='keywords' contents='Samba SMB CIFS Build Farm'/>\n"
+ yield " <meta name='description' contents='Home of the Samba Build Farm, the automated testing facility.'/>\n"
yield " <meta name='robots' contents='noindex'/>"
yield " <link rel='stylesheet' href='/build_farm.css' type='text/css' media='all'/>"
yield " <link rel='stylesheet' href='http://master.samba.org/samba/style/common.css' type='text/css' media='all'/>"
if __name__ == '__main__':
import optparse
parser = optparse.OptionParser("[options]")
- parser.add_option("--standalone", help="Run as standalone server (useful for debugging)", action="store_true")
parser.add_option("--cachedirname", help="Cache directory name", type=str)
- parser.add_option("--port", help="Port to listen on (in standalone mode) [localhost:8000]", default="localhost:8000", type=str)
+ parser.add_option("--port", help="Port to listen on [localhost:8000]", default="localhost:8000", type=str)
opts, args = parser.parse_args()
buildfarm = CachingBuildFarm(cachedirname=opts.cachedirname)
buildApp = BuildFarmApp(buildfarm)
- if opts.standalone:
- from wsgiref.simple_server import make_server
-
- def standaloneApp(environ, start_response):
- if environ['PATH_INFO']:
- dir = os.path.join(os.path.dirname(__file__))
- if re.match("^/[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)?", environ['PATH_INFO']):
- static_file = "%s/%s" % (dir, environ['PATH_INFO'])
- if os.path.exists(static_file):
- tab = environ['PATH_INFO'].split('.')
- if len(tab) > 1:
- extension = tab[-1]
- import mimetypes
- mimetypes.init()
- type = mimetypes.types_map[".%s" % extension]
- start_response('200 OK', [('Content-type', type)])
- data = open(static_file, 'rb').read()
- yield data
- return
- yield "".join(buildApp(environ, start_response))
- try:
- (address, port) = opts.port.rsplit(":", 1)
- except ValueError:
- address = "localhost"
- port = opts.port
- httpd = make_server(address, int(port), standaloneApp)
- print "Serving on %s:%d..." % (address, int(port))
- httpd.serve_forever()
+ from wsgiref.simple_server import make_server
+
+ def standaloneApp(environ, start_response):
+ if environ['PATH_INFO']:
+ dir = os.path.join(os.path.dirname(__file__))
+ if re.match("^/[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)?", environ['PATH_INFO']):
+ static_file = "%s/%s" % (dir, environ['PATH_INFO'])
+ if os.path.exists(static_file):
+ tab = environ['PATH_INFO'].split('.')
+ if len(tab) > 1:
+ extension = tab[-1]
+ import mimetypes
+ mimetypes.init()
+ type = mimetypes.types_map[".%s" % extension]
+ start_response('200 OK', [('Content-type', type)])
+ data = open(static_file, 'rb').read()
+ yield data
+ return
+ yield "".join(buildApp(environ, start_response))
+ try:
+ (address, port) = opts.port.rsplit(":", 1)
+ except ValueError:
+ address = "localhost"
+ port = opts.port
+ httpd = make_server(address, int(port), standaloneApp)
+ print "Serving on %s:%d..." % (address, int(port))
+ httpd.serve_forever()