return self.status
def set_status(self, status):
self.status = status
-
-class MonitorTable:
- def __init__(self):
- self.handles = {} # maps ophandle (an arbitrary string) to a Monitor
- # TODO: all timeouts, handle lifetime, retain-for=, etc, goes here.
- # self.handles should probably be a WeakValueDictionary, and we need
- # a table of timers, and operations which have finished should be
- # handled slightly differently.
-
- def get_monitor(self, handle):
- return self.handles.get(handle)
-
- def add_monitor(self, handle, monitor):
- self.handles[handle] = monitor
-
- def delete_monitor(self, handle):
- if handle in self.handles:
- del self.handles[handle]
client.getPage, url, method="DELETE")
return d
+ def test_bad_ophandle(self):
+ url = self.webish_url + "/operations/bogus?t=status"
+ d = self.shouldHTTPError2("test_bad_ophandle", 400, "400 Bad Request",
+ "unknown/expired handle 'bogus'",
+ client.getPage, url)
+ return d
+
+ def test_incident(self):
+ d = self.POST("/report_incident", details="eek")
+ def _done(res):
+ self.failUnless("Thank you for your report!" in res, res)
+ d.addCallback(_done)
+ return d
+
+
class Util(unittest.TestCase):
def test_abbreviate_time(self):
self.failUnlessEqual(common.abbreviate_time(None), "")
def text(self, ctx):
inevow.IRequest(ctx).setHeader("content-type", "text/plain")
lines = []
- if self.monitor.is_finished():
- lines.append("finished: yes")
- else:
- lines.append("finished: no")
+ is_finished = self.monitor.is_finished()
+ lines.append("finished: " + {True: "yes", False: "no"}[is_finished])
for (path, cap) in self.monitor.get_status():
lines.append(self.slashify_path(path) + " " + cap)
return "\n".join(lines) + "\n"
if output == "json":
return self.json(ctx)
# plain text
- if self.monitor.is_finished():
- output = "finished: true\n"
+ is_finished = self.monitor.is_finished()
+ output = "finished: " + {True: "yes", False: "no"}[is_finished] + "\n"
+ if is_finished:
stats = self.monitor.get_status()
total = (stats.get("size-immutable-files", 0)
+ stats.get("size-mutable-files", 0)
+ stats.get("size-directories", 0))
output += "size: %d\n" % total
- else:
- output = "finished: false\n"
return output
def json(self, ctx):