def _GenerateInstallCounts():

    # Obtain a lock.
    lock_name = 'pkgs_list_cron_lock'
    lock = gae_util.ObtainLock(lock_name)
    if not lock:
      logging.warning('GenerateInstallCounts: lock found; exiting.')
      return

    # Get a list of all packages that have previously been pushed.
    pkgs, unused_dt = models.ReportsCache.GetInstallCounts()

    # Generate a query of all InstallLog entites that haven't been read yet.
    query = models.InstallLog.all().order('server_datetime')
    cursor_obj = models.KeyValueCache.get_by_key_name('pkgs_list_cursor')
    if cursor_obj:
      query.with_cursor(cursor_obj.text_value)

    # Loop over new InstallLog entries.
    try:
      installs = query.fetch(1000)
    except:
      installs = None
    if not installs:
      models.ReportsCache.SetInstallCounts(pkgs)
      gae_util.ReleaseLock(lock_name)
      return

    for install in installs:
      pkg_name = install.package
      if pkg_name not in pkgs:
        pkgs[pkg_name] = {
            'install_count': 0,
            'install_fail_count': 0,
            'applesus': install.applesus,
        }
      if install.IsSuccess():
        pkgs[pkg_name]['install_count'] = (
            pkgs[pkg_name].setdefault('install_count', 0) + 1)
        # (re)calculate avg_duration_seconds for this package.
        if 'duration_seconds_avg' not in pkgs[pkg_name]:
          pkgs[pkg_name]['duration_count'] = 0
          pkgs[pkg_name]['duration_total_seconds'] = 0
          pkgs[pkg_name]['duration_seconds_avg'] = None
        # only proceed if entity has "duration_seconds" property != None.
        if getattr(install, 'duration_seconds', None) is not None:
          pkgs[pkg_name]['duration_count'] += 1
          pkgs[pkg_name]['duration_total_seconds'] += (
              install.duration_seconds)
          pkgs[pkg_name]['duration_seconds_avg'] = int(
              pkgs[pkg_name]['duration_total_seconds'] /
              pkgs[pkg_name]['duration_count'])
      else:
        pkgs[pkg_name]['install_fail_count'] = (
            pkgs[pkg_name].setdefault('install_fail_count', 0) + 1)


    # Update any changed packages.
    models.ReportsCache.SetInstallCounts(pkgs)

    if not cursor_obj:
      cursor_obj = models.KeyValueCache(key_name='pkgs_list_cursor')

    cursor_txt = str(query.cursor())
    cursor_obj.text_value = cursor_txt
    cursor_obj.put()

    # Delete the lock.
    gae_util.ReleaseLock(lock_name)

    deferred.defer(_GenerateInstallCounts)
Fail if the given function doesn't generate the specified warning when
dataset/ETHPy150Open google/simian/src/simian/mac/cron/reports_cache.py/_GenerateInstallCounts--crossover with--dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/trial/unittest.py/_Assertions.failUnlessWarns