mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-25 23:51:07 +00:00
Tidy up introweb.
Fix imports; make all parameter names the same; use " for string literals.
This commit is contained in:
parent
e2aba7f4bb
commit
8ce18541c6
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import time, os
|
import time, os
|
||||||
from pkg_resources import resource_filename
|
from pkg_resources import resource_filename
|
||||||
from twisted.web.template import Element, renderer, renderElement, XMLFile
|
from twisted.web.template import Element, XMLFile, renderElement, renderer
|
||||||
from twisted.python.filepath import FilePath
|
from twisted.python.filepath import FilePath
|
||||||
from twisted.web import resource, static
|
from twisted.web import resource, static
|
||||||
import allmydata
|
import allmydata
|
||||||
@ -9,7 +9,6 @@ import json
|
|||||||
from allmydata.version_checks import get_package_versions_string
|
from allmydata.version_checks import get_package_versions_string
|
||||||
from allmydata.util import idlib
|
from allmydata.util import idlib
|
||||||
from allmydata.web.common import (
|
from allmydata.web.common import (
|
||||||
getxmlfile,
|
|
||||||
render_time,
|
render_time,
|
||||||
MultiFormatResource,
|
MultiFormatResource,
|
||||||
SlotsSequenceElement,
|
SlotsSequenceElement,
|
||||||
@ -17,12 +16,13 @@ from allmydata.web.common import (
|
|||||||
|
|
||||||
|
|
||||||
class IntroducerRoot(MultiFormatResource):
|
class IntroducerRoot(MultiFormatResource):
|
||||||
|
|
||||||
def __init__(self, introducer_node):
|
def __init__(self, introducer_node):
|
||||||
super(IntroducerRoot, self).__init__()
|
super(IntroducerRoot, self).__init__()
|
||||||
self.introducer_node = introducer_node
|
self.introducer_node = introducer_node
|
||||||
self.introducer_service = introducer_node.getServiceNamed("introducer")
|
self.introducer_service = introducer_node.getServiceNamed("introducer")
|
||||||
# necessary as a root Resource
|
# necessary as a root Resource
|
||||||
self.putChild('', self)
|
self.putChild("", self)
|
||||||
static_dir = resource_filename("allmydata.web", "static")
|
static_dir = resource_filename("allmydata.web", "static")
|
||||||
for filen in os.listdir(static_dir):
|
for filen in os.listdir(static_dir):
|
||||||
self.putChild(filen, static.File(os.path.join(static_dir, filen)))
|
self.putChild(filen, static.File(os.path.join(static_dir, filen)))
|
||||||
@ -61,10 +61,10 @@ class IntroducerRootElement(Element):
|
|||||||
self.introducer_node = introducer_node
|
self.introducer_node = introducer_node
|
||||||
self.introducer_service = introducer_service
|
self.introducer_service = introducer_service
|
||||||
self.node_data_dict = {
|
self.node_data_dict = {
|
||||||
'my_nodeid': idlib.nodeid_b2a(self.introducer_node.nodeid),
|
"my_nodeid": idlib.nodeid_b2a(self.introducer_node.nodeid),
|
||||||
'version': get_package_versions_string(),
|
"version": get_package_versions_string(),
|
||||||
'import_path': str(allmydata).replace("/", "/ "), # XXX kludge for wrapping
|
"import_path": str(allmydata).replace("/", "/ "), # XXX kludge for wrapping
|
||||||
'rendered_at': render_time(time.time()),
|
"rendered_at": render_time(time.time()),
|
||||||
}
|
}
|
||||||
|
|
||||||
@renderer
|
@renderer
|
||||||
@ -72,7 +72,7 @@ class IntroducerRootElement(Element):
|
|||||||
return tag.fillSlots(**self.node_data_dict)
|
return tag.fillSlots(**self.node_data_dict)
|
||||||
|
|
||||||
@renderer
|
@renderer
|
||||||
def announcement_summary(self, req, data):
|
def announcement_summary(self, req, tag):
|
||||||
services = {}
|
services = {}
|
||||||
for ad in self.introducer_service.get_announcements():
|
for ad in self.introducer_service.get_announcements():
|
||||||
if ad.service_name not in services:
|
if ad.service_name not in services:
|
||||||
@ -84,7 +84,7 @@ class IntroducerRootElement(Element):
|
|||||||
for service_name in service_names])
|
for service_name in service_names])
|
||||||
|
|
||||||
@renderer
|
@renderer
|
||||||
def client_summary(self, req, data):
|
def client_summary(self, req, tag):
|
||||||
counts = {}
|
counts = {}
|
||||||
for s in self.introducer_service.get_subscribers():
|
for s in self.introducer_service.get_subscribers():
|
||||||
if s.service_name not in counts:
|
if s.service_name not in counts:
|
||||||
@ -110,7 +110,7 @@ class IntroducerRootElement(Element):
|
|||||||
return SlotsSequenceElement(tag, services)
|
return SlotsSequenceElement(tag, services)
|
||||||
|
|
||||||
@renderer
|
@renderer
|
||||||
def subscribers(self, ctx, tag):
|
def subscribers(self, req, tag):
|
||||||
subscribers = [{
|
subscribers = [{
|
||||||
"nickname": s.nickname,
|
"nickname": s.nickname,
|
||||||
"tubid": s.tubid,
|
"tubid": s.tubid,
|
||||||
|
Loading…
Reference in New Issue
Block a user