@check_job_permission
def job_attempt_logs_json(request, job, attempt_index=0, name='syslog', offset=0):
  """For async log retrieval as Yarn servers are very slow"""

  try:
    attempt_index = int(attempt_index)
    attempt = job.job_attempts['jobAttempt'][attempt_index]
    log_link = attempt['logsLink']
  except (__HOLE__, RestException), e:
    raise KeyError(_("Cannot find job attempt '%(id)s'.") % {'id': job.jobId}, e)

  link = '/%s/' % name
  params = {}
  if offset and int(offset) >= 0:
    params['start'] = offset

  root = Resource(get_log_client(log_link), urlparse.urlsplit(log_link)[2], urlencode=False)
  debug_info = ''
  try:
    response = root.get(link, params=params)
    log = html.fromstring(response, parser=html.HTMLParser()).xpath('/html/body/table/tbody/tr/td[2]')[0].text_content()
  except Exception, e:
    log = _('Failed to retrieve log: %s' % e)
    try:
      debug_info = '\nLog Link: %s' % log_link
      debug_info += '\nHTML Response: %s' % response
      LOG.error(debug_info)
    except:
      LOG.exception('failed to create debug info')

  response = {'log': LinkJobLogs._make_hdfs_links(log), 'debug': debug_info}

  return JsonResponse(response)
dataset/ETHPy150Open cloudera/hue/apps/jobbrowser/src/jobbrowser/views.py/job_attempt_logs_json