~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/scripts/manhole.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2001-2009 Twisted Matrix Laboratories.
 
2
# See LICENSE for details.
 
3
 
 
4
"""
 
5
Start a L{twisted.manhole} client.
 
6
"""
 
7
 
 
8
import sys
 
9
 
 
10
from twisted.python import usage
 
11
 
 
12
def run():
 
13
    config = MyOptions()
 
14
    try:
 
15
        config.parseOptions()
 
16
    except usage.UsageError, e:
 
17
        print str(e)
 
18
        print str(config)
 
19
        sys.exit(1)
 
20
 
 
21
    run_gtk2(config)
 
22
 
 
23
    from twisted.internet import reactor
 
24
    reactor.run()
 
25
 
 
26
 
 
27
def run_gtk2(config):
 
28
    # Put these off until after we parse options, so we know what reactor
 
29
    # to load.
 
30
    from twisted.internet import gtk2reactor
 
31
    gtk2reactor.install()
 
32
 
 
33
    # Put this off until after we parse options, or else gnome eats them.
 
34
    sys.argv[:] = ['manhole']
 
35
    from twisted.manhole.ui import gtk2manhole
 
36
 
 
37
    o = config.opts
 
38
    defaults = {
 
39
        'host': o['host'],
 
40
        'port': o['port'],
 
41
        'identityName': o['user'],
 
42
        'password': o['password'],
 
43
        'serviceName': o['service'],
 
44
        'perspectiveName': o['perspective']
 
45
        }
 
46
    w = gtk2manhole.ManholeWindow()
 
47
    w.setDefaults(defaults)
 
48
    w.login()
 
49
 
 
50
 
 
51
pbportno = 8787
 
52
 
 
53
class MyOptions(usage.Options):
 
54
    optParameters=[("user", "u", "guest", "username"),
 
55
                   ("password", "w", "guest"),
 
56
                   ("service", "s", "twisted.manhole", "PB Service"),
 
57
                   ("host", "h", "localhost"),
 
58
                   ("port", "p", str(pbportno)),
 
59
                   ("perspective", "P", "",
 
60
                    "PB Perspective to ask for "
 
61
                    "(if different than username)")]
 
62
    zsh_actions = {"host":"_hosts"}
 
63
 
 
64
if __name__ == '__main__':
 
65
    run()