| 1 |
|
|---|
| 2 |
|
|---|
| 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 |
|
|---|
| 29 |
|
|---|
| 30 |
from twisted.internet import gtk2reactor |
|---|
| 31 |
gtk2reactor.install() |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 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() |
|---|