'Notify about the result of a job. Will always print, if email data
is provided, will send email for it as well.
job: job object to notify about
email_from: send notification email upon completion from here
email_from: send notification email upon completion to here'

def result_notify(self, job, email_from, email_to):

    if (job.result is True):
        subject = 'Testing    PASSED:    '
    else:
        subject = 'Testing    FAILED:    '
    subject += ('%s    :    %s\n' % (job.name, job.id))
    text = []
    for platform in job.results_platform_map:
        for status in job.results_platform_map[platform]:
            if (status == 'Total'):
                continue
            for host in job.results_platform_map[platform][status]:
                text.append(('%20s    %10s    %10s' % (platform, status, host)))
                if (status == 'Failed'):
                    for test_status in job.test_status[host].fail:
                        text.append(('(%s,    %s)    :    %s' % (host, test_status.test_name, test_status.reason)))
                    text.append('')
    base_url = ('http://' + self.server)
    params = ('columns=test', 'rows=machine_group', ("condition=tag~'%s-%%25'" % job.id), 'title=Report')
    query_string = '&'.join(params)
    url = ('%s/tko/compose_query.cgi?%s' % (base_url, query_string))
    text.append((url + '\n'))
    url = ('%s/afe/#tab_id=view_job&object_id=%s' % (base_url, job.id))
    text.append((url + '\n'))
    smtp_info = {}
    smtp_info['server'] = settings.get_value('SERVER', 'smtp_server', default='localhost')
    smtp_info['port'] = settings.get_value('SERVER', 'smtp_port', default='')
    smtp_info['user'] = settings.get_value('SERVER', 'smtp_user', default='')
    smtp_info['password'] = settings.get_value('SERVER', 'smtp_password', default='')
    body = '\n'.join(text)
    print '---------------------------------------------------'
    print 'Subject:    ', subject
    print body
    print '---------------------------------------------------'
    if (email_from and email_to):
        print 'Sending    email    ...'
        mail.send(from_address=email_from, to_addresses=email_to, subject=subject, body=body, smtp_info=smtp_info)
    print
