Exemplo n.º 1
0
def create_datum(campaign, ns, obj = {}):
  ns = ns.strip('/').replace('/', '.')    
  value = obj.get('value')
  kind = obj.get('type', 'number')
    
  datum = Storage(campaign = campaign, namespace = ns, type = kind, value = value)
  
  key = '%s.%s' % (campaign, ns)
  if (not _Stats.has_key(key)):
    datum.stats = _Stats[key] = Statistics.get_by_key_name_or_insert(key, campaign = campaign, namespace = ns)
    datum.stats.type = kind
  else:
    datum.stats = _Stats[key]
  
  helper = stat.get(kind)
  helper.prepare(datum)
  if not hasattr(datum, '_invalid'):
    helper.calculate(datum)
    return datum
  else:
    logging.warning('datum invalid %s/%s, %s, %s' % (campaign, ns, datum.value, datum.type))
Exemplo n.º 2
0
 def setUp(self):
   self.number = stat.get('number')
   self.string = stat.get('string')
   self.datetime = stat.get('datetime')
   self.none = stat.get('none')