def WriteBrokenClient(uuid, reason, details):
  """Saves a BrokenClient entity to Datastore for the given UUID.

  Args:
    uuid: str, uuid of client.
    reason: str, short description of broken state the client is reporting.
    details: str, details or debugging output of the broken report.
  """
  # If the details string contains facter output, parse it.
  facts = {}
  lines = details.splitlines()
  for line in lines:
    try:
      (key, unused_sep, value) = line.split(' ', 2)
    except __HOLE__:
      continue  # current line was not facter, continue.
    value = value.strip()
    facts[key] = value

  # Update the existing, or create a new ComputerClientBroken entity.
  uuid = common.SanitizeUUID(uuid)
  bc = models.ComputerClientBroken.get_or_insert(uuid)
  bc.broken_datetimes.append(datetime.datetime.utcnow())
  bc.reason = reason
  bc.details = details
  bc.fixed = False  # Previously fixed computers will show up again.
  bc.hostname = facts.get('hostname', '')
  bc.owner = facts.get('primary_user', '')
  bc.serial = facts.get('sp_serial_number', '')
  bc.uuid = uuid
  bc.put()
dataset/ETHPy150Open google/simian/src/simian/mac/munki/common.py/WriteBrokenClient