示例#1
0
 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)
示例#3
0
 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)
示例#4
0
 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)
示例#5
0
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
示例#6
0
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
示例#7
0
 def getAllModels():
     with web.ctx.connFactory() as conn:
         return repository.getAllModels(conn, getMetricDisplayFields(conn))
示例#8
0
 def getAllModels():
   with web.ctx.connFactory() as conn:
     return repository.getAllModels(conn, getMetricDisplayFields(conn))