If a helper is not configured, make the banner on the welcome page say that, and have a white background.

fixes #1735

Author: kick
Signed-off-by: David-Sarah Hopwood <davidsarah@jacaranda.org>
This commit is contained in:
David-Sarah Hopwood 2012-12-29 04:17:00 +00:00
parent eba64f2aba
commit a5895b9d59
6 changed files with 71 additions and 4 deletions

View File

@ -306,6 +306,9 @@ class Client(node.Node, pollmixin.PollMixin):
def init_client(self): def init_client(self):
helper_furl = self.get_config("client", "helper.furl", None) helper_furl = self.get_config("client", "helper.furl", None)
if helper_furl in ("None", ""):
helper_furl = None
DEP = self.DEFAULT_ENCODING_PARAMETERS DEP = self.DEFAULT_ENCODING_PARAMETERS
DEP["k"] = int(self.get_config("client", "shares.needed", DEP["k"])) DEP["k"] = int(self.get_config("client", "shares.needed", DEP["k"]))
DEP["n"] = int(self.get_config("client", "shares.total", DEP["n"])) DEP["n"] = int(self.get_config("client", "shares.total", DEP["n"]))

View File

@ -172,6 +172,24 @@ class Basic(testutil.ReallyEqualMixin, unittest.TestCase):
self.failUnless("node.uptime" in stats) self.failUnless("node.uptime" in stats)
self.failUnless(isinstance(stats["node.uptime"], float)) 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.util.log.msg')
@mock.patch('allmydata.frontends.drop_upload.DropUploader') @mock.patch('allmydata.frontends.drop_upload.DropUploader')
def test_create_drop_uploader(self, mock_drop_uploader, mock_log_msg): def test_create_drop_uploader(self, mock_drop_uploader, mock_log_msg):

View File

@ -80,6 +80,9 @@ class FakeNodeMaker(NodeMaker):
class FakeUploader(service.Service): class FakeUploader(service.Service):
name = "uploader" name = "uploader"
helper_furl = None
helper_connected = False
def upload(self, uploadable): def upload(self, uploadable):
d = uploadable.get_size() d = uploadable.get_size()
d.addCallback(lambda size: uploadable.read(size)) d.addCallback(lambda size: uploadable.read(size))
@ -100,8 +103,10 @@ class FakeUploader(service.Service):
return ur return ur
d.addCallback(_got_data) d.addCallback(_got_data)
return d return d
def get_helper_info(self): def get_helper_info(self):
return (None, False) return (self.helper_furl, self.helper_connected)
def build_one_ds(): def build_one_ds():
ds = DownloadStatus("storage_index", 1234) ds = DownloadStatus("storage_index", 1234)
@ -609,6 +614,36 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
d.addCallback(_check) d.addCallback(_check)
return d 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): def test_storage(self):
d = self.GET("/storage") d = self.GET("/storage")
def _check(res): def _check(res):

View File

@ -200,6 +200,7 @@ class Root(rend.Page):
def data_introducer_furl(self, ctx, data): def data_introducer_furl(self, ctx, data):
return self.client.introducer_furl return self.client.introducer_furl
def data_connected_to_introducer(self, ctx, data): def data_connected_to_introducer(self, ctx, data):
if self.client.connected_to_introducer(): if self.client.connected_to_introducer():
return "yes" return "yes"
@ -212,12 +213,19 @@ class Root(rend.Page):
return None return None
furl, connected = uploader.get_helper_info() furl, connected = uploader.get_helper_info()
return furl 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): def data_connected_to_helper(self, ctx, data):
try: try:
uploader = self.client.getServiceNamed("uploader") uploader = self.client.getServiceNamed("uploader")
except KeyError: except KeyError:
return "no" # we don't even have an Uploader return "no" # we don't even have an Uploader
furl, connected = uploader.get_helper_info() furl, connected = uploader.get_helper_info()
if furl is None:
return "not-configured"
if connected: if connected:
return "yes" return "yes"
return "no" return "no"

View File

@ -6,7 +6,7 @@ pre.overflow {
padding: .25em; padding: .25em;
overflow: auto; overflow: auto;
} }
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* colors borrowed from the Allmydata logo */ /* colors borrowed from the Allmydata logo */
@ -34,7 +34,6 @@ th {
.table-headings-top th { .table-headings-top th {
text-align: center; text-align: center;
} }
.table-headings-left th { .table-headings-left th {
text-align: right; text-align: right;
@ -52,6 +51,10 @@ legend {
border: 1px solid #F00; border: 1px solid #F00;
background-color: #FBB; background-color: #FBB;
} }
.connected-not-configured {
border: 1px solid #AAA;
background-color: #FFF;
}
.encoded, .nodeid { .encoded, .nodeid {
font-family: monospace; font-family: monospace;

View File

@ -47,7 +47,7 @@
<div> <div>
<n:attr name="class">connected-<n:invisible n:render="string" n:data="connected_to_helper" /></n:attr> <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>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> </div>
<p>Connected to <span n:render="string" n:data="connected_storage_servers" /> <p>Connected to <span n:render="string" n:data="connected_storage_servers" />