mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This is lame, but seems to fix the timeout problem http://stackoverflow.com/questions/2685089/cherrypy-and-concurrency Review URL: https://codereview.chromium.org/700213005
82 lines
2.8 KiB
Python
Executable File
82 lines
2.8 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# Copyright 2014 The Chromium Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
import argparse
|
|
import cherrypy
|
|
import json
|
|
import os
|
|
import staticdirindex
|
|
from skypy.paths import Paths
|
|
import skypy.configuration as configuration
|
|
|
|
def skydir(section="", dir="", path="", **kwargs):
|
|
if cherrypy.request.params.get('format') is None:
|
|
return '<sky><import src="/sky/examples/file-browser.sky"/><file-browser/></sky>'
|
|
result = dict()
|
|
result['directories'] = []
|
|
result['files'] = []
|
|
for _, dir_names, file_names in os.walk(path.rstrip(r"\/")):
|
|
for dir_name in sorted(dir_names):
|
|
result["directories"].append(dir_name)
|
|
|
|
del dir_names[:] # limit to one level
|
|
|
|
for file_name in sorted(file_names):
|
|
result["files"].append(file_name)
|
|
return json.dumps(result)
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description='Sky development server')
|
|
parser.add_argument('-v', '--verbose', action='store_true',
|
|
help='Enable logging to the console.')
|
|
parser.add_argument('app_path', type=str)
|
|
parser.add_argument('port', type=int)
|
|
configuration.add_arguments(parser)
|
|
args = parser.parse_args()
|
|
|
|
log_dir = os.path.abspath(os.getcwd())
|
|
|
|
paths = Paths(os.path.join('out', args.configuration))
|
|
|
|
config = {
|
|
'global': {
|
|
# Cherrypy appears to just drop requests if it doesn't have
|
|
# a thread to service them, so set our thread_pool high enough
|
|
# so that a z620 can run all the tests w/o timeouts.
|
|
'server.thread_pool': 30,
|
|
'server.socket_port': args.port,
|
|
'tools.staticdir.content_types' : {
|
|
'sky': 'text/sky',
|
|
},
|
|
'log.screen': args.verbose,
|
|
'log.access_log': os.path.join(log_dir, 'access_log.txt'),
|
|
# This causes some strange python exception??
|
|
# 'log.error_log': os.path.join(log_dir, 'error_log.txt'),
|
|
},
|
|
'/': {
|
|
'tools.staticdir.on': True,
|
|
'tools.staticdir.dir': os.path.abspath(args.app_path),
|
|
'tools.staticdir.indexlister': skydir,
|
|
},
|
|
'/mojo/public': {
|
|
'tools.staticdir.on': True,
|
|
'tools.staticdir.dir': os.path.join(paths.gen_root, 'mojo', 'public'),
|
|
},
|
|
'/mojo/services': {
|
|
'tools.staticdir.on': True,
|
|
'tools.staticdir.dir': os.path.join(paths.gen_root, 'mojo', 'services'),
|
|
},
|
|
'/sky/services': {
|
|
'tools.staticdir.on': True,
|
|
'tools.staticdir.dir': os.path.join(paths.gen_root, 'sky', 'services'),
|
|
},
|
|
}
|
|
cherrypy.quickstart(config=config)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|