Skip to content

Commit

Permalink
Preparing for submission to the PyPi index. installation with setup.p…
Browse files Browse the repository at this point in the history
…y is now fully configured.
  • Loading branch information
javipalanca committed Aug 1, 2012
1 parent 4895651 commit ee9977e
Show file tree
Hide file tree
Showing 101 changed files with 5,081 additions and 251 deletions.
16 changes: 16 additions & 0 deletions README
@@ -0,0 +1,16 @@
==========
SPADE
==========


Welcome to SPADE
===========================
SPADE (Smart Python multi-Agent Development Environment) is a Multiagent and Organizations Platform based on the XMPP/Jabber technology and written in the Python programming language. This technology offers by itself many features and facilities that ease the construction of MAS, such as an existing communication channel, the concepts of users (agents) and servers (platforms) and an extensible communication protocol based on XML, just like FIPA-ACL. Many other agent platforms exist, but SPADE is the first to base its roots on the XMPP technology.

The SPADE Agent Platform does not require (but strongly recommends) the operation of agents made with the SPADE Agent Library. The platform itself uses the library to empower its internals, but aside from that, you can develop your own agents in the programming language of your choice and use them with SPADE. The only requirement those agents must fulfill is to be able to communicate through the XMPP protocol. The FIPA-ACL messages will be embedded in XMPP messages. Be warned, however, that some features of the whole SPADE experience may not be available if you do not use the SPADE Agent Library to build your agents.

The SPADE Agent Library
============================
The SPADE Agent Library is a module for the Python programming language for building SPADE agents. It is a collection of classes, functions and tools for creating new SPADE agents that can work with the SPADE Agent Platform. Using it is the best way to start developing your own SPADE agents. In the future, we would like to offer bindings of the SPADE Agent Library for more programming languages, like Java or C#, but for now only Python is supported.

If you have worked with Python before, you will find the SPADE Agent Library easy to understand and use, with classes ready to use and expand, and many functionalities already built in the library. If you have worked with other high-level behavioral agent platforms (like Jade or MadKit) you will find some similarities in the way the library works, although the agent model present in SPADE is a bit different.
196 changes: 99 additions & 97 deletions configure.py
Expand Up @@ -10,51 +10,53 @@
globalhostname = ""

def generateCode():
# Fill the template with the correct data

global jabber_template
global globalhostname

if os.name == "posix":
# If no hostname was previously specified, get one from the system
if globalhostname == "":
hostname = socket.gethostname()
else:
hostname = globalhostname

path = os.sep+"usr"+os.sep+"share"+os.sep+"spade"
else:
# If no hostname was previously specified, get one from the system
if globalhostname == "":
hostname = socket.gethostbyaddr(socket.gethostname())[0]
else:
hostname = globalhostname
path = "usr"+os.sep+"share"+os.sep+"spade"

if hostname == "localhost":
hostname = "127.0.0.1"
print "Translating localhost DNS to IP (127.0.0.1)."

acc_passwd = "".join([string.ascii_letters[int(random.randint(0,len(string.ascii_letters)-1))] for a in range(8)])
ams_passwd = "".join([string.ascii_letters[int(random.randint(0,len(string.ascii_letters)-1))] for a in range(8)])
df_passwd = "".join([string.ascii_letters[int(random.randint(0,len(string.ascii_letters)-1))] for a in range(8)])


spadexml = """
<spade>
# Fill the template with the correct data

global jabber_template
global globalhostname

path=""

if os.name == "posix":
# If no hostname was previously specified, get one from the system
if globalhostname == "":
hostname = socket.gethostname()
else:
hostname = globalhostname

#path = os.sep+"usr"+os.sep+"share"+os.sep+"spade"
else:
# If no hostname was previously specified, get one from the system
if globalhostname == "":
hostname = socket.gethostbyaddr(socket.gethostname())[0]
else:
hostname = globalhostname
#path = "usr"+os.sep+"share"+os.sep+"spade"

if hostname == "localhost":
hostname = "127.0.0.1"
print "Translating localhost DNS to IP (127.0.0.1)."

acc_passwd = "".join([string.ascii_letters[int(random.randint(0,len(string.ascii_letters)-1))] for a in range(8)])
ams_passwd = "".join([string.ascii_letters[int(random.randint(0,len(string.ascii_letters)-1))] for a in range(8)])
df_passwd = "".join([string.ascii_letters[int(random.randint(0,len(string.ascii_letters)-1))] for a in range(8)])


spadexml = """
<spade>
<platform>
<hostname>""" + hostname + """</hostname>
<port>5222</port>
<path>"""+path+"""</path>
<path>"""+path+"""</path>
</platform>
<acc>
<hostname>acc."""+hostname+"""</hostname>
<password>"""+acc_passwd+"""</password>
<port>5222</port>
#MTPS#
</acc>
#MTPS#
</acc>
<ams>
<hostname>ams."""+hostname+"""</hostname>
Expand All @@ -67,86 +69,86 @@ def generateCode():
<password>"""+df_passwd+"""</password>
<port>5222</port>
</df>
</spade>
"""

# Now fill the MTPs information
mtp_str = "\n"
for file in os.listdir("spade/mtp"):
try:
# If its a python script
if file[-3:] == ".py":
fname = file[:-3]
mtp_str = mtp_str + '''\t\t\t<mtp name="''' + fname + '''">\n\t\t\t\t<instance>''' + fname + '''</instance>\n'''
mtp_str = mtp_str + """\t\t\t\t<protocol>""" + fname + """</protocol>\n"""
mtp_str = mtp_str + """\t\t\t</mtp>\n\n"""
except Exception, e:
print "EXCEPTION GETTING MTPS: ", str(e)
# Fill the data
# GUS: By default, no MTPs, thank you
#spadexml = spadexml.replace("#MTPS#", mtp_str)
spadexml = spadexml.replace("#MTPS#", "")

file = open("etc/spade.xml", "w+")
file.write(spadexml)
file.close()

# Generating real xmppd.xml
if os.name == 'posix':
xmppdxml = '''
<server>
<servernames>
<name>'''+hostname+'''</name>
</servernames>
<certificate file="xmppd.pem"/>
<spool path="'''+str(os.environ['HOME'])+'''/.spade/spool"/>
<plugins>
<MUC jid="muc.'''+hostname+'''" name="SPADE MUC Component"/>
<WQ jid="wq.'''+hostname+'''" name="SPADE Workgroup Queues"/>
</plugins>
"""

# Now fill the MTPs information
#mtp_str = "\n"
#for file in os.listdir("spade/mtp"):
# try:
# # If its a python script
# if file[-3:] == ".py":
# fname = file[:-3]
# mtp_str = mtp_str + '''\t\t\t<mtp name="''' + fname + '''">\n\t\t\t\t<instance>''' + fname + '''</instance>\n'''
# mtp_str = mtp_str + """\t\t\t\t<protocol>""" + fname + """</protocol>\n"""
# mtp_str = mtp_str + """\t\t\t</mtp>\n\n"""
# except Exception, e:
# print "EXCEPTION GETTING MTPS: ", str(e)
# Fill the data
# GUS: By default, no MTPs, thank you
#spadexml = spadexml.replace("#MTPS#", mtp_str)
spadexml = spadexml.replace("#MTPS#", "")

file = open("spade.xml", "w+")
file.write(spadexml)
file.close()

# Generating real xmppd.xml
if os.name == 'posix':
xmppdxml = '''
<server>
<servernames>
<name>'''+hostname+'''</name>
</servernames>
<certificate file="xmppd.pem"/>
<spool path="'''+str(os.environ['HOME'])+'''/.spade/spool"/>
<plugins>
<MUC jid="muc.'''+hostname+'''" name="SPADE MUC Component"/>
<WQ jid="wq.'''+hostname+'''" name="SPADE Workgroup Queues"/>
</plugins>
<components>
<AMS jid="ams.'''+hostname+'''" name="AMS" username="ams" password="'''+ams_passwd+'''"/>
<DF jid="df.'''+hostname+'''" name="DF" username="df" password="'''+df_passwd+'''"/>
<ACC jid="acc.'''+hostname+'''" name="ACC" username="acc" password="'''+acc_passwd+'''"/>
</components>
</server>
'''
else:
xmppdxml = '''
<server>
<servernames>
<name>'''+hostname+'''</name>
</servernames>
<certificate file="xmppd.pem"/>
<spool path="usr/share/spade/xmppd/spool"/>
<plugins>
<MUC jid="muc.'''+hostname+'''" name="SPADE MUC Component"/>
<WQ jid="wq.'''+hostname+'''" name="SPADE Workgroup Queues"/>
</plugins>
</server>
'''
else:
xmppdxml = '''
<server>
<servernames>
<name>'''+hostname+'''</name>
</servernames>
<certificate file="xmppd.pem"/>
<spool path="usr/share/spade/xmppd/spool"/>
<plugins>
<MUC jid="muc.'''+hostname+'''" name="SPADE MUC Component"/>
<WQ jid="wq.'''+hostname+'''" name="SPADE Workgroup Queues"/>
</plugins>
<components>
<AMS jid="ams.'''+hostname+'''" name="AMS" username="ams" password="'''+ams_passwd+'''"/>
<DF jid="df.'''+hostname+'''" name="DF" username="df" password="'''+df_passwd+'''"/>
<ACC jid="acc.'''+hostname+'''" name="ACC" username="acc" password="'''+acc_passwd+'''"/>
</components>
</server>
'''
</server>
'''

file = open("etc/xmppd.xml", "w+")
file.write(xmppdxml)
file.close()
file = open("xmppd.xml", "w+")
file.write(xmppdxml)
file.close()



if __name__ == '__main__':
# We look for a command line parameter
if len(sys.argv) > 1:
# There is a parameter
globalhostname = sys.argv[1]
# There is a parameter
globalhostname = sys.argv[1]
else:
# There is no parameter (i.e. macho-mode)
pass
# There is no parameter (i.e. macho-mode)
pass
generateCode()

5 changes: 5 additions & 0 deletions doc/manual/Makefile
@@ -0,0 +1,5 @@
all:
mkdir -p html/images
xsltproc --output html/ chunk-stylesheet.xsl book.xml
cp styles.css html
cp images/* html/images
39 changes: 39 additions & 0 deletions doc/manual/base-html-stylesheet.xsl
@@ -0,0 +1,39 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>

<!-- xsltproc can't support these extensions
<xsl:param name="use.extensions">1</xsl:param>
<xsl:param name="callouts.extension">1</xsl:param>
<xsl:param name="linenumbering.extension">1</xsl:param>
<xsl:param name="tablecolumns.extension">1</xsl:param>
<xsl:param name="textinsert.extension">1</xsl:param>
-->

<xsl:param name="html.stylesheet">styles.css</xsl:param>
<xsl:param name="toc.section.depth">3</xsl:param>
<xsl:param name="annotate.toc">0</xsl:param>

<xsl:param name="admon.graphics" select="1" />
<xsl:param name="admon.graphics.extension">.png</xsl:param>
<xsl:param name="callout.graphics" select="1" />
<xsl:param name="callout.graphics.extension">.png</xsl:param>

<xsl:template match="sect1" mode="toc">
<xsl:param name="toc-context" select="."/>
<xsl:call-template name="subtoc">
<xsl:with-param name="toc-context" select="$toc-context"/>
<xsl:with-param name="nodes"
select="sect2|refentry|bridgehead[$bridgehead.in.toc != 0]"/>
</xsl:call-template>
</xsl:template>

<xsl:template match="sect2" mode="toc">
<xsl:param name="toc-context" select="."/>

<xsl:call-template name="subtoc">
<xsl:with-param name="toc-context" select="$toc-context"/>
<xsl:with-param name="nodes"
select="sect3|refentry|bridgehead[$bridgehead.in.toc != 0]"/>
</xsl:call-template>
</xsl:template>

</xsl:stylesheet>
96 changes: 96 additions & 0 deletions doc/manual/book.xml
@@ -0,0 +1,96 @@
<?xml version="1.0"?>
<!DOCTYPE book SYSTEM "docbookx.dtd"
[
<!--<!ENTITY % vers SYSTEM "version.xml">
%vers;-->
<!ENTITY foreword SYSTEM "foreword.xml">
<!ENTITY ch00 SYSTEM "ch00-introduction-to-spade.xml">
<!ENTITY ch01 SYSTEM "ch01-quickstart-guide.xml">
<!ENTITY ch02 SYSTEM "ch02-fundamental-concepts.xml">
<!ENTITY ch03 SYSTEM "ch03-basic-agents.xml">
<!ENTITY ch04 SYSTEM "ch04-platform-services.xml">
<!ENTITY ch05 SYSTEM "ch05-advanced-behaviours.xml">
<!ENTITY ch06 SYSTEM "ch06-bdi.xml">
<!ENTITY ch07 SYSTEM "ch07-content-objects.xml">
<!ENTITY ch08 SYSTEM "ch08-gui.xml">
<!ENTITY ch09 SYSTEM "ch09-agent-organizations.xml">
<!ENTITY ch10 SYSTEM "ch10-extending-spade.xml">
<!ENTITY ch11 SYSTEM "ch11-creating-a-complex-example.xml">
<!ENTITY ch12 SYSTEM "ch12-faq-and-troubleshooting.xml">
<!ENTITY license SYSTEM "copyright.xml">
]>

<book id="spade">
<title>SPADE User's Manual</title>

<bookinfo>

<subtitle>For SPADE 2.0</subtitle>

<!-- Using revnumber would be more appropriate, but our stylesheets -->
<!-- don't seem to render it. -->
<!--<subtitle>(Compiled from &svn.l10n_revision;&svn.version;)</subtitle>-->

<edition>First</edition>
<isbn>?-?????-???-?</isbn>
<authorgroup>

<author>
<firstname>Gustavo</firstname>
<surname>Aranda</surname>
</author>

<author>
<firstname>Javier</firstname>
<surname>Palanca</surname>
</author>

</authorgroup>

<!--<editor>
<firstname>Vicente</firstname>
<surname>Botti</surname>
</editor>-->

<pagenums>XXX pages (est.)</pagenums>
<pubdate>(TBA)</pubdate>

<copyright>
<year>2005</year>
<year>2010</year>
<holder>Gustavo Aranda</holder>
<holder>Javier Palanca</holder>
<holder>Miguel Escriva</holder>
<holder>Natalia Criado</holder>
<holder>Juan Angel Garcia-Pardo</holder>
</copyright>

<legalnotice><para>This work is licensed under the Creative
Commons Attribution License. To view a copy of this license,
visit <ulink url="http://creativecommons.org/licenses/by/2.0/"/>
or send a letter to Creative Commons, 559 Nathan Abbott Way,
Stanford, California 94305, USA.</para></legalnotice>

</bookinfo>

<!-- External entity refs -->

&foreword;
&ch00;
&ch01;
&ch02;
&ch03;
&ch04;
&ch05;
&ch06;
<!--&ch07;
&ch08;
&ch09;
&appa;
&appb;
&appc;
&appd;
&license;
&index;-->

</book>

0 comments on commit ee9977e

Please sign in to comment.