<commit_before>#! python
# -*- coding: cp1252 -*-
import sys


from spade import ACLMessage
from spade import Agent
from spade import AMS
from spade import Behaviour
from spade import Envelope
from spade import Platform
from spade import ReceivedObject
from spade import ACLParser
from spade import AID
from spade import BasicFipaDateTime
from spade import DF
from spade import FIPAMessage
from spade import MessageReceiver
from spade import pyparsing
from spade import SL0Parser
from spade import XMLCodec
from spade import SpadeConfigParser 

    
class SpadeBackend:
	"""
	Runs the platform.
	Inits the platform components (AMS, DF, ...)
	"""

	def runAgent(self, config, section, agentClass):
		"""
		starts an agent
		"""
		#jid = configfile.get(section,'JID')
		passwd = config[section]['password']
		server = config["platform"]['hostname']
		port = int( config[section]['port'] )
		jid = section + "." + server
		agent = agentClass(jid, passwd, server, port)
		agent.start()
		return agent
    
	def __init__(self, configfilename="/etc/spade/spade.xml"):
		parser = SpadeConfigParser.ConfigParser()
		self.config = parser.parse(configfilename)

	def start(self):
		#TODO: this should be configurable
		#self.acc = self.runAgent(self.configfile, "acc", Platform.SpadePlatform)
		self.ams = self.runAgent(self.config, "ams", AMS.AMS)
		self.df = self.runAgent(self.config, "df", DF.DF)
		#self.simba = self.runAgent(self.configfile, "simba", SIMBA.SIMBA)

	def shutdown(self):
		if self.df: self.df.stop()
		if self.ams: self.ams.stop()
		#self.acc.stop()


if __name__ ==  "__main__":
	p = SpadeBackend()
	p.start()
<commit_msg>packaging<commit_after>#! python
# -*- coding: cp1252 -*-
import sys


from spade import ACLMessage
from spade import Agent
from spade import AMS
from spade import Behaviour
from spade import Envelope
from spade import Platform
from spade import ReceivedObject
from spade import ACLParser
from spade import AID
from spade import BasicFipaDateTime
from spade import DF
from spade import FIPAMessage
from spade import MessageReceiver
from spade import pyparsing
from spade import SL0Parser
from spade import XMLCodec
from spade import SpadeConfigParser 

    
class SpadeBackend:
	"""
	Runs the platform.
	Inits the platform components (AMS, DF, ...)
	"""

	def runAgent(self, config, section, agentClass):
		"""
		starts an agent
		"""
		#jid = configfile.get(section,'JID')
		passwd = config[section]['password']
		server = config["platform"]['hostname']
		port = int( config[section]['port'] )
		jid = section + "." + server
		agent = agentClass(jid, passwd, server, port)
		agent.start()
		return agent
    
	def __init__(self, configfilename="/etc/spade/spade.xml"):
		parser = SpadeConfigParser.ConfigParser()
		self.config = parser.parse(configfilename)

		self.ams=None
		self.df =None

	def start(self):
		#TODO: this should be configurable
		#self.acc = self.runAgent(self.configfile, "acc", Platform.SpadePlatform)
		self.ams = self.runAgent(self.config, "ams", AMS.AMS)
		self.df = self.runAgent(self.config, "df", DF.DF)
		#self.simba = self.runAgent(self.configfile, "simba", SIMBA.SIMBA)

	def shutdown(self):
		if self.df: self.df.stop()
		if self.ams: self.ams.stop()
		#self.acc.stop()


if __name__ ==  "__main__":
	p = SpadeBackend()
	p.start()

{'fraction_non_alphanumeric': 0.1164695177434031, 'fraction_numerical': 0.003033060357901122, 'mean_word_length': 4.415435139573071, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '4974314', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1095, 'n_words': 319}