Skip to content

Commit f66279d

Browse files
committed
Merge branch 'release/4.0.3'
* release/4.0.3: Prepare for version 4.0.3 Bump version: 4.0.2 → 4.0.3 Fix XMPP message send + tests
2 parents 56881cf + eda0faa commit f66279d

File tree

12 files changed

+60
-22
lines changed

12 files changed

+60
-22
lines changed

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
History
33
=======
44

5+
4.0.3 (2025-02-17)
6+
--------------------
7+
* Prepare XMPP messages linked to client stream.
8+
* Added CLI support for in-memory database in the XMPP server.
9+
* Added CLI support for custom connection timeout.
10+
* Fixed bug in XMPP sending method.
511

612
4.0.2 (2025-01-09)
713
--------------------

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
slixmpp==1.8.5
1+
slixmpp>=1.8.5
22
aiohttp>=3.10.4
33
aiohttp_jinja2==1.6
44
jinja2==3.0.3

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 4.0.2
2+
current_version = 4.0.3
33
commit = True
44
tag = False
55
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>[a-z]+)(?P<rc>\d+))?

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def parse_requirements(filename):
3434

3535
setup(
3636
name='spade',
37-
version='4.0.2',
37+
version='4.0.3',
3838
description="Smart Python Agent Development Environment",
3939
long_description=readme + '\n\n' + history,
4040
author="Javi Palanca",

spade/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
__author__ = """Javi Palanca"""
1414
__email__ = "[email protected]"
15-
__version__ = "4.0.2"
15+
__version__ = "4.0.3"
1616

1717
__all__ = ["agent", "behaviour", "message", "template"]
1818

spade/behaviour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ async def send(self, msg: Message) -> None:
338338
self.agent.traces.append(msg, category=str(self))
339339

340340
async def _xmpp_send(self, msg: Message) -> None:
341-
slixmpp_msg = msg.prepare()
341+
slixmpp_msg = msg.prepare(self.agent.client)
342342
slixmpp_msg.send()
343343

344344
async def receive(self, timeout: Optional[float] = None) -> Optional[Message]:

spade/cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def cli():
2929
@click.option("--client_port", default=5222, help="Client port")
3030
@click.option("--server_port", default=5269, help="Server port")
3131
@click.option("--debug", is_flag=True, default=False, help="Enables debug mode")
32+
@click.option("--timeout", default=600, help="Connection timeout")
3233
@click.option(
3334
"--db",
3435
type=str,
@@ -37,9 +38,10 @@ def cli():
3738
help="Path for database file",
3839
)
3940
@click.option(
40-
"--purge", is_flag=True, help="Restore database file to default state (empty)"
41+
"--purge", is_flag=True, default=False, help="Restore database file to default state (empty)"
4142
)
42-
def run(host, client_port, server_port, debug, db, purge):
43+
@click.option("--memory", is_flag=True, default=False, help="Use an in-memory database")
44+
def run(host, client_port, server_port, debug, timeout, db, purge, memory):
4345
"""Launch an XMPP server"""
4446
if check_port_in_use(client_port, host):
4547
click.echo(f"Error: The port {client_port} is already in use.")
@@ -65,9 +67,10 @@ def run(host, client_port, server_port, debug, db, purge):
6567
host=host,
6668
client_port=client_port,
6769
server_port=server_port,
68-
connection_timeout=600,
70+
connection_timeout=timeout,
6971
database_path=db,
7072
database_purge=purge,
73+
database_in_memory=memory,
7174
)
7275

7376
print_spade_info()

spade/message.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Optional, Dict, Type
33

44
import slixmpp.stanza
5+
from slixmpp import ClientXMPP
56
from slixmpp.plugins.xep_0004 import Form
67

78
import spade.message
@@ -252,15 +253,18 @@ def make_reply(self) -> "Message":
252253
metadata=self.metadata,
253254
)
254255

255-
def prepare(self) -> slixmpp.stanza.Message:
256+
def prepare(self, client: ClientXMPP) -> slixmpp.stanza.Message:
256257
"""
257258
Returns a slixmpp.stanza.Message built from the Message and prepared to be sent.
258259
260+
Args:
261+
client (ClientXMPP): An XMPP client, whose stream will be used to send the message
262+
259263
Returns:
260-
slixmpp.stanza.Message: the message prepared to be sent
264+
slixmpp.stanza.Message: the message prepared to be sent
261265
262266
"""
263-
msg = slixmpp.stanza.Message()
267+
msg = client.Message()
264268
msg["to"] = self.to
265269
msg["from"] = self.sender
266270
msg["body"] = self.body

spade/templates/internal_tpl_base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ <h3 class="box-title">Agent Friends</h3>
302302

303303
<footer class="main-footer">
304304
<div class="pull-right hidden-xs">
305-
<b>Version</b> 4.0.2
305+
<b>Version</b> 4.0.3
306306
</div>
307307
<strong>Copyright © {% now 'local', '%Y' %} <a href="https://github.com/javipalanca/spade">SPADE</a>.</strong>
308308
</footer>

spade/web.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ async def send_agent(self, request):
314314
body = form["message"]
315315
logger.info("Sending message to {}: {}".format(agent_jid, body))
316316
msg = Message(to=agent_jid, sender=str(self.agent.jid), body=body)
317-
slixmpp_msg = msg.prepare()
317+
slixmpp_msg = msg.prepare(self.agent.client)
318318
self.agent.client.send(slixmpp_msg)
319319
msg.sent = True
320320
self.agent.traces.append(msg)

0 commit comments

Comments
 (0)