mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-19 03:06:33 +00:00
webish: write node.url, for the benefit of CLI tools
This commit is contained in:
parent
a470947cc3
commit
a29ab33379
@ -98,8 +98,9 @@ class Client(node.Node, Referenceable, testutil.PollMixin):
|
||||
self.add_service(ws)
|
||||
vd = self.getServiceNamed("vdrive")
|
||||
startfile = os.path.join(self.basedir, "start.html")
|
||||
nodeurl_file = os.path.join(self.basedir, "node.url")
|
||||
d = vd.when_private_root_available()
|
||||
d.addCallback(ws.create_start_html, startfile)
|
||||
d.addCallback(ws.create_start_html, startfile, nodeurl_file)
|
||||
|
||||
|
||||
def _check_hotline(self, hotline_file):
|
||||
|
@ -395,7 +395,8 @@ class Web(WebMixin, unittest.TestCase):
|
||||
self.s.basedir = 'web/test_welcome'
|
||||
fileutil.make_dirs("web/test_welcome")
|
||||
self.ws.create_start_html("private_uri",
|
||||
"web/test_welcome/start.html")
|
||||
"web/test_welcome/start.html",
|
||||
"web/test_welcome/node.url")
|
||||
return self.GET("/")
|
||||
d.addCallback(_check)
|
||||
def _check2(res):
|
||||
@ -467,7 +468,8 @@ class Web(WebMixin, unittest.TestCase):
|
||||
def test_start_html(self):
|
||||
fileutil.make_dirs("web")
|
||||
startfile = "web/start.html"
|
||||
self.ws.create_start_html("private_uri", startfile)
|
||||
nodeurlfile = "web/node.url"
|
||||
self.ws.create_start_html("private_uri", startfile, nodeurlfile)
|
||||
|
||||
self.failUnless(os.path.exists(startfile))
|
||||
start_html = open(startfile, "r").read()
|
||||
@ -475,6 +477,10 @@ class Web(WebMixin, unittest.TestCase):
|
||||
private_url = self.webish_url + "/uri/private_uri"
|
||||
self.failUnless(private_url in start_html)
|
||||
|
||||
self.failUnless(os.path.exists(nodeurlfile))
|
||||
nodeurl = open(nodeurlfile, "r").read().strip()
|
||||
self.failUnless(nodeurl.startswith("http://localhost"))
|
||||
|
||||
def test_GET_FILEURL(self):
|
||||
d = self.GET("/vdrive/global/foo/bar.txt")
|
||||
d.addCallback(self.failUnlessIsBarDotTxt)
|
||||
|
@ -1221,7 +1221,7 @@ class WebishServer(service.MultiService):
|
||||
# apparently 'ISite' does not exist
|
||||
#self.site._client = self.parent
|
||||
|
||||
def create_start_html(self, private_uri, startfile):
|
||||
def create_start_html(self, private_uri, startfile, nodeurl_file):
|
||||
f = open(startfile, "w")
|
||||
os.chmod(startfile, 0600)
|
||||
template = open(util.sibpath(__file__, "web/start.html"), "r").read()
|
||||
@ -1240,3 +1240,9 @@ class WebishServer(service.MultiService):
|
||||
}
|
||||
f.write(template % fields)
|
||||
f.close()
|
||||
|
||||
f = open(nodeurl_file, "w")
|
||||
# this file is world-readable
|
||||
f.write(base_url + "\n")
|
||||
f.close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user