File: twisted_serve_ssh.tac

package info (click to toggle)
urwid 3.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,232 kB
  • sloc: python: 29,010; javascript: 382; sh: 34; makefile: 22
file content (41 lines) | stat: -rw-r--r-- 946 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# encoding: utf-8

"""
Example application for integrating serving a Urwid application remotely.

Run this application with::

    twistd -ny twisted_serve_ssh.tac

Then in another terminal run::

    ssh -p 6022 user@localhost

(The password is 'pw' without the quotes.)

Note: To use this in real life, you must use some real checker.
"""

from twisted.cred.checkers import InMemoryUsernamePasswordDatabaseDontUse

import urwid
from twisted_serve_ssh import UrwidMind, UrwidUi, create_application


class HelloUi(UrwidUi):
    def create_urwid_toplevel(self):
        txt = urwid.Edit('Hello World?\n ')
        txt2 = urwid.Edit('Hello World?\n ')
        fill = urwid.Filler(urwid.Pile([txt, txt2]), 'top')
        return fill


class HelloMind(UrwidMind):
    ui_factory = HelloUi
    cred_checkers = [InMemoryUsernamePasswordDatabaseDontUse(user='pw')]


application = create_application('TXUrwid Demo', HelloMind, 6022)

# vim: ft=python