From: Brian Warner Date: Thu, 11 Oct 2007 08:38:04 +0000 (-0700) Subject: webish: write node.url, for the benefit of CLI tools X-Git-Tag: allmydata-tahoe-0.6.1~49 X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/biz?a=commitdiff_plain;h=a29ab3337992ea44c0d953ebf6aa1927441eab7a;p=tahoe-lafs%2Ftahoe-lafs.git webish: write node.url, for the benefit of CLI tools --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 8dbc71a5..79de742e 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -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): diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index e3c83ee6..1a5c9e88 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -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) diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index 3cc6c83c..5b966ca3 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -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() +