<s> from gevent import monkey <EOL> monkey . patch_all ( ) <EOL> import sys <EOL> import click <EOL> from bottle import static_file , Bottle , run , view <EOL> from bottle import TEMPLATE_PATH as T <EOL> from bottle . ext . websocket import GeventWebSocketServer <EOL> from bottle . ext . auth . decorator import login <EOL> from gevent . pywsgi import WSGIServer <EOL> from geventwebsocket . handler import WebSocketHandler <EOL> from beaker . middleware import SessionMiddleware <EOL> from mining . controllers . api import api_app <EOL> from mining . controllers . data import data_app <EOL> from mining . utils import conf <EOL> from mining . auth import auth <EOL> from mining . settings import TEMPLATE_PATH , STATIC_PATH <EOL> from mining . celeryc import celery_app <EOL> from mining . bin . scheduler import scheduler_app <EOL> from mining . bin . demo . build_admin import build <EOL> reload ( sys ) <EOL> sys . setdefaultencoding ( '<STR_LIT:utf-8>' ) <EOL> T . insert ( <NUM_LIT:0> , TEMPLATE_PATH ) <EOL> session_opts = { <EOL> '<STR_LIT>' : '<STR_LIT:file>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : True <EOL> } <EOL> app = SessionMiddleware ( Bottle ( ) , session_opts ) <EOL> app . wrap_app . mount ( '<STR_LIT>' , api_app ) <EOL> app . wrap_app . mount ( '<STR_LIT>' , data_app ) <EOL> app . wrap_app . install ( auth ) <EOL> @ app . wrap_app . route ( '<STR_LIT>' , name = '<STR_LIT>' ) <EOL> def static ( path ) : <EOL> yield static_file ( path , root = STATIC_PATH ) <EOL> @ app . wrap_app . route ( '<STR_LIT:/>' ) <EOL> @ login ( ) <EOL> @ view ( '<STR_LIT>' ) <EOL> def index ( ) : <EOL> return { '<STR_LIT>' : app . wrap_app . get_url , <EOL> '<STR_LIT>' : conf ( '<STR_LIT>' ) [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : conf ( '<STR_LIT>' ) [ '<STR_LIT>' ] } <EOL> @ app . wrap_app . route ( '<STR_LIT>' ) <EOL> @ view ( '<STR_LIT>' ) <EOL> def login ( ) : <EOL> return { '<STR_LIT>' : app . wrap_app . get_url , <EOL> '<STR_LIT>' : conf ( '<STR_LIT>' ) [ '<STR_LIT>' ] } <EOL> @ click . group ( ) <EOL> def cmds ( ) : <EOL> pass <EOL> @ cmds . command ( ) <EOL> @ click . option ( '<STR_LIT>' , type = int , help = u'<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , type = str , help = u'<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , default = False , <EOL> help = u'<STR_LIT>' ) <EOL> def runserver ( port , ip , debug ) : <EOL> if debug is None : <EOL> server = WSGIServer ( ( ip , port ) , app , handler_class = WebSocketHandler ) <EOL> server . serve_forever ( ) <EOL> click . echo ( u'<STR_LIT>' . format ( ip , port ) ) <EOL> run ( app = app , host = ip , port = port , debug = debug , <EOL> reloader = True , server = GeventWebSocketServer ) <EOL> @ cmds . command ( ) <EOL> @ click . option ( '<STR_LIT>' , type = int , default = <NUM_LIT:4> , <EOL> help = """<STR_LIT>""" ) <EOL> def celery ( concurrency ) : <EOL> click . echo ( u'<STR_LIT>' ) <EOL> args = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" . format ( concurrency ) ] <EOL> celery_app . start ( args ) <EOL> @ cmds . command ( ) <EOL> def scheduler ( ) : <EOL> click . echo ( u'<STR_LIT>' ) <EOL> scheduler_app ( ) <EOL> @ cmds . command ( ) <EOL> @ click . option ( '<STR_LIT>' , type = int , default = <NUM_LIT:0> , <EOL> help = "<STR_LIT>" ) <EOL> def build_demo ( level ) : <EOL> click . echo ( u'<STR_LIT>' ) <EOL> build ( level ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> default_map = { "<STR_LIT>" : conf ( '<STR_LIT>' ) } <EOL> default_map [ "<STR_LIT>" ] [ "<STR_LIT>" ] = False <EOL> cmds ( default_map = default_map ) </s>
