diff --git a/jupyter_server/edit/__init__.py b/jupyter_server/edit/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/jupyter_server/edit/handlers.py b/jupyter_server/edit/handlers.py deleted file mode 100644 index f813fd1040..0000000000 --- a/jupyter_server/edit/handlers.py +++ /dev/null @@ -1,31 +0,0 @@ -#encoding: utf-8 -"""Tornado handlers for the terminal emulator.""" - -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. - -from tornado import web -from ..base.handlers import JupyterHandler, path_regex -from ..utils import url_escape - - -class EditorHandler(JupyterHandler): - """Render the text editor interface.""" - - @web.authenticated - def get(self, path): - path = path.strip('/') - if not self.contents_manager.file_exists(path): - raise web.HTTPError(404, u'File does not exist: %s' % path) - - basename = path.rsplit('/', 1)[-1] - self.write(self.render_template('edit.html', - file_path=url_escape(path), - basename=basename, - page_title=basename + " (editing)", - ) - ) - -default_handlers = [ - (r"/edit%s" % path_regex, EditorHandler), -] diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index 8ac457bed1..e4e93c5972 100755 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -119,7 +119,6 @@ api=['jupyter_server.services.api.handlers'], config=['jupyter_server.services.config.handlers'], contents=['jupyter_server.services.contents.handlers'], - edit=['jupyter_server.edit.handlers'], files=['jupyter_server.files.handlers'], kernels=['jupyter_server.services.kernels.handlers'], kernelspecs=[ @@ -574,7 +573,6 @@ class ServerApp(JupyterApp): 'auth', 'config', 'contents', - 'edit', 'files', 'kernels', 'kernelspecs', diff --git a/jupyter_server/terminal/__init__.py b/jupyter_server/terminal/__init__.py index d23c036375..01ec828e5f 100644 --- a/jupyter_server/terminal/__init__.py +++ b/jupyter_server/terminal/__init__.py @@ -10,9 +10,9 @@ from terminado import NamedTermManager from tornado.log import app_log from jupyter_server.utils import url_path_join as ujoin -from .handlers import TerminalHandler, TermSocket from . import api_handlers + def initialize(webapp, root_dir, connection_url, settings): if os.name == 'nt': default_shell = 'powershell.exe' @@ -33,9 +33,6 @@ def initialize(webapp, root_dir, connection_url, settings): terminal_manager.log = app_log base_url = webapp.settings['base_url'] handlers = [ - (ujoin(base_url, r"/terminals/(\w+)"), TerminalHandler), - (ujoin(base_url, r"/terminals/websocket/(\w+)"), TermSocket, - {'term_manager': terminal_manager}), (ujoin(base_url, r"/api/terminals"), api_handlers.TerminalRootHandler), (ujoin(base_url, r"/api/terminals/(\w+)"), api_handlers.TerminalHandler), ] diff --git a/jupyter_server/terminal/handlers.py b/jupyter_server/terminal/handlers.py deleted file mode 100644 index 231ede1f39..0000000000 --- a/jupyter_server/terminal/handlers.py +++ /dev/null @@ -1,42 +0,0 @@ -#encoding: utf-8 -"""Tornado handlers for the terminal emulator.""" - -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. - -from tornado import web -import terminado -from jupyter_server._tz import utcnow -from ..base.handlers import JupyterHandler -from ..base.zmqhandlers import WebSocketMixin - - -class TerminalHandler(JupyterHandler): - """Render the terminal interface.""" - @web.authenticated - def get(self, term_name): - self.write(self.render_template('terminal.html', - ws_path="terminals/websocket/%s" % term_name)) - - -class TermSocket(WebSocketMixin, JupyterHandler, terminado.TermSocket): - - def origin_check(self): - """Terminado adds redundant origin_check - - Tornado already calls check_origin, so don't do anything here. - """ - return True - - def get(self, *args, **kwargs): - if not self.get_current_user(): - raise web.HTTPError(403) - return super(TermSocket, self).get(*args, **kwargs) - - def on_message(self, message): - super(TermSocket, self).on_message(message) - self.application.settings['terminal_last_activity'] = utcnow() - - def write_message(self, message, binary=False): - super(TermSocket, self).write_message(message, binary=binary) - self.application.settings['terminal_last_activity'] = utcnow() diff --git a/tests/test_terminal.py b/tests/test_terminal.py index 4cc40f5c5e..9104b083bb 100644 --- a/tests/test_terminal.py +++ b/tests/test_terminal.py @@ -70,40 +70,3 @@ async def test_terminal_create_with_kwargs(fetch, ws_fetch, terminal_path, kill_ assert data['name'] == term_name await kill_all() - - -async def test_terminal_create_with_cwd( - fetch, - ws_fetch, - terminal_path, - kill_all -): - resp = await fetch( - 'api', 'terminals', - method='POST', - body=json.dumps({'cwd': str(terminal_path)}), - allow_nonstandard_methods=True, - ) - - data = json.loads(resp.body.decode()) - term_name = data['name'] - - ws = await ws_fetch( - 'terminals', 'websocket', term_name - ) - await ws.write_message(json.dumps(['stdin', 'pwd\r'])) - - messages = "" - while True: - try: - response = await asyncio.wait_for(ws.read_message(), timeout=1.0) - except asyncio.TimeoutError: - return messages - - response = json.loads(response) - if response[0] == "stdout": - messages += response[1] - - ws.close() - assert str(terminal_path) in messages - await kill_all()