#NEWLINE# def configureServer( test = False , plugins = None , curConfig = None ) : #NEWLINE# #INDENT# '\n    Function to setup the cherrypy server. It configures it, but does\n    not actually start it.\n\n    :param test: Set to True when running in the tests.\n    :type test: bool\n    :param plugins: If you wish to start the server with a custom set of\n                    plugins, pass this as a list of plugins to load. Otherwise,\n                    will use the PLUGINS_ENABLED setting value from the db.\n    :param curConfig: The configuration dictionary to update.\n    ' #NEWLINE# if ( test is None ) : #NEWLINE# #INDENT# curConfig = config . getConfig ( ) #NEWLINE# #UNINDENT# curStaticRoot = constants . STATIC_ROOT_DIR #NEWLINE# appconf = { #NEWLINE# #INDENT# '/' : { #NEWLINE# #INDENT# 'request.dispatch' : cherrypy . dispatch . MethodDispatcher ( ) , #NEWLINE# 'tools.staticdir.root' : curStaticRoot , #NEWLINE# 'request.show_tracebacks' : test , #NEWLINE# 'request.methods_with_bodies' : ( 'POST' , 'PUT' , 'PATCH' ) , #NEWLINE# #UNINDENT# } , #NEWLINE# '/static' : { #NEWLINE# #INDENT# 'tools.staticdir.on' : True , #NEWLINE# 'tools.staticdir.dir' : 'clients/web/static' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# mimetypes . add_type ( 'application/vnd.ms-fontobject' , '.eot' ) #NEWLINE# mimetypes . add_type ( 'application/x-font-ttf' , '.ttf' ) #NEWLINE# mimetypes . add_type ( 'application/font-woff' , '.woff' ) #NEWLINE# if test : #NEWLINE# #INDENT# appconf [ '/src' ] = { #NEWLINE# #INDENT# 'tools.staticdir.on' : True , #NEWLINE# 'tools.staticdir.dir' : 'clients/web/src' , #NEWLINE# #UNINDENT# } #NEWLINE# appconf [ '/test' ] = { #NEWLINE# #INDENT# 'tools.staticdir.on' : True , #NEWLINE# 'tools.staticdir.dir' : 'clients/web/test' , #NEWLINE# #UNINDENT# } #NEWLINE# appconf [ '/clients' ] = { #NEWLINE# #INDENT# 'tools.staticdir.on' : True , #NEWLINE# 'tools.staticdir.dir' : 'clients' , #NEWLINE# #UNINDENT# } #NEWLINE# appconf [ '/plugins' ] = { #NEWLINE# #INDENT# 'tools.staticdir.on' : True , #NEWLINE# 'tools.staticdir.dir' : 'plugins' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# curConfig . update ( appconf ) #NEWLINE# if test : #NEWLINE# #INDENT# curConfig . update ( { #NEWLINE# #INDENT# 'server' : { #NEWLINE# #INDENT# 'mode' : 'testing' , #NEWLINE# 'api_root' : 'api/v1' , #NEWLINE# 'static_root' : 'static' , #NEWLINE# 'api_static_root' : '../static' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# mode = curConfig [ 'server' ] [ 'mode' ] . lower ( ) #NEWLINE# print ( constants . TerminalColor . info ( ( 'Running in mode: ' + mode ) ) ) #NEWLINE# cherrypy . config [ 'engine.autoreload.on' ] = ( mode == 'development' ) #NEWLINE# from girder.api import api_main #NEWLINE# root = webroot . Webroot ( ) #NEWLINE# api_main . addApiToNode ( root ) #NEWLINE# cherrypy . engine . subscribe ( 'start' , girder . events . daemon . start ) #NEWLINE# cherrypy . engine . subscribe ( 'stop' , girder . events . daemon . stop ) #NEWLINE# if ( plugins is None ) : #NEWLINE# #INDENT# settings = model_importer . ModelImporter ( ) . model ( 'setting' ) #NEWLINE# plugins = settings . get ( constants . SettingKey . PLUGINS_ENABLED , default = ( ) ) #NEWLINE# #UNINDENT# plugins = list ( plugin_utilities . getToposortedPlugins ( plugins , curConfig , ignoreMissing = True ) ) #NEWLINE# root . updateHtmlVars ( { #NEWLINE# #INDENT# 'apiRoot' : curConfig [ 'server' ] [ 'api_root' ] , #NEWLINE# 'staticRoot' : curConfig [ 'server' ] [ 'static_root' ] , #NEWLINE# 'plugins' : plugins , #NEWLINE# #UNINDENT# } ) #NEWLINE# apiStaticRoot = curConfig [ 'server' ] . get ( 'api_static_root' , '' ) #NEWLINE# if ( not apiStaticRoot ) : #NEWLINE# #INDENT# apiStaticRoot = curConfig [ 'server' ] [ 'static_root' ] #NEWLINE# #UNINDENT# root . api . v1 . updateHtmlVars ( { #NEWLINE# #INDENT# 'apiRoot' : curConfig [ 'server' ] [ 'api_root' ] , #NEWLINE# 'staticRoot' : apiStaticRoot , #NEWLINE# #UNINDENT# } ) #NEWLINE# ( root , appconf , _ ) = plugin_utilities . loadPlugins ( plugins , root , appconf , root . api . v1 , curConfig = curConfig , buildDag = False ) #NEWLINE# return ( root , appconf )