<commit_before>#!/usr/bin/python

def main()
    print "Goodbye World!"

if __name__ == "__main__":
    main()

<commit_msg>Giving the main function some structure. Esentially main acts as a message handeler that forwards information for childern threads to other children threads that then act apropriatly on that data. Reason for multiple threads is that any listeners that we set up hang the code and therefore prevent other parts of the program from functioning. By creating multiple threads, the threads hang without hanging the rest of the program.<commit_after>#!/usr/bin/python
import sys
import Queue
import thread
import curses

from message import Message
from logging import logging_thread
#
def main(debug=False):
	#Setup general vars
	Run = True
	x = 0
	y = 0 
	
	#Setup individual Queues
	mainQueue = Queue.Queue(100)

	childrenQueues = {}
#	childrenQueues["Keyboard"] =  Queue.Queue(100)
#	childrenQueues["Display"] =  Queue.Queue(100)
	childrenQueues["Logging"] =  Queue.Queue(100)
#	childrenQueues["NFC"] =  Queue.Queue(100)

	#Function mapping
	functions = {}
	functions["Terminate"] = terminate


	#Order of Queues passed to functions: Queue passing data into function, Queue passing data from function to Main, Queue for logging function
	#thread.start_new_thread(keyboard_thread,(childrenQueues["Keyboard"],  mainQueue, childrenQueues["Logging"]))
	thread.start_new_thread(logging_thread,(childrenQueues["Logging"],))

	## Forwards messages to apropriate Queues/ runs appropriate functions
	while Run:
		log(childrenQueues["Logging"], "Empty Log")
		while not mainQueue.empty():
			log(childrenQueues["Logging"], "Entries in Log")
			currentMessage = mainQueue.get()
			if "Terminate" in currentMessage.content:
				log(childrenQueues["Logging"], "Terminating")
				Run = False
				break;
			else:
				functions[currentMessage.message]


## Logging Queue
def log(queue,mes):
	newLog = Message("Main", "Logging", {})
	newLog.add_content("1",mes)
	queue.put(newLog)

##Functions called:
def terminate():
	print "Terminating"
	## Add Terminate Handleing


##Allow for command line args: At the moment only can handle one (DEBUG). Order specific
if __name__ == "__main__":
	if len(sys.argv)>1:
		main(sys.argv[1])
	else:
		main()

{'fraction_non_alphanumeric': 0.1045373665480427, 'fraction_numerical': 0.008896797153024912, 'mean_word_length': 5.111413043478261, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2586906', 'n_tokens_mistral': 714, 'n_tokens_neox': 664, 'n_words': 225}