| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import argparse | 6 import argparse |
| 7 import cherrypy | 7 import cherrypy |
| 8 import json | 8 import json |
| 9 import os | 9 import os |
| 10 import staticdirindex | 10 import staticdirindex |
| 11 | 11 import skypy.paths as paths |
| 12 | |
| 13 BUILD_DIRECTORY = 'out' | |
| 14 CONFIG_DIRECTORY = 'Debug' | |
| 15 SRC_ROOT = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, | |
| 16 os.pardir)) | |
| 17 SKY_ROOT = os.path.join(SRC_ROOT, 'sky') | |
| 18 GEN_ROOT = os.path.join(SRC_ROOT, BUILD_DIRECTORY, CONFIG_DIRECTORY, 'gen') | |
| 19 | |
| 20 | 12 |
| 21 def skydir(section="", dir="", path="", **kwargs): | 13 def skydir(section="", dir="", path="", **kwargs): |
| 22 if cherrypy.request.params.get('format') is None: | 14 if cherrypy.request.params.get('format') is None: |
| 23 return '<sky><import src="/sky/examples/file-browser.sky"/><file-browser
/></sky>' | 15 return '<sky><import src="/sky/examples/file-browser.sky"/><file-browser
/></sky>' |
| 24 result = dict() | 16 result = dict() |
| 25 result['directories'] = [] | 17 result['directories'] = [] |
| 26 result['files'] = [] | 18 result['files'] = [] |
| 27 for _, dir_names, file_names in os.walk(path.rstrip(r"\/")): | 19 for _, dir_names, file_names in os.walk(path.rstrip(r"\/")): |
| 28 for dir_name in sorted(dir_names): | 20 for dir_name in sorted(dir_names): |
| 29 result["directories"].append(dir_name) | 21 result["directories"].append(dir_name) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 55 # This causes some strange python exception?? | 47 # This causes some strange python exception?? |
| 56 # 'log.error_log': os.path.join(log_dir, 'error_log.txt'), | 48 # 'log.error_log': os.path.join(log_dir, 'error_log.txt'), |
| 57 }, | 49 }, |
| 58 '/': { | 50 '/': { |
| 59 'tools.staticdir.on': True, | 51 'tools.staticdir.on': True, |
| 60 'tools.staticdir.dir': os.path.abspath(args.app_path), | 52 'tools.staticdir.dir': os.path.abspath(args.app_path), |
| 61 'tools.staticdir.indexlister': skydir, | 53 'tools.staticdir.indexlister': skydir, |
| 62 }, | 54 }, |
| 63 '/mojo/public': { | 55 '/mojo/public': { |
| 64 'tools.staticdir.on': True, | 56 'tools.staticdir.on': True, |
| 65 'tools.staticdir.dir': os.path.join(GEN_ROOT, 'mojo', 'public'), | 57 'tools.staticdir.dir': os.path.join(paths.GEN_ROOT, 'mojo', 'public'
), |
| 66 }, | 58 }, |
| 67 '/mojo/services': { | 59 '/mojo/services': { |
| 68 'tools.staticdir.on': True, | 60 'tools.staticdir.on': True, |
| 69 'tools.staticdir.dir': os.path.join(GEN_ROOT, 'mojo', 'services'), | 61 'tools.staticdir.dir': os.path.join(paths.GEN_ROOT, 'mojo', 'service
s'), |
| 70 }, | 62 }, |
| 71 '/sky/services': { | 63 '/sky/services': { |
| 72 'tools.staticdir.on': True, | 64 'tools.staticdir.on': True, |
| 73 'tools.staticdir.dir': os.path.join(GEN_ROOT, 'sky', 'services'), | 65 'tools.staticdir.dir': os.path.join(paths.GEN_ROOT, 'sky', 'services
'), |
| 74 }, | 66 }, |
| 75 } | 67 } |
| 76 cherrypy.quickstart(config=config) | 68 cherrypy.quickstart(config=config) |
| 77 | 69 |
| 78 | 70 |
| 79 if __name__ == '__main__': | 71 if __name__ == '__main__': |
| 80 main() | 72 main() |
| OLD | NEW |