def GET(self): with web.ctx.connFactory() as conn: metrics = repository.getCustomMetrics(conn, getMetricDisplayFields(conn)) convertedMetrics = [convertMetricRowToMetricDict(metric) for metric in metrics] self.addStandardHeaders() return json.dumps(convertedMetrics)
def GET(self): with web.ctx.connFactory() as conn: metrics = repository.getCustomMetrics(conn, getMetricDisplayFields(conn)) convertedMetrics = [ convertMetricRowToMetricDict(metric) for metric in metrics ] self.addStandardHeaders() return json.dumps(convertedMetrics)
def getModel(metricId): try: with web.ctx.connFactory() as conn: metric = repository.getMetric(conn, metricId, getMetricDisplayFields(conn)) return metric except app_exceptions.ObjectNotFoundError: raise web.notfound( "ObjectNotFoundError Metric not found: Metric ID: %s" % metricId)
def getModel(metricId): try: with web.ctx.connFactory() as conn: metric = repository.getMetric(conn, metricId, getMetricDisplayFields(conn)) return metric except app_exceptions.ObjectNotFoundError: raise web.notfound("ObjectNotFoundError Metric not found: Metric ID: %s" % metricId)
def formatMetricRowProxy(metricObj): if metricObj.tag_name is not None and len(metricObj.tag_name) > 0: displayName = "%s (%s)" % (metricObj.tag_name, metricObj.server) else: displayName = metricObj.server if (hasattr(metricObj, "parameters") and isinstance(metricObj.parameters, basestring)): parameters = json.loads(metricObj.parameters) else: parameters = metricObj.parameters engine = repository.engineFactory() allowedKeys = set([col.name for col in getMetricDisplayFields(engine)]) metricDict = dict((col, getattr(metricObj, col)) for col in metricObj.keys() if col in allowedKeys) metricDict["display_name"] = displayName metricDict["parameters"] = parameters return metricDict
def getAllModels(): with web.ctx.connFactory() as conn: return repository.getAllModels(conn, getMetricDisplayFields(conn))