]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webish: write node.url, for the benefit of CLI tools
authorBrian Warner <warner@lothar.com>
Thu, 11 Oct 2007 08:38:04 +0000 (01:38 -0700)
committerBrian Warner <warner@lothar.com>
Thu, 11 Oct 2007 08:38:04 +0000 (01:38 -0700)
src/allmydata/client.py
src/allmydata/test/test_web.py
src/allmydata/webish.py

index 8dbc71a5e5dfb56ecb775e6b642feda822a22be9..79de742eb3d0e61e748b0d449f83f3d589f187db 100644 (file)
@@ -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):
index e3c83ee62a95b66f8f358f11060eeaf10753328d..1a5c9e880b11613a8574535ca73e2e8a89da3517 100644 (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)
index 3cc6c83c0fbb5220865afef23a991533c5a77415..5b966ca390c8dea9993969b81c325f711792d54d 100644 (file)
@@ -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()
+