def IsCronJobFailing(cron_job):
  """Returns True if there are more than 1 failures during last 4 runs."""
  statuses = itertools.islice(
      cron_job.GetValuesForAttribute(cron_job.Schema.LAST_RUN_STATUS), 0, 4)

  failures_count = 0
  for status in statuses:
    if status.status != grr_rdf.CronJobRunStatus.Status.OK:
      failures_count += 1

  return failures_count >= 2
dataset/ETHPy150Open google/grr/grr/gui/api_plugins/cron.py/IsCronJobFailing/original