mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-29 17:28:53 +00:00
Convert storage.py over to MultiFormatPage
This commit is contained in:
parent
6e4c4b7abc
commit
1e885fa40b
@ -1,7 +1,11 @@
|
||||
|
||||
import time, json
|
||||
from nevow import rend, tags as T, inevow
|
||||
from allmydata.web.common import getxmlfile, abbreviate_time, get_arg
|
||||
from nevow import rend, tags as T
|
||||
from allmydata.web.common import (
|
||||
getxmlfile,
|
||||
abbreviate_time,
|
||||
MultiFormatPage,
|
||||
)
|
||||
from allmydata.util.abbreviate import abbreviate_space
|
||||
from allmydata.util import time_format, idlib
|
||||
|
||||
@ -10,7 +14,7 @@ def remove_prefix(s, prefix):
|
||||
return None
|
||||
return s[len(prefix):]
|
||||
|
||||
class StorageStatus(rend.Page):
|
||||
class StorageStatus(MultiFormatPage):
|
||||
docFactory = getxmlfile("storage_status.xhtml")
|
||||
# the default 'data' argument is the StorageServer instance
|
||||
|
||||
@ -19,13 +23,6 @@ class StorageStatus(rend.Page):
|
||||
self.storage = storage
|
||||
self.nickname = nickname
|
||||
|
||||
def renderHTTP(self, ctx):
|
||||
req = inevow.IRequest(ctx)
|
||||
t = get_arg(req, "t")
|
||||
if t == "json":
|
||||
return self.render_JSON(req)
|
||||
return rend.Page.renderHTTP(self, ctx)
|
||||
|
||||
def render_JSON(self, req):
|
||||
req.setHeader("content-type", "text/plain")
|
||||
d = {"stats": self.storage.get_stats(),
|
||||
@ -266,4 +263,3 @@ class StorageStatus(rend.Page):
|
||||
]]])
|
||||
|
||||
return ctx.tag[p]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user