Show More
@@ -190,7 +190,6 b' class NotebookWebApplication(web.Application):' | |||||
190 | handlers.extend(load_handlers('notebook.handlers')) |
|
190 | handlers.extend(load_handlers('notebook.handlers')) | |
191 | handlers.extend(load_handlers('nbconvert.handlers')) |
|
191 | handlers.extend(load_handlers('nbconvert.handlers')) | |
192 | handlers.extend(load_handlers('kernelspecs.handlers')) |
|
192 | handlers.extend(load_handlers('kernelspecs.handlers')) | |
193 | handlers.extend(load_handlers('terminal.handlers')) |
|
|||
194 | handlers.extend(load_handlers('services.kernels.handlers')) |
|
193 | handlers.extend(load_handlers('services.kernels.handlers')) | |
195 | handlers.extend(load_handlers('services.contents.handlers')) |
|
194 | handlers.extend(load_handlers('services.contents.handlers')) | |
196 | handlers.extend(load_handlers('services.clusters.handlers')) |
|
195 | handlers.extend(load_handlers('services.clusters.handlers')) | |
@@ -762,6 +761,15 b' class NotebookApp(BaseIPythonApplication):' | |||||
762 | proto = 'https' if self.certfile else 'http' |
|
761 | proto = 'https' if self.certfile else 'http' | |
763 | return "%s://%s:%i%s" % (proto, ip, self.port, self.base_url) |
|
762 | return "%s://%s:%i%s" % (proto, ip, self.port, self.base_url) | |
764 |
|
763 | |||
|
764 | def init_terminals(self): | |||
|
765 | try: | |||
|
766 | from .terminal import initialize | |||
|
767 | initialize(self.web_app) | |||
|
768 | self.web_app.terminals_available = True | |||
|
769 | except ImportError as e: | |||
|
770 | self.log.info("Terminals not available (error was %s)", e) | |||
|
771 | self.web_app.terminals_available = False | |||
|
772 | ||||
765 | def init_signal(self): |
|
773 | def init_signal(self): | |
766 | if not sys.platform.startswith('win'): |
|
774 | if not sys.platform.startswith('win'): | |
767 | signal.signal(signal.SIGINT, self._handle_sigint) |
|
775 | signal.signal(signal.SIGINT, self._handle_sigint) | |
@@ -841,6 +849,7 b' class NotebookApp(BaseIPythonApplication):' | |||||
841 | self.init_configurables() |
|
849 | self.init_configurables() | |
842 | self.init_components() |
|
850 | self.init_components() | |
843 | self.init_webapp() |
|
851 | self.init_webapp() | |
|
852 | self.init_terminals() | |||
844 | self.init_signal() |
|
853 | self.init_signal() | |
845 |
|
854 | |||
846 | def cleanup_kernels(self): |
|
855 | def cleanup_kernels(self): |
@@ -22,8 +22,9 b' require([' | |||||
22 | $("#dummy-screen").hide(); |
|
22 | $("#dummy-screen").hide(); | |
23 |
|
23 | |||
24 | var base_url = utils.get_body_data('baseUrl'); |
|
24 | var base_url = utils.get_body_data('baseUrl'); | |
|
25 | var ws_path = utils.get_body_data('wsPath'); | |||
25 | var ws_url = location.protocol.replace('http', 'ws') + "//" + location.host |
|
26 | var ws_url = location.protocol.replace('http', 'ws') + "//" + location.host | |
26 |
+ base_url + |
|
27 | + base_url + ws_path; | |
27 |
|
28 | |||
28 | var header = $("#header")[0] |
|
29 | var header = $("#header")[0] | |
29 | function calculate_size() { |
|
30 | function calculate_size() { |
@@ -10,6 +10,7 b'' | |||||
10 | {% block params %} |
|
10 | {% block params %} | |
11 |
|
11 | |||
12 | data-base-url="{{base_url}}" |
|
12 | data-base-url="{{base_url}}" | |
|
13 | data-ws-path="{{ws_path}}" | |||
13 |
|
14 | |||
14 | {% endblock %} |
|
15 | {% endblock %} | |
15 |
|
16 |
@@ -0,0 +1,14 b'' | |||||
|
1 | import os | |||
|
2 | from terminado import NamedTermManager | |||
|
3 | from .handlers import TerminalHandler, NewTerminalHandler, TermSocket | |||
|
4 | ||||
|
5 | def initialize(webapp): | |||
|
6 | shell = os.environ.get('SHELL', 'sh') | |||
|
7 | webapp.terminal_manager = NamedTermManager(shell_command=[shell]) | |||
|
8 | handlers = [ | |||
|
9 | (r"/terminals/new", NewTerminalHandler), | |||
|
10 | (r"/terminals/(\w+)", TerminalHandler), | |||
|
11 | (r"/terminals/websocket/(\w+)", TermSocket, | |||
|
12 | {'term_manager': webapp.terminal_manager}), | |||
|
13 | ] | |||
|
14 | webapp.add_handlers(".*$", handlers) No newline at end of file |
@@ -8,19 +8,17 b' import terminado' | |||||
8 | from ..base.handlers import IPythonHandler |
|
8 | from ..base.handlers import IPythonHandler | |
9 |
|
9 | |||
10 | class TerminalHandler(IPythonHandler): |
|
10 | class TerminalHandler(IPythonHandler): | |
11 |
"""Render the t |
|
11 | """Render the terminal interface.""" | |
12 | @web.authenticated |
|
12 | @web.authenticated | |
13 |
def get(self, |
|
13 | def get(self, term_name): | |
14 |
self.write(self.render_template('terminal.html' |
|
14 | self.write(self.render_template('terminal.html', | |
15 |
|
15 | ws_path="terminals/websocket/%s" % term_name)) | ||
16 |
|
||||
17 | #----------------------------------------------------------------------------- |
|
|||
18 | # URL to handler mappings |
|
|||
19 | #----------------------------------------------------------------------------- |
|
|||
20 |
|
16 | |||
|
17 | class NewTerminalHandler(IPythonHandler): | |||
|
18 | """Redirect to a new terminal.""" | |||
|
19 | @web.authenticated | |||
|
20 | def get(self): | |||
|
21 | name, _ = self.application.terminal_manager.new_named_terminal() | |||
|
22 | self.redirect("/terminals/%s" % name, permanent=False) | |||
21 |
|
23 | |||
22 | default_handlers = [ |
|
24 | TermSocket = terminado.TermSocket | |
23 | (r"/terminal", TerminalHandler), |
|
|||
24 | (r"/terminal/websocket", terminado.TermSocket, |
|
|||
25 | {'term_manager': terminado.SingleTermManager(shell_command=['bash'])}), |
|
|||
26 | ] |
|
General Comments 0
You need to be logged in to leave comments.
Login now