def get(self, path): # pylint: disable=W0221 """Renders a GET request, by showing this nodes stats and children.""" path = path or '' path = path.lstrip('/') parts = path.split('/') if not parts[0]: parts = parts[1:] statDict = util.lookup(scales.getStats(), parts) if statDict is None: self.set_status(404) self.finish('Path not found.') return outputFormat = self.get_argument('format', default='html') query = self.get_argument('query', default=None) if outputFormat == 'json': formats.jsonFormat(self, statDict, query) elif outputFormat == 'prettyjson': formats.jsonFormat(self, statDict, query, pretty=True) else: formats.htmlHeader(self, '/' + path, self.serverName, query) formats.htmlFormat(self, tuple(parts), statDict, query) return ''
def bottlestats(server_name, path=''): """Renders a GET request, by showing this nodes stats and children.""" path = path.lstrip('/') parts = path.split('/') if not parts[0]: parts = parts[1:] stat_dict = util.lookup(scales.getStats(), parts) if stat_dict is None: abort(404, "Not Found") return output = StringIO() output_format = request.query.get('format', 'html') query = request.query.get('query', None) if output_format == 'json': response.content_type = "application/json" formats.jsonFormat(output, stat_dict, query) elif output_format == 'prettyjson': formats.jsonFormat(output, stat_dict, query, pretty=True) response.content_type = "application/json" else: formats.htmlHeader(output, '/' + path, server_name, query) formats.htmlFormat(output, tuple(parts), stat_dict, query) response.content_type = "text/html" return output.getvalue()
def render_GET(self, request): """Renders a GET request, by showing this nodes stats and children.""" fullPath = request.path.split("/") if not fullPath[-1]: fullPath = fullPath[:-1] parts = fullPath[2:] statDict = util.lookup(scales.getStats(), parts) if statDict is None: request.setResponseCode(404) return "Path not found." if "query" in request.args: query = request.args["query"][0] else: query = None if "format" in request.args and request.args["format"][0] == "json": request.headers["content-type"] = "text/javascript; charset=UTF-8" formats.jsonFormat(request, statDict, query) elif "format" in request.args and request.args["format"][0] == "prettyjson": request.headers["content-type"] = "text/javascript; charset=UTF-8" formats.jsonFormat(request, statDict, query, pretty=True) else: formats.htmlHeader(request, "/" + "/".join(parts), self.serverName, query) formats.htmlFormat(request, tuple(parts), statDict, query) return ""
def render_GET(self, request): """Renders a GET request, by showing this nodes stats and children.""" fullPath = request.path.split('/') if not fullPath[-1]: fullPath = fullPath[:-1] parts = fullPath[2:] statDict = util.lookup(scales.getStats(), parts) if statDict is None: request.setResponseCode(404) return "Path not found." if 'query' in request.args: query = request.args['query'][0] else: query = None if 'format' in request.args and request.args['format'][0] == 'json': request.headers['content-type'] = 'text/javascript; charset=UTF-8' formats.jsonFormat(request, statDict, query) elif 'format' in request.args and request.args['format'][ 0] == 'prettyjson': request.headers['content-type'] = 'text/javascript; charset=UTF-8' formats.jsonFormat(request, statDict, query, pretty=True) else: formats.htmlHeader(request, '/' + '/'.join(parts), self.serverName, query) formats.htmlFormat(request, tuple(parts), statDict, query) return ''
def get(self, path): # pylint: disable=W0221 """Renders a GET request, by showing this nodes stats and children.""" path = path or "" path = path.lstrip("/") parts = path.split("/") if not parts[0]: parts = parts[1:] statDict = util.lookup(scales.getStats(), parts) if statDict is None: self.set_status(404) self.finish("Path not found.") return outputFormat = self.get_argument("format", default="html") query = self.get_argument("query", default=None) if outputFormat == "json": formats.jsonFormat(self, statDict, query) elif outputFormat == "prettyjson": formats.jsonFormat(self, statDict, query, pretty=True) else: formats.htmlHeader(self, "/" + path, self.serverName, query) formats.htmlFormat(self, tuple(parts), statDict, query) return None
def get(self, path): """Return the `greplin.scales` stats collected so far.""" path = path or '' path = path.lstrip('/') parts = path.split('/') if not parts[0]: parts = parts[1:] statDict = util.lookup(scales.getStats(), parts) serialized = json.dumps(statDict, cls=scales.StatContainerEncoder) self.set_header('Content-Type', 'application/json') self.finish(serialized)
def statsHandler(serverName, path=''): """Renders a GET request, by showing this nodes stats and children.""" path = path.lstrip('/') parts = path.split('/') if not parts[0]: parts = parts[1:] statDict = util.lookup(scales.getStats(), parts) if statDict is None: abort(404, 'No stats found with path /%s' % '/'.join(parts)) output = StringIO() outputFormat = request.args.get('format', 'html') query = request.args.get('query', None) if outputFormat == 'json': formats.jsonFormat(output, statDict, query) elif outputFormat == 'prettyjson': formats.jsonFormat(output, statDict, query, pretty=True) else: formats.htmlHeader(output, '/' + path, serverName, query) formats.htmlFormat(output, tuple(parts), statDict, query) return output.getvalue()
def statsHandler(serverName, path=""): """Renders a GET request, by showing this nodes stats and children.""" path = path.lstrip("/") parts = path.split("/") if not parts[0]: parts = parts[1:] statDict = util.lookup(scales.getStats(), parts) if statDict is None: abort(404) return output = StringIO() outputFormat = request.args.get("format", "html") query = request.args.get("query", None) if outputFormat == "json": formats.jsonFormat(output, statDict, query) elif outputFormat == "prettyjson": formats.jsonFormat(output, statDict, query, pretty=True) else: formats.htmlHeader(output, "/" + path, serverName, query) formats.htmlFormat(output, tuple(parts), statDict, query) return output.getvalue()