diff options
author | Georg Brandl <georg@python.org> | 2007-08-09 09:19:37 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-08-09 09:19:37 +0000 |
commit | edd5ff70d9b56041b0024f4531ea48dd7b0dde28 (patch) | |
tree | e80ab9ffdd579d3bf7356981a0fbd35867194a91 /sphinx-web.py | |
parent | 9a267392c2f5282551682d01a76bc31d52d6543d (diff) | |
download | sphinx-git-edd5ff70d9b56041b0024f4531ea48dd7b0dde28.tar.gz |
Move web startup code to __init__.py.
Diffstat (limited to 'sphinx-web.py')
-rw-r--r-- | sphinx-web.py | 49 |
1 files changed, 2 insertions, 47 deletions
diff --git a/sphinx-web.py b/sphinx-web.py index 80820a1ce..9f8ef8b74 100644 --- a/sphinx-web.py +++ b/sphinx-web.py @@ -6,54 +6,9 @@ :copyright: 2007 by Armin Ronacher, Georg Brandl. :license: Python license. """ -import os -import sys -import getopt - -import sphinx -from sphinx.web.application import setup_app -from sphinx.web.serve import run_simple - -try: - from werkzeug.debug import DebuggedApplication -except ImportError: - DebuggedApplication = lambda x, y: x - - -def main(argv): - opts, args = getopt.getopt(argv[1:], "dhf:") - opts = dict(opts) - if len(args) != 1 or '-h' in opts: - print 'usage: %s [-d] [-f cfg.py] <doc_root>' % argv[0] - print ' -d: debug mode, use werkzeug debugger if installed' - print ' -f: use "cfg.py" file instead of doc_root/webconf.py' - return 2 - - conffile = opts.get('-f', os.path.join(args[0], 'webconf.py')) - config = {} - execfile(conffile, config) - - port = config.get('listen_port', 3000) - hostname = config.get('listen_addr', 'localhost') - debug = ('-d' in opts) or (hostname == 'localhost') - - config['data_root_path'] = args[0] - config['debug'] = debug - - def make_app(): - app = setup_app(config, check_superuser=True) - if debug: - app = DebuggedApplication(app, True) - return app - - if os.environ.get('RUN_MAIN') != 'true': - print '* Sphinx %s- Python documentation web application' % \ - sphinx.__version__.replace('$', '').replace('Revision:', 'rev.') - if debug: - print '* Running in debug mode' - - run_simple(hostname, port, make_app, use_reloader=debug) +import sys if __name__ == '__main__': + from sphinx.web import main sys.exit(main(sys.argv)) |