Below is the file 'plugins/textoutput.py' from this revision. You can also download the file.

#!/usr/bin/python

import socket
import threading
import sys

export = {
	"name" : "text_output",
	"version" : "0.1",
	"description" : "A simple output module that writes a text file",
	"type" : "output"
}

lock = threading.Lock()
result_fd = None
error_fd = None

def initialise(library):
	global result_fd, error_fd
	result_fd = open(library.config.result_log, 'w')
	error_fd = open(library.config.error_log, 'w')

def finalise(library):
	result_fd.close()
	error_fd.close()

def write_results(library, host, results):
	lock.acquire()
	for result in results:
		result_fd.write("%-15s  %s\n" % (result.address[0], result.text_summary()))
	lock.release()

def write_errors(library, host, errors):
	lock.acquire()
	for plugin_name, error in errors:
		error_fd.write("\nHost: %s\nPlugin: %s\%s\n" % (str(host.addresses), plugin_name, error))
	lock.release()