'Write the report to a json file.'

def submit_report(self, dataset, job, tool, **kwargs):

    path = os.path.join(self.report_directory, str(dataset.id))
    with open(path, 'w') as handle:
        data = {'info': job.info, 'id': job.id, 'command_line': job.command_line, 'stderr': job.stderr, 'traceback': job.traceback, 'exit_code': job.exit_code, 'stdout': job.stdout, 'handler': job.handler, 'user': job.get_user().to_dict(), 'tool_version': job.tool_version, 'tool_xml': (str(tool.config_file) if tool else None)}
        if ('email' in kwargs):
            data['email'] = kwargs['email']
        if ('message' in kwargs):
            data['message'] = kwargs['message']
        json.dump(data, handle, indent=2)
    return (('Wrote    error    report    to    %s' % path), 'success')
