How to use the terminado.TermSocket function in terminado

To help you get started, we’ve selected a few terminado examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github blink1073 / jupyter_demo / src / View on Github external
def main(argv):
    if len(sys.argv) > 1:
        cmd = sys.argv[1]
        cmd = 'bash'
    term_manager = SingleTermManager(shell_command=[cmd])

    handlers = [
        (r"/websocket", TermSocket,
         {'term_manager': term_manager}),
        (r"/", TerminalPageHandler),
        (r'/(.*)', tornado.web.StaticFileHandler,
         {'path': '.'}),
        (r'/*/(.*)', tornado.web.StaticFileHandler,
         {'path': '.'}),

    nb_command = [sys.executable, '-m', 'notebook', '--no-browser',
    nb_server = subprocess.Popen(nb_command, stderr=subprocess.STDOUT,

    # wait for notebook server to start up
    while 1:
        line = nb_server.stdout.readline().decode('utf-8').strip()
github nathanielobrown / flask-terminado / View on Github external
def add_terminal(self, route, command, workdir=None, env=None):
        assert route.startswith('/')
        if is None:
            raise Exception("we don't support init_app yet")
        term_manager = SingleTermManager(shell_command=command)
        wrapped_app = tornado.wsgi.WSGIContainer(
        handlers = [
                TermSocket, {'term_manager': term_manager}),
                IndexHandler, {'url_prefix': self.url_prefix}),
                tornado.web.StaticFileHandler, {'path': '.'}),
                tornado.web.FallbackHandler, {'fallback': wrapped_app}),
        self.tornado_app = tornado.web.Application(handlers)
github jupyter / notebook / notebook / terminal / View on Github external
from tornado import web
import terminado
from notebook._tz import utcnow
from ..base.handlers import IPythonHandler
from ..base.zmqhandlers import WebSocketMixin

class TerminalHandler(IPythonHandler):
    """Render the terminal interface."""
    def get(self, term_name):
                   ws_path="terminals/websocket/%s" % term_name))

class TermSocket(WebSocketMixin, IPythonHandler, 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()
github SandstoneHPC / sandstone-ide / oide / View on Github external
def __init__(self, *args, **kwargs):
        app_static_handlers = []
        for spec in get_installed_app_static_specs():
            s_url = r"/static/{}/(.*)".format(spec[0])
            s_dir = os.path.join(spec[1],'static')
                (s_url, tornado.web.StaticFileHandler, {'path': s_dir})

        term_manager = SingleTermManager(shell_command=['bash'])
        self.term_manager = term_manager
        term_url = [(r"/terminal/a/term", TermSocket,
                     {'term_manager': term_manager})]

        handlers = [
                (r"/static/core/(.*)", tornado.web.StaticFileHandler, {'path': STATIC_DIR}),
            ] + app_static_handlers + URL_SCHEMA + term_url

        settings = dict(
            cookie_secret = global_settings.COOKIE_SECRET,
            debug = global_settings.DEBUG,
github SandstoneHPC / sandstone-ide / sandstone / apps / webterminal / View on Github external
import sandstone.lib.decorators
from sandstone.lib.handlers.base import BaseHandler
from terminado import TermSocket

class AuthTermSocket(TermSocket,BaseHandler):

    def get(self, *args, **kwargs):
        return super(AuthTermSocket, self).get(*args, **kwargs)


Tornado websocket backend for the Xterm.js Javascript terminal emulator library.

Latest version published 10 months ago

Package Health Score

82 / 100
Full package analysis

Similar packages