GithubHelp home page GithubHelp logo

python-repository-hub / terminado Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jupyter/terminado

0.0 0.0 0.0 446 KB

Terminals served by tornado websockets

Home Page: http://terminado.readthedocs.org/en/latest/

License: Other

Python 93.84% JavaScript 6.16%

terminado's Introduction

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

It evolved out of pyxterm, which was part of GraphTerm (as lineterm.py), v0.57.0 (2014-07-18), and ultimately derived from the public-domain Ajaxterm code, v0.11 (2008-11-13) (also on Github as part of QWeb).

Modules:

  • terminado.management: controls launching virtual terminals, connecting them to Tornado's event loop, and closing them down.
  • terminado.websocket: Provides a websocket handler for communicating with a terminal.
  • terminado.uimodule: Provides a Terminal Tornado UI Module.

JS:

  • terminado/_static/terminado.js: A lightweight wrapper to set up a term.js terminal with a websocket.

Local Installation:

$ pip install -e .[test]

Usage example:

import os.path
import tornado.web
import tornado.ioloop
# This demo requires tornado_xstatic and XStatic-term.js
import tornado_xstatic

import terminado
STATIC_DIR = os.path.join(os.path.dirname(terminado.__file__), "_static")

class TerminalPageHandler(tornado.web.RequestHandler):
    def get(self):
        return self.render("termpage.html", static=self.static_url,
                           xstatic=self.application.settings['xstatic_url'],
                           ws_url_path="/websocket")

if __name__ == '__main__':
    term_manager = terminado.SingleTermManager(shell_command=['bash'])
    handlers = [
                (r"/websocket", terminado.TermSocket,
                     {'term_manager': term_manager}),
                (r"/", TerminalPageHandler),
                (r"/xstatic/(.*)", tornado_xstatic.XStaticFileHandler,
                     {'allowed_modules': ['termjs']})
               ]
    app = tornado.web.Application(handlers, static_path=STATIC_DIR,
                      xstatic_url = tornado_xstatic.url_maker('/xstatic/'))
    # Serve at http://localhost:8765/ N.B. Leaving out 'localhost' here will
    # work, but it will listen on the public network interface as well.
    # Given what terminado does, that would be rather a security hole.
    app.listen(8765, 'localhost')
    try:
        tornado.ioloop.IOLoop.instance().start()
    finally:
        term_manager.shutdown()

See the demos directory for more examples. This is a simplified version of the single.py demo.

Run the unit tests with:

$ pytest

terminado's People

Contributors

afshin avatar andfoy avatar athornton avatar aus avatar blink1073 avatar cailiang9 avatar chjj avatar devmonkey22 avatar dlukes avatar dong-zeyu avatar github-actions[bot] avatar gururajrkatti avatar hugovk avatar icankeep avatar jasongrout avatar jtpio avatar mgmarino avatar minrk avatar mircot avatar mitotic avatar omrishiv avatar payne92 avatar pre-commit-ci[bot] avatar qntnrbns avatar risacher avatar rvalieris avatar srstevenson avatar takluyver avatar wh1isper avatar yusufbashi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.