import allmydata # to display import path
from allmydata import get_package_versions_string
-from allmydata.util import idlib, log
+from allmydata.util import log
from allmydata.interfaces import IFileNode
from allmydata.web import filenode, directory, unlinked, status, operations
from allmydata.web import storage
from allmydata.web.common import abbreviate_size, getxmlfile, WebError, \
- get_arg, RenderMixin, get_format, get_mutable_type
+ get_arg, RenderMixin, get_format, get_mutable_type, TIME_FORMAT
+from allmydata.util.time_format import format_delta
class URIHandler(RenderMixin, rend.Page):
details=get_arg(req, "details", ""),
level=log.WEIRD, umid="LkD9Pw")
req.setHeader("content-type", "text/plain")
- return "Thank you for your report!"
+ return "An incident report has been saved to logs/incidents/ in the node directory."
SPACE = u"\u00A0"*2
addSlash = True
docFactory = getxmlfile("welcome.xhtml")
- def __init__(self, client, clock=None):
+ def __init__(self, client, clock=None, now=None):
rend.Page.__init__(self, client)
self.client = client
# If set, clock is a twisted.internet.task.Clock that the tests
# use to test ophandle expiration.
self.child_operations = operations.OphandleTable(clock)
+ self.now = now
+ if self.now is None:
+ self.now = time.time
try:
s = client.getServiceNamed("storage")
except KeyError:
#child_server # let's reserve this for storage-server-over-HTTP
# FIXME: This code is duplicated in root.py and introweb.py.
+ def data_rendered_at(self, ctx, data):
+ return time.strftime(TIME_FORMAT, time.localtime())
def data_version(self, ctx, data):
return get_package_versions_string()
def data_import_path(self, ctx, data):
return str(allmydata)
- def data_my_nodeid(self, ctx, data):
- return idlib.nodeid_b2a(self.client.nodeid)
+ def render_my_nodeid(self, ctx, data):
+ tubid_s = "TubID: "+self.client.get_long_tubid()
+ return T.td(title=tubid_s)[self.client.get_long_nodeid()]
def data_my_nickname(self, ctx, data):
return self.client.nickname
ctx.fillSlots("peerid", server.get_longname())
ctx.fillSlots("nickname", server.get_nickname())
rhost = server.get_remote_host()
- if rhost:
+ if server.is_connected():
if nodeid == self.client.nodeid:
rhost_s = "(loopback)"
elif isinstance(rhost, address.IPv4Address):
else:
rhost_s = str(rhost)
addr = rhost_s
- connected = "yes"
- since = server.get_last_connect_time()
+ service_connection_status = "Connected"
+ service_connection_status_abs_time, service_connection_status_rel_time = format_delta(server.get_last_connect_time(), self.now())
else:
addr = "N/A"
- connected = "no"
- since = server.get_last_loss_time()
- announced = server.get_announcement_time()
+ service_connection_status = "Disconnected"
+ service_connection_status_abs_time, service_connection_status_rel_time = format_delta(server.get_last_loss_time(), self.now())
+
+ last_received_data_abs_time, last_received_data_rel_time = format_delta(server.get_last_received_data_time(), self.now())
+
announcement = server.get_announcement()
version = announcement["my-version"]
- service_name = announcement["service-name"]
-
- TIME_FORMAT = "%H:%M:%S %d-%b-%Y"
+ available_space = server.get_available_space()
+ if available_space is None:
+ available_space = "N/A"
+ else:
+ available_space = abbreviate_size(available_space)
ctx.fillSlots("address", addr)
- ctx.fillSlots("connected", connected)
- ctx.fillSlots("connected-bool", bool(rhost))
- ctx.fillSlots("since", time.strftime(TIME_FORMAT,
- time.localtime(since)))
- ctx.fillSlots("announced", time.strftime(TIME_FORMAT,
- time.localtime(announced)))
+ ctx.fillSlots("service_connection_status", service_connection_status)
+ ctx.fillSlots("service_connection_status_abs_time", service_connection_status_abs_time)
+ ctx.fillSlots("service_connection_status_rel_time", service_connection_status_rel_time)
+ ctx.fillSlots("last_received_data_abs_time", last_received_data_abs_time)
+ ctx.fillSlots("last_received_data_rel_time", last_received_data_rel_time)
ctx.fillSlots("version", version)
- ctx.fillSlots("service_name", service_name)
+ ctx.fillSlots("available_space", available_space)
return ctx.tag
T.input(type="hidden", name="t", value="report-incident"),
"What went wrong?"+SPACE,
T.input(type="text", name="details"), SPACE,
- T.input(type="submit", value=u"Report \u00BB"),
+ T.input(type="submit", value=u"Save \u00BB"),
]]
return T.div[form]