def RetrieveEntropy():
  try:
    rc, stdout, _ = Exec(['/usr/sbin/ioreg', '-l'])
  except ExecError:
    raise RetrieveEntropyError('/usr/sbin/ioreg not executable')

  if rc != 0:
    raise RetrieveEntropyError('ioreg exit status %s' % rc)
  if not stdout:
    raise RetrieveEntropyError('ioreg no or insufficient stdout')

  interesting_lines_re = re.compile(
      '(HIDIdleTime|IODeviceMemory|sessionID|DriverPMAssertionsDetailed|'
      'TimeSinceDeviceIdle|Statistics|IdleTimerPeriod|IOKitDiagnostics|'
      'IOPowerManagement|IOPowerManagement|acpi-mmcfg-seg0|clock-frequency|'
      'pwm-info|HIDPointerAccelerationTable|HIDScrollAccelerationTable|'
      'frequency)')

  output = []
  for l in stdout.splitlines():
    if interesting_lines_re.search(l):
      l = l.strip()
      output.append(l)

  output = ''.join(output)

  if not output:
    raise RetrieveEntropyError('ioreg unexpected output yieled no entropy')

  return output
Retrieve entropy bytes from a trusted source and return them as a str.
dataset/ETHPy150Open google/cauliflowervest/src/cauliflowervest/client/util.py/RetrieveEntropy