def get_verifier(self):
return IDirnodeURI(self._uri).get_verifier()
+ def check(self):
+ verifier = self.get_verifier()
+ return self._client.getServiceNamed("checker").check(verifier)
+
def get_child_at_path(self, path):
if not path:
return defer.succeed(self)
def get_verifier(self):
return IFileURI(self.uri).get_verifier()
+ def check(self):
+ verifier = self.get_verifier()
+ return self._client.getServiceNamed("checker").check(verifier)
+
def download(self, target):
downloader = self._client.getServiceNamed("downloader")
return downloader.download(self.uri, target)
it holds a share for the file or directory.
"""
+ def check():
+ """Perform a file check. See IChecker.check for details."""
+
class IDirectoryNode(Interface):
def is_mutable():
"""Return True if this directory is mutable, False if it is read-only.
it holds a share for the file or directory.
"""
+ def check():
+ """Perform a file check. See IChecker.check for details."""
+
def list():
"""I return a Deferred that fires with a dictionary mapping child
name to an IFileNode or IDirectoryNode."""
<td>other representations</td>
<td></td>
<td></td>
+ <td></td>
+ <td>Checker Results</td>
</tr>
<tr n:pattern="item" n:render="row">
<td><n:slot name="filename"/></td>
<td><n:slot name="data"/></td>
<td><n:slot name="delete"/></td>
<td><n:slot name="rename"/></td>
+ <td><n:slot name="check"/></td>
+ <td><n:slot name="checker_results"/></td>
</tr>
<tr n:pattern="empty"><td>directory is empty!</td></tr>
else:
delete = "-"
rename = "-"
+
ctx.fillSlots("delete", delete)
ctx.fillSlots("rename", rename)
+ check = T.form(action=url.here, method="post")[
+ T.input(type='hidden', name='t', value='check'),
+ T.input(type='hidden', name='name', value=name),
+ T.input(type='hidden', name='when_done', value=url.here),
+ T.input(type='submit', value='check', name="check"),
+ ]
+ ctx.fillSlots("check", check)
# build the base of the uri_link link url
uri_link = "/uri/" + urllib.quote(target.get_uri().replace("/", "!"))
ctx.fillSlots("data", childdata)
+ checker = IClient(ctx).getServiceNamed("checker")
+ checker_results = checker.checker_results_for(target.get_verifier())
+ recent_results = reversed(checker_results[-5:])
+ if IFileNode.providedBy(target):
+ results = ("[" +
+ ", ".join(["%d/%d" % (found, needed)
+ for (when, (needed, total, found, sharemap))
+ in recent_results]) +
+ "]")
+ elif IDirectoryNode.providedBy(target):
+ results = ("[" +
+ "".join([{True:"+",False:"-"}[res]
+ for (when, res) in recent_results]) +
+ "]")
+ else:
+ results = "%d results" % len(checker_results)
+ ctx.fillSlots("checker_results", results)
+
return ctx.tag
def render_forms(self, ctx, data):
def _done(newnode):
return newnode.get_uri()
d.addCallback(_done)
+ elif t == "check":
+ d = self._node.get(name)
+ def _got_child(child_node):
+ d2 = child_node.check()
+ def _done(res):
+ log.msg("checked %s, results %s" % (child_node, res))
+ return res
+ d2.addCallback(_done)
+ return d2
+ d.addCallback(_got_child)
else:
print "BAD t=%s" % t
return "BAD t=%s" % t