##// END OF EJS Templates
require terminado >= 0.3.3 for terminal handlers
Min RK -
Show More
@@ -1,20 +1,27 b''
1 import os
1 import os
2
3 import terminado
4 from IPython.utils.version import check_version
5
6 if not check_version(terminado.__version__, '0.3.3'):
7 raise ImportError("terminado >= 0.3.3 required, found %s" % terminado.__version__)
8
2 from terminado import NamedTermManager
9 from terminado import NamedTermManager
3 from tornado.log import app_log
10 from tornado.log import app_log
4 from IPython.html.utils import url_path_join as ujoin
11 from IPython.html.utils import url_path_join as ujoin
5 from .handlers import TerminalHandler, TermSocket
12 from .handlers import TerminalHandler, TermSocket
6 from . import api_handlers
13 from . import api_handlers
7
14
8 def initialize(webapp):
15 def initialize(webapp):
9 shell = os.environ.get('SHELL', 'sh')
16 shell = os.environ.get('SHELL', 'sh')
10 terminal_manager = webapp.settings['terminal_manager'] = NamedTermManager(shell_command=[shell])
17 terminal_manager = webapp.settings['terminal_manager'] = NamedTermManager(shell_command=[shell])
11 terminal_manager.log = app_log
18 terminal_manager.log = app_log
12 base_url = webapp.settings['base_url']
19 base_url = webapp.settings['base_url']
13 handlers = [
20 handlers = [
14 (ujoin(base_url, r"/terminals/(\w+)"), TerminalHandler),
21 (ujoin(base_url, r"/terminals/(\w+)"), TerminalHandler),
15 (ujoin(base_url, r"/terminals/websocket/(\w+)"), TermSocket,
22 (ujoin(base_url, r"/terminals/websocket/(\w+)"), TermSocket,
16 {'term_manager': terminal_manager}),
23 {'term_manager': terminal_manager}),
17 (ujoin(base_url, r"/api/terminals"), api_handlers.TerminalRootHandler),
24 (ujoin(base_url, r"/api/terminals"), api_handlers.TerminalRootHandler),
18 (ujoin(base_url, r"/api/terminals/(\w+)"), api_handlers.TerminalHandler),
25 (ujoin(base_url, r"/api/terminals/(\w+)"), api_handlers.TerminalHandler),
19 ]
26 ]
20 webapp.add_handlers(".*$", handlers) No newline at end of file
27 webapp.add_handlers(".*$", handlers)
General Comments 0
You need to be logged in to leave comments. Login now