PageRenderTime 24ms CodeModel.GetById 10ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/silk/devserver.py

https://bitbucket.org/btubbs/silk-deployment/
Python | 27 lines | 20 code | 4 blank | 3 comment | 3 complexity | 9c09a7b9b58bec51c702599557e00200 MD5 | raw file
 1import os
 2import sys
 3import cherrypy
 4
 5import silk.lib
 6
 7role = silk.lib.get_role()
 8root = silk.lib.get_site_root(os.getcwd())
 9config = silk.lib.get_config(root, role)
10
11if config.get('static_dirs'):
12    for static_dir in config['static_dirs']:
13        # Mount each of our static dirs as its own app in the cherrypy tree.
14        # Each static_dir is a dict with url_path and system_path keys
15        url_path = static_dir['url_path'].rstrip('/')
16        sys_path = os.path.join(root, static_dir['system_path'])
17        cherry_conf = {'/': {'tools.staticdir.on': True,
18                             'tools.staticdir.dir': sys_path,}}
19        cherrypy.tree.mount(None, script_name=url_path, config=cherry_conf)
20
21#mount the wsgi app
22wsgi_app = cherrypy.lib.attributes(config['wsgi_app'].replace(':', '.'))
23cherrypy.tree.graft(wsgi_app, '')
24
25sys.path.append(root)
26os.chdir(root)
27app = cherrypy.tree