def _LogInstalls(self, installs, computer):
    """Logs a batch of installs for a given computer.

    Args:
      installs: list, of str install data from a preflight/postflight report.
      computer: models.Computer entity.
    """
    if not installs:
      return

    on_corp = self.request.get('on_corp')
    if on_corp == '1':
      on_corp = True
    elif on_corp == '0':
      on_corp = False
    else:
      on_corp = None

    to_put = []
    for install in installs:
      if install.startswith('Install of'):
        d = {
            'applesus': 'false',
            'duration_seconds': None,
            'download_kbytes_per_sec': None,
            'name': install,
            'status': 'UNKNOWN',
            'version': '',
            'unattended': 'false',
        }
        # support for old 'Install of FooPkg-1.0: SUCCESSFUL' style strings.
        try:
          m = LEGACY_INSTALL_RESULTS_STRING_REGEX.search(install)
          if not m:
            raise ValueError
          elif m.group(3) == INSTALL_RESULT_SUCCESSFUL:
            d['status'] = 0
          else:
            d['status'] = m.group(4)
          d['name'] = m.group(1)
          d['version'] = m.group(2)
        except (IndexError, AttributeError, ValueError):
          logging.warning('Unknown install string format: %s', install)
      else:
        # support for new 'name=pkg|version=foo|...' style strings.
        d = common.KeyValueStringToDict(install)

      name = d.get('display_name', '') or d.get('name', '')
      version = d.get('version', '')
      status = str(d.get('status', ''))
      applesus = common.GetBoolValueFromString(d.get('applesus', '0'))
      unattended = common.GetBoolValueFromString(d.get('unattended', '0'))
      try:
        duration_seconds = int(d.get('duration_seconds', None))
      except (TypeError, ValueError):
        duration_seconds = None
      try:
        dl_kbytes_per_sec = int(d.get('download_kbytes_per_sec', None))
        # Ignore zero KB/s download speeds, as that's how Munki reports
        # unknown speed.
        if dl_kbytes_per_sec == 0:
          dl_kbytes_per_sec = None
      except (TypeError, ValueError):
        dl_kbytes_per_sec = None

      try:
        install_datetime = util.Datetime.utcfromtimestamp(d.get('time', None))
      except ValueError as e:
        logging.info('Ignoring invalid install_datetime: %s', str(e))
        install_datetime = datetime.datetime.utcnow()
      except util.EpochExtremeFutureValueError as e:
        logging.info('Ignoring extreme future install_datetime: %s', str(e))
        install_datetime = datetime.datetime.utcnow()
      except util.EpochFutureValueError:
        install_datetime = datetime.datetime.utcnow()

      pkg = '%s-%s' % (name, version)
      entity = models.InstallLog(
          uuid=computer.uuid, computer=computer, package=pkg, status=status,
          on_corp=on_corp, applesus=applesus, unattended=unattended,
          duration_seconds=duration_seconds, mtime=install_datetime,
          dl_kbytes_per_sec=dl_kbytes_per_sec)
      entity.success = entity.IsSuccess()
      to_put.append(entity)

    gae_util.BatchDatastoreOp(models.db.put, to_put)
dataset/ETHPy150Open google/simian/src/simian/mac/munki/handlers/reports.py/Reports._LogInstalls/original