def __init__(self, host, port): # Now import the girder modules. If this fails, it's up to the # administrator to make sure Girder is installed and on the PYTHONPATH. import girder.events from girder import constants from girder.api import api_main from girder import constants from girder.utility import plugin_utilities, model_importer self.root_dir = constants.ROOT_DIR api_main.addApiToNode(self) cherrypy.engine.subscribe("start", girder.events.daemon.start) cherrypy.engine.subscribe("stop", girder.events.daemon.stop) plugins = model_importer.ModelImporter().model('setting').get( constants.SettingKey.PLUGINS_ENABLED, default=()) plugin_utilities.loadPlugins(plugins, self, cherrypy.config) self.config = { "/": { "request.dispatch": cherrypy.dispatch.MethodDispatcher(), "tools.staticdir.root": self.root_dir }, "/static": { "tools.staticdir.on": "True", "tools.staticdir.dir": "clients/web/static" } }
def setup(test=False): """ Function to setup the cherrypy server. It configures it, but does not actually start it. :param test: Set to True when running in the tests. :type test: bool """ cfgs = ('auth', 'db', 'server') cfgs = [os.path.join(constants.ROOT_DIR, 'girder', 'conf', 'local.%s.cfg' % c) for c in cfgs] for cfg in cfgs: cherrypy.config.update(cfg) appconf = { '/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), 'tools.staticdir.root': constants.ROOT_DIR, 'request.show_tracebacks': test }, '/static': { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'clients/web/static' } } cherrypy.config.update(appconf) if test: # Force the mode to be 'testing' cherrypy.config.update({'server': {'mode': 'testing'}}) # Don't import this until after the configs have been read; some module # initialization code requires the configuration to be set up. from girder.api import api_main root = Webroot() api_main.addApiToNode(root) if cherrypy.config['server']['mode'] is 'development': dev_endpoints.addDevEndpoints(root, appconf) # pragma: no cover cherrypy.engine.subscribe('start', girder.events.daemon.start) cherrypy.engine.subscribe('stop', girder.events.daemon.stop) settings = model_importer.ModelImporter().model('setting') plugins = settings.get(constants.SettingKey.PLUGINS_ENABLED, default=()) plugin_utilities.loadPlugins(plugins, root, appconf) application = cherrypy.tree.mount(root, '/', appconf) for cfg in cfgs: application.merge(cfg) if test: application.merge({'server': {'mode': 'testing'}}) return application
def configureServer(test=False, plugins=None, curConfig=None): """ Function to setup the cherrypy server. It configures it, but does not actually start it. :param test: Set to True when running in the tests. :type test: bool :param plugins: If you wish to start the server with a custom set of plugins, pass this as a list of plugins to load. Otherwise, will use the PLUGINS_ENABLED setting value from the db. :param curConfig: The configuration dictionary to update. """ if curConfig is None: curConfig = config.getConfig() appconf = { '/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), 'request.show_tracebacks': test, 'request.methods_with_bodies': ('POST', 'PUT', 'PATCH'), 'response.headers.server': 'Girder %s' % __version__, 'error_page.default': _errorDefault } } # Add MIME types for serving Fontello files from staticdir; # these may be missing or incorrect in the OS mimetypes.add_type('application/vnd.ms-fontobject', '.eot') mimetypes.add_type('application/x-font-ttf', '.ttf') mimetypes.add_type('application/font-woff', '.woff') if test: appconf['/src'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'clients/web/src', } appconf['/test'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'clients/web/test', } appconf['/clients'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'clients' } appconf['/plugins'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'plugins', } curConfig.update(appconf) if test: # Force some config params in testing mode curConfig.update({ 'server': { 'mode': 'testing', 'api_root': 'api/v1', 'static_root': 'static', 'api_static_root': '../static', 'cherrypy_server': True } }) mode = curConfig['server']['mode'].lower() logprint.info('Running in mode: ' + mode) cherrypy.config['engine.autoreload.on'] = mode == 'development' # Don't import this until after the configs have been read; some module # initialization code requires the configuration to be set up. from girder.api import api_main root = webroot.Webroot() api_main.addApiToNode(root) cherrypy.engine.subscribe('start', girder.events.daemon.start) cherrypy.engine.subscribe('stop', girder.events.daemon.stop) if plugins is None: settings = model_importer.ModelImporter().model('setting') plugins = settings.get(constants.SettingKey.PLUGINS_ENABLED, default=()) plugins = list( plugin_utilities.getToposortedPlugins(plugins, ignoreMissing=True)) _configureStaticRoutes(root, plugins) girder.events.bind( 'model.setting.save.after', '_updateStaticRoutesIfModified', functools.partial(_configureStaticRoutes, root, plugins)) root, appconf, _ = plugin_utilities.loadPlugins(plugins, root, appconf, root.api.v1, buildDag=False) return root, appconf
def configureServer(test=False, plugins=None, curConfig=None): """ Function to setup the cherrypy server. It configures it, but does not actually start it. :param test: Set to True when running in the tests. :type test: bool :param plugins: If you wish to start the server with a custom set of plugins, pass this as a list of plugins to load. Otherwise, will use the PLUGINS_ENABLED setting value from the db. :param curConfig: The configuration dictionary to update. """ if curConfig is None: curConfig = config.getConfig() routeTable = loadRouteTable() appconf = { '/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), 'request.show_tracebacks': test, 'request.methods_with_bodies': ('POST', 'PUT', 'PATCH'), 'response.headers.server': 'Girder %s' % __version__, 'error_page.default': _errorDefault } } # Add MIME types for serving Fontello files from staticdir; # these may be missing or incorrect in the OS mimetypes.add_type('application/vnd.ms-fontobject', '.eot') mimetypes.add_type('application/x-font-ttf', '.ttf') mimetypes.add_type('application/font-woff', '.woff') if test: appconf['/src'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'clients/web/src', } appconf['/test'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'clients/web/test', } appconf['/clients'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'clients' } appconf['/plugins'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'plugins', } curConfig.update(appconf) if test: # Force some config params in testing mode curConfig.update({ 'server': { 'mode': 'testing', 'api_root': 'api/v1', 'static_root': 'static', 'api_static_root': '../static' } }) mode = curConfig['server']['mode'].lower() logprint.info('Running in mode: ' + mode) cherrypy.config['engine.autoreload.on'] = mode == 'development' # Don't import this until after the configs have been read; some module # initialization code requires the configuration to be set up. from girder.api import api_main root = webroot.Webroot() api_main.addApiToNode(root) cherrypy.engine.subscribe('start', girder.events.daemon.start) cherrypy.engine.subscribe('stop', girder.events.daemon.stop) if plugins is None: settings = model_importer.ModelImporter().model('setting') plugins = settings.get(constants.SettingKey.PLUGINS_ENABLED, default=()) plugins = list( plugin_utilities.getToposortedPlugins(plugins, ignoreMissing=True)) root.updateHtmlVars({ 'apiRoot': curConfig['server']['api_root'], 'staticRoot': os.path.relpath(routeTable[constants.GIRDER_STATIC_ROUTE_ID], routeTable[constants.GIRDER_ROUTE_ID]), 'plugins': plugins }) # Make the staticRoot relative to the api_root, if possible. The api_root # could be relative or absolute, but it needs to be in an absolute form for # relpath to behave as expected. We always expect the api_root to # contain at least two components, but the reference from static needs to # be from only the first component. apiRootBase = os.path.split( os.path.join('/', curConfig['server']['api_root']))[0] root.api.v1.updateHtmlVars({ 'apiRoot': curConfig['server']['api_root'], 'staticRoot': os.path.relpath(routeTable[constants.GIRDER_STATIC_ROUTE_ID], apiRootBase) }) root, appconf, _ = plugin_utilities.loadPlugins(plugins, root, appconf, root.api.v1, buildDag=False) return root, appconf
def setup(test=False, plugins=None): """ Function to setup the cherrypy server. It configures it, but does not actually start it. :param test: Set to True when running in the tests. :type test: bool :param plugins: If you wish to start the server with a custom set of plugins, pass this as a list of plugins to load. Otherwise, will use the PLUGINS_ENABLED setting value from the db. """ cur_config = config.getConfig() appconf = { '/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), 'tools.staticdir.root': constants.ROOT_DIR, 'request.show_tracebacks': test }, '/static': { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'clients/web/static' } } if test: appconf['/src'] = { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'clients/web/src', } appconf['/test'] = { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'clients/web/test', } appconf['/clients'] = { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'clients' } cur_config.update(appconf) if test: # Force some config params in testing mode cur_config.update({ 'server': { 'mode': 'testing', 'api_root': '/api/v1', 'static_root': '/static' } }) # Don't import this until after the configs have been read; some module # initialization code requires the configuration to be set up. from girder.api import api_main root = webroot.Webroot() api_main.addApiToNode(root) if cur_config['server']['mode'] is 'development': dev_endpoints.addDevEndpoints(root, appconf) # pragma: no cover cherrypy.engine.subscribe('start', girder.events.daemon.start) cherrypy.engine.subscribe('stop', girder.events.daemon.stop) if plugins is None: settings = model_importer.ModelImporter().model('setting') plugins = settings.get(constants.SettingKey.PLUGINS_ENABLED, default=()) root.updateHtmlVars({ 'apiRoot': cur_config['server']['api_root'], 'staticRoot': cur_config['server']['static_root'], 'plugins': plugins }) plugin_utilities.loadPlugins(plugins, root, appconf) application = cherrypy.tree.mount(root, '/', appconf) if test: application.merge({'server': {'mode': 'testing'}}) return application
def configureServer(test=False, plugins=None, curConfig=None): """ Function to setup the cherrypy server. It configures it, but does not actually start it. :param test: Set to True when running in the tests. :type test: bool :param plugins: If you wish to start the server with a custom set of plugins, pass this as a list of plugins to load. Otherwise, will use the PLUGINS_ENABLED setting value from the db. :param curConfig: The configuration dictionary to update. """ if curConfig is None: curConfig = config.getConfig() appconf = { '/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), 'request.show_tracebacks': test, 'request.methods_with_bodies': ('POST', 'PUT', 'PATCH'), 'response.headers.server': 'Girder %s' % __version__, 'error_page.default': _errorDefault } } # Add MIME types for serving Fontello files from staticdir; # these may be missing or incorrect in the OS mimetypes.add_type('application/vnd.ms-fontobject', '.eot') mimetypes.add_type('application/x-font-ttf', '.ttf') mimetypes.add_type('application/font-woff', '.woff') if test: appconf['/src'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'clients/web/src', } appconf['/test'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'clients/web/test', } appconf['/clients'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'clients' } appconf['/plugins'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'plugins', } curConfig.update(appconf) if test: # Force some config params in testing mode curConfig.update({'server': { 'mode': 'testing', 'api_root': 'api/v1', 'static_root': 'static', 'api_static_root': '../static', 'cherrypy_server': True }}) mode = curConfig['server']['mode'].lower() logprint.info('Running in mode: ' + mode) cherrypy.config['engine.autoreload.on'] = mode == 'development' # Don't import this until after the configs have been read; some module # initialization code requires the configuration to be set up. from girder.api import api_main root = webroot.Webroot() api_main.addApiToNode(root) cherrypy.engine.subscribe('start', girder.events.daemon.start) cherrypy.engine.subscribe('stop', girder.events.daemon.stop) if plugins is None: settings = model_importer.ModelImporter().model('setting') plugins = settings.get(constants.SettingKey.PLUGINS_ENABLED, default=()) plugins = list(plugin_utilities.getToposortedPlugins(plugins, ignoreMissing=True)) _configureStaticRoutes(root, plugins) girder.events.bind('model.setting.save.after', '_updateStaticRoutesIfModified', functools.partial(_configureStaticRoutes, root, plugins)) root, appconf, _ = plugin_utilities.loadPlugins( plugins, root, appconf, root.api.v1, buildDag=False) return root, appconf
def setup(test=False, plugins=None): """ Function to setup the cherrypy server. It configures it, but does not actually start it. :param test: Set to True when running in the tests. :type test: bool :param plugins: If you wish to start the server with a custom set of plugins, pass this as a list of plugins to load. Otherwise, will use the PLUGINS_ENABLED setting value from the db. """ cur_config = config.getConfig() appconf = { '/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), 'tools.staticdir.root': constants.ROOT_DIR, 'request.show_tracebacks': test }, '/static': { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'clients/web/static' } } if test: appconf['/src'] = { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'clients/web/src', } appconf['/test'] = { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'clients/web/test', } appconf['/clients'] = { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'clients' } cur_config.update(appconf) if test: # Force some config params in testing mode cur_config.update({'server': { 'mode': 'testing', 'api_root': '/api/v1', 'static_root': '/static' }}) # Don't import this until after the configs have been read; some module # initialization code requires the configuration to be set up. from girder.api import api_main root = webroot.Webroot() api_main.addApiToNode(root) if cur_config['server']['mode'] is 'development': dev_endpoints.addDevEndpoints(root, appconf) # pragma: no cover cherrypy.engine.subscribe('start', girder.events.daemon.start) cherrypy.engine.subscribe('stop', girder.events.daemon.stop) if plugins is None: settings = model_importer.ModelImporter().model('setting') plugins = settings.get(constants.SettingKey.PLUGINS_ENABLED, default=()) root.updateHtmlVars({ 'apiRoot': cur_config['server']['api_root'], 'staticRoot': cur_config['server']['static_root'], 'plugins': plugins }) plugin_utilities.loadPlugins(plugins, root, appconf) application = cherrypy.tree.mount(root, '/', appconf) if test: application.merge({'server': {'mode': 'testing'}}) return application
def configureServer(test=False, plugins=None, curConfig=None): """ Function to setup the cherrypy server. It configures it, but does not actually start it. :param test: Set to True when running in the tests. :type test: bool :param plugins: If you wish to start the server with a custom set of plugins, pass this as a list of plugins to load. Otherwise, will use the PLUGINS_ENABLED setting value from the db. :param curConfig: The configuration dictionary to update. """ if curConfig is None: curConfig = config.getConfig() curStaticRoot = constants.STATIC_ROOT_DIR appconf = { '/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), 'tools.staticdir.root': curStaticRoot, 'request.show_tracebacks': test, 'request.methods_with_bodies': ('POST', 'PUT', 'PATCH') }, '/static': { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'clients/web/static' } } if test: appconf['/src'] = { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'clients/web/src', } appconf['/test'] = { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'clients/web/test', } appconf['/clients'] = { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'clients' } appconf['/plugins'] = { 'tools.staticdir.on': 'True', 'tools.staticdir.dir': 'plugins', } curConfig.update(appconf) if test: # Force some config params in testing mode curConfig.update({ 'server': { 'mode': 'testing', 'api_root': 'api/v1', 'static_root': 'static', 'api_static_root': '../static' } }) # Don't import this until after the configs have been read; some module # initialization code requires the configuration to be set up. from girder.api import api_main root = webroot.Webroot() api_main.addApiToNode(root) cherrypy.engine.subscribe('start', girder.events.daemon.start) cherrypy.engine.subscribe('stop', girder.events.daemon.stop) if plugins is None: settings = model_importer.ModelImporter().model('setting') plugins = settings.get(constants.SettingKey.PLUGINS_ENABLED, default=()) root.updateHtmlVars({ 'apiRoot': curConfig['server']['api_root'], 'staticRoot': curConfig['server']['static_root'], 'plugins': plugins }) apiStaticRoot = curConfig['server'].get('api_static_root', '') if not apiStaticRoot: apiStaticRoot = curConfig['server']['static_root'] root.api.v1.updateHtmlVars({ 'apiRoot': curConfig['server']['api_root'], 'staticRoot': apiStaticRoot, }) root, appconf, _ = plugin_utilities.loadPlugins(plugins, root, appconf, root.api.v1, curConfig=curConfig) return root, appconf
def configureServer(test=False, plugins=None, curConfig=None): """ Function to setup the cherrypy server. It configures it, but does not actually start it. :param test: Set to True when running in the tests. :type test: bool :param plugins: If you wish to start the server with a custom set of plugins, pass this as a list of plugins to load. Otherwise, will use the PLUGINS_ENABLED setting value from the db. :param curConfig: The configuration dictionary to update. """ if curConfig is None: curConfig = config.getConfig() curStaticRoot = constants.STATIC_ROOT_DIR appconf = { "/": { "request.dispatch": cherrypy.dispatch.MethodDispatcher(), "tools.staticdir.root": curStaticRoot, "request.show_tracebacks": test, "request.methods_with_bodies": ("POST", "PUT", "PATCH"), }, "/static": {"tools.staticdir.on": "True", "tools.staticdir.dir": "clients/web/static"}, } if test: appconf["/src"] = {"tools.staticdir.on": "True", "tools.staticdir.dir": "clients/web/src"} appconf["/test"] = {"tools.staticdir.on": "True", "tools.staticdir.dir": "clients/web/test"} appconf["/clients"] = {"tools.staticdir.on": "True", "tools.staticdir.dir": "clients"} appconf["/plugins"] = {"tools.staticdir.on": "True", "tools.staticdir.dir": "plugins"} curConfig.update(appconf) if test: # Force some config params in testing mode curConfig.update( { "server": { "mode": "testing", "api_root": "api/v1", "static_root": "static", "api_static_root": "../static", } } ) # Don't import this until after the configs have been read; some module # initialization code requires the configuration to be set up. from girder.api import api_main root = webroot.Webroot() api_main.addApiToNode(root) cherrypy.engine.subscribe("start", girder.events.daemon.start) cherrypy.engine.subscribe("stop", girder.events.daemon.stop) if plugins is None: settings = model_importer.ModelImporter().model("setting") plugins = settings.get(constants.SettingKey.PLUGINS_ENABLED, default=()) root.updateHtmlVars( { "apiRoot": curConfig["server"]["api_root"], "staticRoot": curConfig["server"]["static_root"], "plugins": plugins, } ) apiStaticRoot = curConfig["server"].get("api_static_root", "") if not apiStaticRoot: apiStaticRoot = curConfig["server"]["static_root"] root.api.v1.updateHtmlVars({"apiRoot": curConfig["server"]["api_root"], "staticRoot": apiStaticRoot}) root, appconf, _ = plugin_utilities.loadPlugins(plugins, root, appconf, root.api.v1, curConfig=curConfig) return root, appconf
def configureServer(test=False, plugins=None, curConfig=None): """ Function to setup the cherrypy server. It configures it, but does not actually start it. :param test: Set to True when running in the tests. :type test: bool :param plugins: If you wish to start the server with a custom set of plugins, pass this as a list of plugins to load. Otherwise, will use the PLUGINS_ENABLED setting value from the db. :param curConfig: The configuration dictionary to update. """ if curConfig is None: curConfig = config.getConfig() curStaticRoot = constants.STATIC_ROOT_DIR appconf = { '/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), 'tools.staticdir.root': curStaticRoot, 'request.show_tracebacks': test, 'request.methods_with_bodies': ('POST', 'PUT', 'PATCH') }, '/static': { 'tools.staticdir.on': True, 'tools.staticdir.dir': 'clients/web/static' } } if test: appconf['/src'] = { 'tools.staticdir.on': True, 'tools.staticdir.dir': 'clients/web/src', } appconf['/test'] = { 'tools.staticdir.on': True, 'tools.staticdir.dir': 'clients/web/test', } appconf['/clients'] = { 'tools.staticdir.on': True, 'tools.staticdir.dir': 'clients' } appconf['/plugins'] = { 'tools.staticdir.on': True, 'tools.staticdir.dir': 'plugins', } curConfig.update(appconf) if test: # Force some config params in testing mode curConfig.update({'server': { 'mode': 'testing', 'api_root': 'api/v1', 'static_root': 'static', 'api_static_root': '../static' }}) mode = curConfig['server']['mode'].lower() print(constants.TerminalColor.info('Running in mode: ' + mode)) cherrypy.config['engine.autoreload.on'] = mode == 'development' # Don't import this until after the configs have been read; some module # initialization code requires the configuration to be set up. from girder.api import api_main root = webroot.Webroot() api_main.addApiToNode(root) cherrypy.engine.subscribe('start', girder.events.daemon.start) cherrypy.engine.subscribe('stop', girder.events.daemon.stop) if plugins is None: settings = model_importer.ModelImporter().model('setting') plugins = settings.get(constants.SettingKey.PLUGINS_ENABLED, default=()) root.updateHtmlVars({ 'apiRoot': curConfig['server']['api_root'], 'staticRoot': curConfig['server']['static_root'], 'plugins': plugins }) apiStaticRoot = curConfig['server'].get('api_static_root', '') if not apiStaticRoot: apiStaticRoot = curConfig['server']['static_root'] root.api.v1.updateHtmlVars({ 'apiRoot': curConfig['server']['api_root'], 'staticRoot': apiStaticRoot, }) root, appconf, _ = plugin_utilities.loadPlugins( plugins, root, appconf, root.api.v1, curConfig=curConfig) return root, appconf
def configureServer(test=False, plugins=None, curConfig=None): """ Function to setup the cherrypy server. It configures it, but does not actually start it. :param test: Set to True when running in the tests. :type test: bool :param plugins: If you wish to start the server with a custom set of plugins, pass this as a list of plugins to load. Otherwise, will use the PLUGINS_ENABLED setting value from the db. :param curConfig: The configuration dictionary to update. """ if curConfig is None: curConfig = config.getConfig() curStaticRoot = constants.STATIC_ROOT_DIR appconf = { "/": { "request.dispatch": cherrypy.dispatch.MethodDispatcher(), "tools.staticdir.root": curStaticRoot, "request.show_tracebacks": test, "request.methods_with_bodies": ("POST", "PUT", "PATCH"), }, "/static": {"tools.staticdir.on": True, "tools.staticdir.dir": "clients/web/static"}, } # Add MIME types for serving Fontello files from staticdir; # these may be missing or incorrect in the OS mimetypes.add_type("application/vnd.ms-fontobject", ".eot") mimetypes.add_type("application/x-font-ttf", ".ttf") mimetypes.add_type("application/font-woff", ".woff") if test: appconf["/src"] = {"tools.staticdir.on": True, "tools.staticdir.dir": "clients/web/src"} appconf["/test"] = {"tools.staticdir.on": True, "tools.staticdir.dir": "clients/web/test"} appconf["/clients"] = {"tools.staticdir.on": True, "tools.staticdir.dir": "clients"} appconf["/plugins"] = {"tools.staticdir.on": True, "tools.staticdir.dir": "plugins"} curConfig.update(appconf) if test: # Force some config params in testing mode curConfig.update( { "server": { "mode": "testing", "api_root": "api/v1", "static_root": "static", "api_static_root": "../static", } } ) mode = curConfig["server"]["mode"].lower() print(constants.TerminalColor.info("Running in mode: " + mode)) cherrypy.config["engine.autoreload.on"] = mode == "development" # Don't import this until after the configs have been read; some module # initialization code requires the configuration to be set up. from girder.api import api_main root = webroot.Webroot() api_main.addApiToNode(root) cherrypy.engine.subscribe("start", girder.events.daemon.start) cherrypy.engine.subscribe("stop", girder.events.daemon.stop) if plugins is None: settings = model_importer.ModelImporter().model("setting") plugins = settings.get(constants.SettingKey.PLUGINS_ENABLED, default=()) plugins = list(plugin_utilities.getToposortedPlugins(plugins, curConfig, ignoreMissing=True)) root.updateHtmlVars( { "apiRoot": curConfig["server"]["api_root"], "staticRoot": curConfig["server"]["static_root"], "plugins": plugins, } ) apiStaticRoot = curConfig["server"].get("api_static_root", "") if not apiStaticRoot: apiStaticRoot = curConfig["server"]["static_root"] root.api.v1.updateHtmlVars({"apiRoot": curConfig["server"]["api_root"], "staticRoot": apiStaticRoot}) root, appconf, _ = plugin_utilities.loadPlugins( plugins, root, appconf, root.api.v1, curConfig=curConfig, buildDag=False ) return root, appconf