def run(self):
        client = get_client(self.parent)
        base_url = get_base_url(self.parent)
        uuid_length = get_uuid_length(self["long"])

        d = combined_state(client, base_url, self["deleted"])

        def got_results(results):
            rows = []
            for result in results:
                rows.append([
                    result["dataset_id"], result["size"], result["meta"],
                    result["status"],
                    ("<missing>" if result["node"] is None else
                     result["node"]["uuid"][:uuid_length] + " (" +
                     result["node"]["host"] + ")")
                ])
            table = get_table()
            table.set_cols_align(["l", "l", "l", "l", "l"])
            rows = [["", "", "", "", ""]] + [[
                "DATASET", "SIZE", "METADATA", "STATUS", "SERVER"
            ]] + rows
            table.add_rows(rows)
            print table.draw() + "\n"

        d.addCallback(got_results)
        return d
    def run(self):
        client = get_client(self.parent)
        base_url = get_base_url(self.parent)
        uuid_length = get_uuid_length(self["long"])

        d = combined_state(client, base_url, self["deleted"])

        def got_results(results):
            rows = []
            for result in results:
                rows.append(
                    [
                        result["dataset_id"],
                        result["size"],
                        result["meta"],
                        result["status"],
                        (
                            "<missing>"
                            if result["node"] is None
                            else result["node"]["uuid"][:uuid_length] + " (" + result["node"]["host"] + ")"
                        ),
                    ]
                )
            table = get_table()
            table.set_cols_align(["l", "l", "l", "l", "l"])
            rows = [["", "", "", "", ""]] + [["DATASET", "SIZE", "METADATA", "STATUS", "SERVER"]] + rows
            table.add_rows(rows)
            print table.draw() + "\n"

        d.addCallback(got_results)
        return d
 def render_GET(self, request):
     d = combined_state(get_client(), get_base_url(), deleted=True)
     def got_state(result):
         request.setHeader("content-type", "application/json")
         request.setHeader("access-control-allow-origin", "*")
         request.write(json.dumps(result))
         request.finish()
     d.addCallback(got_state)
     d.addErrback(log.err, "while trying to GET combined state")
     return server.NOT_DONE_YET
    def render_GET(self, request):
        d = combined_state(get_client(), get_base_url(), deleted=False)

        def got_state(result):
            request.setHeader("content-type", "application/json")
            request.setHeader("access-control-allow-origin", "*")
            request.write(json.dumps(result))
            request.finish()

        d.addCallback(got_state)
        d.addErrback(log.err, "while trying to GET combined state")
        return server.NOT_DONE_YET
 def render_GET(self, request):
     d = combined_state(get_client(), get_base_url(), deleted=False)
     def got_state(results):
         request.setHeader("content-type", "application/json")
         request.setHeader("access-control-allow-origin", "*")
         for result in results:
             if result["dataset_id"] == self.dataset_id:
                 request.write(json.dumps(result))
                 request.finish()
                 return
         request.setResponseCode(400)
         request.write(json.dumps(dict(
             error="unable to find %s" % (self.dataset_id,))))
         request.finish()
     d.addCallback(got_state)
     d.addErrback(log.err, "while trying to GET child dataset")
     return server.NOT_DONE_YET
    def render_GET(self, request):
        d = combined_state(get_client(), get_base_url(), deleted=False)

        def got_state(results):
            request.setHeader("content-type", "application/json")
            request.setHeader("access-control-allow-origin", "*")
            for result in results:
                if result["dataset_id"] == self.dataset_id:
                    request.write(json.dumps(result))
                    request.finish()
                    return
            request.setResponseCode(400)
            request.write(
                json.dumps(
                    dict(error="unable to find %s" % (self.dataset_id, ))))
            request.finish()

        d.addCallback(got_state)
        d.addErrback(log.err, "while trying to GET child dataset")
        return server.NOT_DONE_YET