<commit_before>
from spade import MTP
from spade import AID
import socket
import SocketServer
try:
	import stack_thread as thread
except:
	import thread

class simba(MTP.MTP):
	class SimbaRequestHandler(SocketServer.DatagramRequestHandler):
                        '''
                        Request handler for SIMBA messages
                        '''
                        def handle(self):
                                print "SIMBA SS: New incoming message"


	def receiveThread(self):
                self.SS = SocketServer.ThreadingUDPServer(("", self.port), SimbaRequestHandler)
                print "SIMBA SS listening on port ", self.port
                self.SS.serve_forever()

	def __setup(self):
		'''
		Secondary constructor
		'''
		self.address = self.config.acc[self.name].address		
		self.port = self.config.acc[self.name].port		

		# Launch receive thread
		thread.start_new_thread(self.receiveThread, ())	
			

	def send(self, envelope, payload, to=None):
		'''
		Send a message to a SIMBA agent
		'''
		print ">>>SIMBA TRANSPORT: A MESSAGE ARRIVED FOR ME"
		if to == None:
			to = envelope.getTo()

		for receiver in to:
			for ad in receiver.getAddresses():
				# SIMBA URI = simba://address:port
				if ad[0:7] == "simba://":
					ad = str(ad)
					ad = ad.strip("simba://")
					# Check for the presence of a port
					if ':' in ad:
						ip, port = ad.split(':')
					else:
						ip = ad
						port = 20001

					# Set up a SIMBA socket to send the message
					s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
					try:
    						s.connect((ip, port))<commit_msg>packaging<commit_after>
from spade import MTP
from spade import AID
import socket
import SocketServer
try:
	import stack_thread as thread
except:
	import thread

class simba(MTP.MTP):
	class SimbaRequestHandler(SocketServer.DatagramRequestHandler):
                        '''
                        Request handler for SIMBA messages
                        '''
                        def handle(self):
                                print "SIMBA SS: New incoming message"


	def receiveThread(self):
                self.SS = SocketServer.ThreadingUDPServer(("", self.port), SimbaRequestHandler)
                print "SIMBA SS listening on port ", self.port
                self.SS.serve_forever()

	def __setup(self):
		'''
		Secondary constructor
		'''
		self.address = self.config.acc[self.name].address		
		self.port = self.config.acc[self.name].port		

		# Launch receive thread
		thread.start_new_thread(self.receiveThread, ())	
			

	def send(self, envelope, payload, to=None):
		'''
		Send a message to a SIMBA agent
		'''
		print ">>>SIMBA TRANSPORT: A MESSAGE TO SEND FOR ME"
		if to == None:
			to = envelope.getTo()
			print ">>>SIMBA TRANSPORT: TO = " + str(to)

		for receiver in to:
			print ">>>SIMBA TRANSPORT: RECEIVER = " + str(receiver)
			for ad in receiver.getAddresses():
				# SIMBA URI = simba://address:port
				if ad[0:7] == "simba://":
					ad = str(ad)
					ad = ad.strip("simba://")
					# Check for the presence of a port
					if ':' in ad:
						ip, port = ad.split(':')
					else:
						ip = ad
						port = 20001

					# Set up a SIMBA socket to send the message
					s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
					try:
    						s.connect((ip, port))
{'fraction_non_alphanumeric': 0.11023622047244094, 'fraction_numerical': 0.004239854633555421, 'mean_word_length': 2.1882239382239383, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 15, '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': '334251', 'n_tokens_mistral': 1230, 'n_tokens_neox': 997, 'n_words': 290}