Add support for terminals on Windows (#3087)

* Add support for terminals on Windows

* Bump terminado requirement

* Fix handling of default shell

* Fix appveyor syntax

* Fix requires syntax

* Fix version target

* Clean up handling of default shell and update version check

* Always require terminado

* Clean up appveyor test

* Make the terminado warning uniform

* Default to powershell on Windows

* Clean up terminado verison
This commit is contained in:
Steven Silvester 2017-11-30 23:33:50 -06:00 committed by Grant Nestor
parent ee419c0a17
commit 7b8759fafb
4 changed files with 12 additions and 7 deletions

View File

@ -23,4 +23,4 @@ install:
- cmd: pip install .[test]
test_script:
- nosetests --exclude-dir notebook\terminal -v notebook
- nosetests -v notebook

View File

@ -1328,8 +1328,7 @@ class NotebookApp(JupyterApp):
initialize(self.web_app, self.notebook_dir, self.connection_url, self.terminado_settings)
self.web_app.settings['terminals_available'] = True
except ImportError as e:
log = self.log.debug if sys.platform == 'win32' else self.log.warning
log(_("Terminals not available (error was %s)"), e)
self.log.warning(_("Terminals not available (error was %s)"), e)
def init_signal(self):
if not sys.platform.startswith('win') and sys.stdin and sys.stdin.isatty():

View File

@ -3,9 +3,10 @@ import os
import terminado
from ..utils import check_version
if not check_version(terminado.__version__, '0.3.3'):
raise ImportError("terminado >= 0.3.3 required, found %s" % terminado.__version__)
if not check_version(terminado.__version__, '0.8.1'):
raise ImportError("terminado >= 0.8.1 required, found %s" % terminado.__version__)
from ipython_genutils.py3compat import which
from terminado import NamedTermManager
from tornado.log import app_log
from notebook.utils import url_path_join as ujoin
@ -13,7 +14,12 @@ from .handlers import TerminalHandler, TermSocket
from . import api_handlers
def initialize(webapp, notebook_dir, connection_url, settings):
shell = settings.get('shell_command', [os.environ.get('SHELL') or 'sh'])
default_shell = which('sh')
if not default_shell and os.name == 'nt':
default_shell = 'powershell.exe'
shell = settings.get('shell_command',
[os.environ.get('SHELL') or default_shell]
)
terminal_manager = webapp.settings['terminal_manager'] = NamedTermManager(
shell_command=shell,
extra_env={'JUPYTER_SERVER_ROOT': notebook_dir,

View File

@ -153,9 +153,9 @@ install_requires = [
'nbconvert',
'ipykernel', # bless IPython kernel for now
'Send2Trash',
'terminado>=0.8.1'
]
extras_require = {
':sys_platform != "win32"': ['terminado>=0.3.3'],
'test:python_version == "2.7"': ['mock'],
'test': ['nose', 'coverage', 'requests', 'nose_warnings_filters', 'nbval'],
'test:sys_platform == "win32"': ['nose-exclude'],