__init__.py
26 lines
| 1.1 KiB
| text/x-python
|
PythonLexer
Thomas Kluyver
|
r18482 | import os | |
Min RK
|
r19980 | ||
import terminado | |||
from IPython.utils.version import check_version | |||
if not check_version(terminado.__version__, '0.3.3'): | |||
raise ImportError("terminado >= 0.3.3 required, found %s" % terminado.__version__) | |||
Thomas Kluyver
|
r18482 | from terminado import NamedTermManager | |
Min RK
|
r19974 | from tornado.log import app_log | |
Thomas Kluyver
|
r18485 | from IPython.html.utils import url_path_join as ujoin | |
Min RK
|
r18616 | from .handlers import TerminalHandler, TermSocket | |
Thomas Kluyver
|
r18483 | from . import api_handlers | |
Thomas Kluyver
|
r18482 | ||
def initialize(webapp): | |||
shell = os.environ.get('SHELL', 'sh') | |||
Min RK
|
r18616 | terminal_manager = webapp.settings['terminal_manager'] = NamedTermManager(shell_command=[shell]) | |
Min RK
|
r19974 | terminal_manager.log = app_log | |
Thomas Kluyver
|
r18485 | base_url = webapp.settings['base_url'] | |
Thomas Kluyver
|
r18482 | handlers = [ | |
Thomas Kluyver
|
r18485 | (ujoin(base_url, r"/terminals/(\w+)"), TerminalHandler), | |
(ujoin(base_url, r"/terminals/websocket/(\w+)"), TermSocket, | |||
Min RK
|
r18616 | {'term_manager': terminal_manager}), | |
Thomas Kluyver
|
r18485 | (ujoin(base_url, r"/api/terminals"), api_handlers.TerminalRootHandler), | |
(ujoin(base_url, r"/api/terminals/(\w+)"), api_handlers.TerminalHandler), | |||
Thomas Kluyver
|
r18482 | ] | |
webapp.add_handlers(".*$", handlers) |