def _parse_out_hadoop_jobs(log, engine='mr'):
  """
  Ideally, Hive would tell us what jobs it has run directly from the Thrift interface.
  """
  ret = []

  if engine.lower() == 'mr':
    pattern = HADOOP_JOBS_RE
  elif engine.lower() == 'spark':
    pattern = SPARK_APPLICATION_RE
  else:
    raise ValueError(_('Cannot parse job IDs for execution engine %(engine)s') % {'engine': engine})

  for match in pattern.finditer(log):
    job_id = match.group(1)
    if job_id not in ret:
      ret.append(job_id)

  return ret
dataset/ETHPy150Open cloudera/hue/apps/beeswax/src/beeswax/views.py/_parse_out_hadoop_jobs/original