source: trunk/misc/operations_helpers/provisioning/run.py

Last change on this file was 938fdb0, checked in by Itamar Turner-Trauring <itamar@…>, at 2021-02-23T14:18:01Z

putChild should always be bytes.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#!/usr/bin/env python
2
3# this depends upon Twisted and Nevow, but not upon Tahoe itself
4
5import webbrowser
6
7from twisted.application import strports
8from twisted.internet import reactor
9from nevow import appserver, rend, loaders
10from twisted.web import static
11import web_reliability, provisioning
12
13class 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
31def 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
40if __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.