]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
If a helper is not configured, make the banner on the welcome page say that, and...
authorDavid-Sarah Hopwood <david-sarah@jacaranda.org>
Sat, 29 Dec 2012 04:17:00 +0000 (04:17 +0000)
committerDavid-Sarah Hopwood <david-sarah@jacaranda.org>
Sat, 29 Dec 2012 04:17:00 +0000 (04:17 +0000)
fixes #1735

Author: kick
Signed-off-by: David-Sarah Hopwood <davidsarah@jacaranda.org>
src/allmydata/client.py
src/allmydata/test/test_client.py
src/allmydata/test/test_web.py
src/allmydata/web/root.py
src/allmydata/web/static/tahoe.css
src/allmydata/web/welcome.xhtml

index 1e4479bb47f0c85c143209f6a8737847581ac289..e18999713cc0e7b3c2496fb8bfb74aa0fb3f70a2 100644 (file)
@@ -306,6 +306,9 @@ class Client(node.Node, pollmixin.PollMixin):
 
     def init_client(self):
         helper_furl = self.get_config("client", "helper.furl", None)
+        if helper_furl in ("None", ""):
+            helper_furl = None
+
         DEP = self.DEFAULT_ENCODING_PARAMETERS
         DEP["k"] = int(self.get_config("client", "shares.needed", DEP["k"]))
         DEP["n"] = int(self.get_config("client", "shares.total", DEP["n"]))
index 5373464811c864af79c689f188b76fe3b599470c..04458e6824daaffce6945b991d2d376e0674a0f5 100644 (file)
@@ -172,6 +172,24 @@ class Basic(testutil.ReallyEqualMixin, unittest.TestCase):
         self.failUnless("node.uptime" in stats)
         self.failUnless(isinstance(stats["node.uptime"], float))
 
+    def test_helper_furl(self):
+        basedir = "test_client.Basic.test_helper_furl"
+        os.mkdir(basedir)
+
+        def _check(config, expected_furl):
+            fileutil.write(os.path.join(basedir, "tahoe.cfg"),
+                           BASECONFIG + config)
+            c = client.Client(basedir)
+            uploader = c.getServiceNamed("uploader")
+            furl, connected = uploader.get_helper_info()
+            self.failUnlessEqual(furl, expected_furl)
+
+        _check("", None)
+        _check("helper.furl =\n", None)
+        _check("helper.furl = \n", None)
+        _check("helper.furl = None", None)
+        _check("helper.furl = pb://blah\n", "pb://blah")
+
     @mock.patch('allmydata.util.log.msg')
     @mock.patch('allmydata.frontends.drop_upload.DropUploader')
     def test_create_drop_uploader(self, mock_drop_uploader, mock_log_msg):
index 2c6c0ceb4c998a144ff9cb60e7c9e45ba13fcd89..576c3da33c8bfbf238b788f659f0c00e2931a27e 100644 (file)
@@ -80,6 +80,9 @@ class FakeNodeMaker(NodeMaker):
 
 class FakeUploader(service.Service):
     name = "uploader"
+    helper_furl = None
+    helper_connected = False
+
     def upload(self, uploadable):
         d = uploadable.get_size()
         d.addCallback(lambda size: uploadable.read(size))
@@ -100,8 +103,10 @@ class FakeUploader(service.Service):
             return ur
         d.addCallback(_got_data)
         return d
+
     def get_helper_info(self):
-        return (None, False)
+        return (self.helper_furl, self.helper_connected)
+
 
 def build_one_ds():
     ds = DownloadStatus("storage_index", 1234)
@@ -609,6 +614,36 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
         d.addCallback(_check)
         return d
 
+    def test_helper_status(self):
+        d = defer.succeed(None)
+
+        # set helper furl to None
+        def _set_helper_not_configured2(ign):
+            self.s.uploader.helper_furl = None
+            return self.GET("/")
+        d.addCallback(_set_helper_not_configured2)
+        d.addCallback(lambda res:
+                      self.failUnlessIn('Connected to helper?: <span>not configured</span>', res))
+
+        # enable helper, not connected
+        def _set_helper_not_connected(ign):
+            self.s.uploader.helper_furl = "pb://someHelper"
+            self.s.uploader.helper_connected = False
+            return self.GET("/")
+        d.addCallback(_set_helper_not_connected)
+        d.addCallback(lambda res:
+                      self.failUnlessIn('Connected to helper?: <span>no</span>', res))
+
+        # enable helper, connected
+        def _set_helper_connected(ign):
+            self.s.uploader.helper_furl = "pb://someHelper"
+            self.s.uploader.helper_connected = True
+            return self.GET("/")
+        d.addCallback(_set_helper_connected)
+        d.addCallback(lambda res:
+                      self.failUnlessIn('Connected to helper?: <span>yes</span>', res))
+        return d
+
     def test_storage(self):
         d = self.GET("/storage")
         def _check(res):
index 2cd315d99b373c71b9b5fd910194fa07a8ca6cec..6f467cc8681e3a53b23b74956863fa0a4702f0f7 100644 (file)
@@ -200,6 +200,7 @@ class Root(rend.Page):
 
     def data_introducer_furl(self, ctx, data):
         return self.client.introducer_furl
+
     def data_connected_to_introducer(self, ctx, data):
         if self.client.connected_to_introducer():
             return "yes"
@@ -212,12 +213,19 @@ class Root(rend.Page):
             return None
         furl, connected = uploader.get_helper_info()
         return furl
+
+    def data_connected_to_helper_description(self, ctx, data):
+        return self.data_connected_to_helper(ctx, data).replace('-', ' ')
+
     def data_connected_to_helper(self, ctx, data):
         try:
             uploader = self.client.getServiceNamed("uploader")
         except KeyError:
             return "no" # we don't even have an Uploader
         furl, connected = uploader.get_helper_info()
+
+        if furl is None:
+            return "not-configured"
         if connected:
             return "yes"
         return "no"
index 297bbe4403141c1a498d7df408abb874f08e3115..4a94d49c09aa8555ea743634dddb79dd418ca9ac 100644 (file)
@@ -6,7 +6,7 @@ pre.overflow {
                padding: .25em;
                overflow: auto;
                }
-               
+
 /* ----------------------------------------------------------------------- */
 
 /* colors borrowed from the Allmydata logo */
@@ -34,7 +34,6 @@ th {
 
 .table-headings-top th {
     text-align: center;
-    
 }
 .table-headings-left th {
     text-align: right;
@@ -52,6 +51,10 @@ legend {
   border: 1px solid #F00;
   background-color: #FBB;
 }
+.connected-not-configured {
+  border: 1px solid #AAA;
+  background-color: #FFF;
+}
 
 .encoded, .nodeid {
   font-family: monospace;
index b493ee79d30308af2b5a72c54588e98a44bac89f..f88c02ca2309e4a5a902c74945af1a9243f09188 100644 (file)
@@ -47,7 +47,7 @@
   <div>
     <n:attr name="class">connected-<n:invisible n:render="string" n:data="connected_to_helper" /></n:attr>
     <div>Helper: <span n:render="string" n:data="helper_furl" /></div>
-    <div>Connected to helper?: <span n:render="string" n:data="connected_to_helper" /></div>
+    <div>Connected to helper?: <span n:render="string" n:data="connected_to_helper_description" /></div>
   </div>
 
   <p>Connected to <span n:render="string" n:data="connected_storage_servers" />