├── .gitignore ├── .npmignore ├── COPYING ├── LICENSE.txt ├── README.md └── pyxterm ├── _static ├── index.html ├── pyxterm.js └── term.js ├── pyxshell.py └── pyxterm.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *~ 3 | *.pyc 4 | *.prev 5 | *.sav 6 | *.old 7 | *.pem 8 | README.html 9 | build/* 10 | dist/* 11 | pyxterm.egg-info/* 12 | BAK 13 | IGNORE 14 | ORIG 15 | SUBMIT 16 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .git* 2 | build/ 3 | .lock-wscript 4 | out/ 5 | Makefile.gyp 6 | *.Makefile 7 | *.target.gyp.mk 8 | node_modules/ 9 | img/ 10 | test/ 11 | *.node 12 | example/*.log 13 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Unless otherwise indicated, pyxterm files are distributed 2 | under the BSD License (see LICENSE.txt). 3 | 4 | This package also includes other bundled open source 5 | components which are governed by their own licenses, 6 | as indicated in the respective files. These include: 7 | 8 | pyxshell.py: Public Domain 9 | index.html, term.js, pyxterm.js: MIT 10 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | # pyxterm: A python websocket server backend for term.js 2 | # 3 | # BSD License 4 | # 5 | # Copyright (c) 2014, Ramalingam Saravanan 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # 1. Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## pyxterm: Pure python websocket terminal server for term.js 2 | 3 | Uses ``term.js`` from 4 | 5 | Requires the tornado web server from 6 | 7 | *Note:* To be consistent with ``term.js``, this package should have been 8 | named either ``term.py`` or ``tty.py``, but those names are already in 9 | use. Hence the name ``pyxterm``. 10 | 11 | 12 | ### Main files 13 | 14 | * ``pyxterm.py``: Terminal server 15 | 16 | * ``pyxshell.py``: Backend pseudo-tty shell manager 17 | 18 | * ``_static/pyxterm.js``: Javascript wrappers for ``term.js`` 19 | 20 | * ``_static/index.html``: Example terminal template 21 | 22 | ### Testing 23 | 24 | To try it out, run: 25 | 26 | ./pyxterm.py --auth_type=none --terminal 27 | 28 | to start the server with no authentication and open a ``bash`` shell terminal. 29 | 30 | The default URL to a create a new terminal is 31 | ``http://localhost:8700/new``. To create a named terminal, open 32 | ``http://localhost:8700/terminal_name`` 33 | 34 | Other authentication/shell options are 35 | 36 | * ``./pyxterm.py --auth_type=ssh`` for SSH login to localhost (default) 37 | 38 | * ``sudo ./pyxterm.py --auth_type=login`` for standard Unix-style login 39 | 40 | * ``./pyxterm.py --auth_type=google`` for Google authentication 41 | 42 | * ``./pyxterm.py --auth_type=none /bin/shell_program `` to run a different "shell" program 43 | 44 | * ``./pyxterm.py --auth_type=none ipython `` to run ipython as the "shell" 45 | 46 | * ``./pyxterm.py --auth_type=none /usr/bin/env python /path/app.py `` to use a python script as the "shell" 47 | 48 | 49 | For more help information, type 50 | 51 | ./pyxterm.py -h 52 | 53 | ### Google authentication 54 | 55 | To set up the ``pyxterm`` for Google authentication: 56 | 57 | * Go to the Google Dev Console at 58 | 59 | * Select a project, or create a new one. 60 | 61 | * In the sidebar on the left, select *APIs & Auth*. 62 | 63 | * In the sidebar on the left, select *Consent Screen* to customize the Product name etc. 64 | 65 | * In the sidebar on the left, select *Credentials*. 66 | 67 | * In the OAuth section of the page, select *Create New Client ID*. 68 | 69 | * Edit settings for the Authorized URIs, substituting ``localhost:8700`` if need be 70 | 71 | Authorized Javascript origins: ``http://localhost:8700`` 72 | 73 | Authorized Redirect URI: ``http://localhost:8700/_gauth`` 74 | 75 | * Copy the web application "Client ID key" and "Client secret" to the settings file (see below) 76 | 77 | Start the server with the command: 78 | 79 | ./pyxterm.py --auth_type=google 80 | 81 | and use the URLs ``http://localhost:8700/_gauth/_info`` and 82 | ``http://localhost:8700/_gauth/_test`` to display setup 83 | information and test Google authentication. 84 | 85 | ### Settings file 86 | 87 | Settings may be provided in JSON format in the file 88 | ``.pyxterm.json`` in the home directory. If present, it contains 89 | information of the form: 90 | 91 | {"google_oauth": {"key": "0123456789-code.apps.googleusercontent.com", 92 | "secret": "ABCDEFABCDEF"}, 93 | "auth_emails": ["user1@gmail.com", "user2@gmail.com"] } 94 | 95 | ``auth_emails`` is the list of gmail accounts authorized to access the 96 | server. An empty list implies all accounts are authorized. 97 | 98 | ### History and goals 99 | 100 | The goal is to provide a simple Python terminal server for ``term.js`` using websockets, akin to ``tty.js``. 101 | 102 | ``pyxterm`` contains code simplified and factored out of more complex ``GraphTerm`` code 103 | (), which itself used some old code from 104 | ``AjaxTerm`` 105 | 106 | 107 | Licenses: MIT, BSD 108 | 109 | Version: 0.10 (alpha) 110 | -------------------------------------------------------------------------------- /pyxterm/_static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | pyxterm 4 | 11 | 37 | 38 | 39 | 78 | 79 | 80 | 81 |