root/trunk/twisted/tap/manhole.py

Revision 25168, 1.7 KB (checked in by exarkun, 22 months ago)

Merge remove-mktap-3393

Author: kehander1, exarkun
Reviewer: ralphm, itamar
Fixes: #3393

Remove almost all references to mktap(1) from the Twisted documentation.

The finger tutorial still refers to mktap since it also contains an
old-style plugin which will not work with twistd.

Line 
1
2# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
3# See LICENSE for details.
4
5
6"""
7I am the support module for making a manhole server with twistd.
8"""
9
10from twisted.manhole import service
11from twisted.spread import pb
12from twisted.python import usage, util
13from twisted.cred import portal, checkers
14from twisted.application import strports
15import os, sys
16
17class Options(usage.Options):
18    synopsis = "[options]"
19    optParameters = [
20           ["user", "u", "admin", "Name of user to allow to log in"],
21           ["port", "p", str(pb.portno), "Port to listen on"],
22    ]
23
24    optFlags = [
25        ["tracebacks", "T", "Allow tracebacks to be sent over the network"],
26    ]
27    zsh_actions = {"user" : "_users"}
28
29    def opt_password(self, password):
30        """Required.  '-' will prompt or read a password from stdin.
31        """
32        # If standard input is a terminal, I prompt for a password and
33        # confirm it.  Otherwise, I use the first line from standard
34        # input, stripping off a trailing newline if there is one.
35        if password in ('', '-'):
36            self['password'] = util.getPassword(confirm=1)
37        else:
38            self['password'] = password
39    opt_w = opt_password
40
41    def postOptions(self):
42        if not self.has_key('password'):
43            self.opt_password('-')
44
45def makeService(config):
46    port, user, password = config['port'], config['user'], config['password']
47    p = portal.Portal(
48        service.Realm(service.Service(config["tracebacks"], config.get('namespace'))),
49        [checkers.InMemoryUsernamePasswordDatabaseDontUse(**{user: password})]
50    )
51    return strports.service(port, pb.PBServerFactory(p, config["tracebacks"]))
Note: See TracBrowser for help on using the browser.