Ejemplo n.º 1
0
 def execute(task, stat):
   hists_query = Histogram.all(keys_only = True).filter('statistic =', stat)
   if (hists_query.count(limit = 1)):
     for hist in hists_query.fetch(100):
       db.delete(hist)
   else:
     logging.info('Nothing left of histograms with statistic: %s' % stat)
     db.delete(stat)
     task.delete()
     return True
Ejemplo n.º 2
0
 def execute(task, campaign):
   storage_query = Storage.all().filter('campaign =', campaign)
   if (storage_query.count(limit = 1)):
     for datum in storage_query.fetch(100):
       logging.info('checking for stats: %s' % datum.stats.key())
       if (Histogram.has(datum.stats) and not TaskModel.has(datum.stats)): #perhaps use a pickled dictionary instead of count queries
         if (not TaskModel(object = datum.stats, task = 'delete histogram').put()):
           logging.critical('Could not create delete histogram task for %s' % datum.stats)
       else:
         datum.stat.delete()
       datum.delete()
   else:
     task.delete()
     logging.info('Nothing left in storage to clean up for campaign %s' % campaign)
     return True
Ejemplo n.º 3
0
    def tally(cls, stats, name, index):
        if not isinstance(index, str):
            try:
                index = str(index)
            except:
                return cls.critical("Could not str(%s)" % index)

        if name not in stats.histograms:
            stats.histograms.append(name)

        key = "%s.%s" % (stats.key(), name)
        if not _Hists.has_key(key):
            hist = _Hists[key] = Histogram.get_by_key_name_or_insert(key, statistic=stats, name=name)
        else:
            hist = _Hists[key]

        try:
            value = getattr(hist, index)
        except:
            value = 0
        setattr(hist, index, value + 1)