Exemplo n.º 1
0
 def increment(word, value): 
   entity = WCResults.get_by_key_name(word) 
   if not entity: 
     entity = WCResults(key_name=word, value=value, word=word) 
   else: 
     entity.value += value 
   entity.put() 
Exemplo n.º 2
0
def fsm_calculate_run_time():
  """ Fantasm does not give call backs when its done. Must figure it out
      with another job using the last modified date on output entities
  """
  # Get the last job which was run for wordcount/fsm
  q = Record.all() 
  q.filter('engine_type =','fsm')
  q.filter('benchmark =','wordcount')
  q.order('-start')
  results = q.fetch(1)
  if len(results) == 0:
    logging.error("Unable to find a record for fsm/wordcount")
    return False

  q = None
  record = None
  for ii in results:
    if ii.state == "Done":
      logging.error("Last FSM end time has already been calculated")
    q = WCResults.all()
    if not q:
      logging.error("No query returned for WordCount results")
      return False
    record = ii

  max_date = None 
  while True:
    results = q.fetch(1000)  
    for ii in results:
      date = ii.modifiedDate
      if max_date == None or max_date < date:
        max_date = date 
    if len(results) < 1000:
      break;
  record.state = "Done"
  record.end = max_date
  delta = (record.end - record.start)
  record.total = float(delta.days * 86400 + delta.seconds) + float(delta.microseconds)/1000000
  record.put()
  return True