/silk/devserver.py

https://bitbucket.org/btubbs/silk-deployment/ · Python · 27 lines · 19 code · 5 blank · 3 comment · 2 complexity · 9c09a7b9b58bec51c702599557e00200 MD5 · raw file

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