'Gather info for the status notification e-mails.
If needed, we could start using the Django templating engine to create
the subject and the e-mail body, but that doesn\'t seem necessary right
now.
:param status: Job status text. Mandatory.
:param summary: Job summary text. Optional.
:param hostname: A hostname for the job. Optional.
:return: Tuple (subject, body) for the notification e-mail.'

def _get_status_email_contents(self, status, summary=None, hostname=None):

    job_stats = Job(id=self.job.id).get_execution_details()
    subject = ('Autotest    #%s' % self.job.id)
    if (hostname is not None):
        subject += ('    |    %s    on    %s' % (self.job.name, hostname))
    else:
        subject += ('    |    %s' % self.job.name)
    status = status.split()[(-1)]
    if (status == 'Completed'):
        subject += ('    |    success:    %.2f%%' % job_stats['success_rate'])
    else:
        subject += ('    |    %s' % status)
    body = ''
    if (int(job_stats['total_executed']) > 0):
        body += ('run:    %s    |    pass:    %s    |    skip:    %s    |    fail:    %s' % (job_stats['total_executed'], job_stats['total_passed'], job_stats['total_skipped'], job_stats['total_failed']))
        e_time = job_stats['execution_time']
        if (e_time not in ['(could    not    determine)', '(none)']):
            body += ('    |    runtime:    %s' % e_time)
        if (status == 'Completed'):
            body += ('    |    success:    %.2f%%' % job_stats['success_rate'])
        else:
            body += ('\n[Warning]    Job    status:    %s' % status)
        body += ('\n%s\n\n' % self._view_job_url())
    body += job_stats['fail_detail']
    body += job_stats['warn_detail']
    body += job_stats['skip_detail']
    body += job_stats['pass_detail']
    keyval_list = job_stats['keyval_dict_list']
    if keyval_list:
        for kv in keyval_list:
            (k, v) = kv.items()[0]
            body += ('%s:\n' % k)
            for part in v.split():
                body += ('        %s\n' % part)
            body += '\n'
    if (hostname is not None):
        body += ('Job    was    run    on    host    %s\n' % hostname)
    body += ('For    more    details,    check    the    full    report    on    the    web:\n%s\n' % self._view_job_url())
    return (subject, body)
