Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for terminals on Windows #3087

Merged
merged 12 commits into from
Dec 1, 2017
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ install:
- cmd: pip install .[test]

test_script:
- nosetests --exclude-dir notebook\terminal -v notebook
- nosetests -v notebook
3 changes: 1 addition & 2 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1328,8 +1328,7 @@ def init_terminals(self):
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():
Expand Down
12 changes: 9 additions & 3 deletions notebook/terminal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
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
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,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@
'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'],
Expand Down