Skip to content

Commit

Permalink
Add support for terminals on Windows (#3087)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
blink1073 authored and gnestor committed Dec 1, 2017
1 parent ee419c0 commit 7b8759f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
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

0 comments on commit 7b8759f

Please sign in to comment.