def _DisplayBrokenClients(self):
    """Displays a report of broken clients."""
    # client with broken python
    py_computers = models.ComputerClientBroken.all().filter('fixed =', False)
    py_computers = list(py_computers)
    for computer in py_computers:
      computer.details = computer.details.replace("'", "\\'")
      computer.details = computer.details.replace('"', "\\'")
      computer.details = re.sub('\n', '<br/>', computer.details)
      computer.broken_datetimes.reverse()
      computer.likely_fixed = False
      # if a UUID is set, attempt to figure out when it last connected.
      if computer.uuid:
        try:
          c_obj = models.Computer.get_by_key_name(computer.uuid)
          if c_obj.preflight_datetime > computer.broken_datetimes[0]:
            computer.likely_fixed = True
        except (IndexError, TypeError, models.db.Error):
          pass

    # clients with zero connection
    q = models.Computer.AllActive().filter(
        'connections_on_corp =', 0).filter('connections_off_corp =', 0).fetch(
            admin.DEFAULT_COMPUTER_FETCH_LIMIT)
    zero_conn_computers = []
    for c in q:
      if c.preflight_count_since_postflight > PREFLIGHT_COUNT_BROKEN_THRESHOLD:
        zero_conn_computers.append(c)
    zero_conn_computers.sort(key=lambda x: x.preflight_datetime, reverse=True)

    # clients with no recent postflight, but recent preflight
    fetch_limit = 1000
    pf_computers = []
    q = models.Computer.AllActive().filter(
        'preflight_count_since_postflight >', PREFLIGHT_COUNT_BROKEN_THRESHOLD)
    i = 0
    for c in q:
      i += 1
      if i >= fetch_limit:  # avoid DeadlineExceededError.
        break
      if not c.preflight_datetime or not c.postflight_datetime:
        continue  # already covered zero connection clients above.
      pf_computers.append(c)
    pf_computers.sort(key=lambda x: x.preflight_datetime, reverse=True)

    self.Render(
        'broken_clients.html',
        {'py_computers': py_computers,
         'zero_conn_computers': zero_conn_computers,
         'pf_computers': pf_computers,
         'is_security_user': auth.IsSecurityUser(),
         'report_type': 'broken_clients',
         'truncated': i >= fetch_limit,
         'preflight_count_broken_threshold': PREFLIGHT_COUNT_BROKEN_THRESHOLD,
        })
dataset/ETHPy150Open google/simian/src/simian/mac/admin/broken_clients.py/BrokenClients._DisplayBrokenClients/original