Line | |
---|
1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | # this depends upon Twisted and Nevow, but not upon Tahoe itself |
---|
4 | |
---|
5 | import webbrowser |
---|
6 | |
---|
7 | from twisted.application import strports |
---|
8 | from twisted.internet import reactor |
---|
9 | from nevow import appserver, rend, loaders |
---|
10 | from twisted.web import static |
---|
11 | import web_reliability, provisioning |
---|
12 | |
---|
13 | class Root(rend.Page): |
---|
14 | docFactory = loaders.xmlstr('''\ |
---|
15 | <html xmlns:n="http://nevow.com/ns/nevow/0.1"> |
---|
16 | <head> |
---|
17 | <title>Tahoe-LAFS Provisioning/Reliability Calculator</title> |
---|
18 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
19 | </head> |
---|
20 | <body> |
---|
21 | <p><a href="reliability">Reliability Tool</a></p> |
---|
22 | <p><a href="provisioning">Provisioning Tool</a></p> |
---|
23 | </body> |
---|
24 | </html> |
---|
25 | ''') |
---|
26 | |
---|
27 | child_reliability = web_reliability.ReliabilityTool() |
---|
28 | child_provisioning = provisioning.ProvisioningTool() |
---|
29 | |
---|
30 | |
---|
31 | def run(portnum): |
---|
32 | root = Root() |
---|
33 | root.putChild(b"tahoe.css", static.File("tahoe.css")) |
---|
34 | site = appserver.NevowSite(root) |
---|
35 | s = strports.service("tcp:%d" % portnum, site) |
---|
36 | s.startService() |
---|
37 | reactor.callLater(1.0, webbrowser.open, "http://localhost:%d/" % portnum) |
---|
38 | reactor.run() |
---|
39 | |
---|
40 | if __name__ == '__main__': |
---|
41 | import sys |
---|
42 | portnum = 8070 |
---|
43 | if len(sys.argv) > 1: |
---|
44 | portnum = int(sys.argv[1]) |
---|
45 | run(portnum) |
---|
Note: See
TracBrowser
for help on using the repository browser.