fjagepy 2.0.0__tar.gz → 2.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {fjagepy-2.0.0 → fjagepy-2.0.2}/PKG-INFO +6 -1
  2. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy/AgentID.py +2 -2
  3. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy/Gateway.py +7 -2
  4. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy/JSONMessage.py +1 -0
  5. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy/Message.py +6 -10
  6. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy.egg-info/PKG-INFO +6 -1
  7. {fjagepy-2.0.0 → fjagepy-2.0.2}/pyproject.toml +9 -2
  8. {fjagepy-2.0.0 → fjagepy-2.0.2}/LICENSE +0 -0
  9. {fjagepy-2.0.0 → fjagepy-2.0.2}/README.md +0 -0
  10. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy/Connector.py +0 -0
  11. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy/Performative.py +0 -0
  12. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy/Services.py +0 -0
  13. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy/TCPConnector.py +0 -0
  14. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy/Utils.py +0 -0
  15. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy/__init__.py +0 -0
  16. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy.egg-info/SOURCES.txt +0 -0
  17. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy.egg-info/dependency_links.txt +0 -0
  18. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy.egg-info/requires.txt +0 -0
  19. {fjagepy-2.0.0 → fjagepy-2.0.2}/fjagepy.egg-info/top_level.txt +0 -0
  20. {fjagepy-2.0.0 → fjagepy-2.0.2}/setup.cfg +0 -0
  21. {fjagepy-2.0.0 → fjagepy-2.0.2}/test/test_agentid.py +0 -0
  22. {fjagepy-2.0.0 → fjagepy-2.0.2}/test/test_gateway.py +0 -0
  23. {fjagepy-2.0.0 → fjagepy-2.0.2}/test/test_jsonmessage.py +0 -0
  24. {fjagepy-2.0.0 → fjagepy-2.0.2}/test/test_message.py +0 -0
  25. {fjagepy-2.0.0 → fjagepy-2.0.2}/test/test_shellreqs.py +0 -0
@@ -1,8 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fjagepy
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: fjage Gateway in Python
5
5
  Author-email: Chinmay Pendharkar <chinmay@subnero.com>
6
+ License: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/org-arl/fjage/tree/master/gateways/python
8
+ Project-URL: Source, https://github.com/org-arl/fjage/tree/master/gateways/python
9
+ Project-URL: Issues, https://github.com/org-arl/fjage/issues
10
+ Keywords: fjage,agent,framework,gateway,python
6
11
  Requires-Python: >=3.9
7
12
  Description-Content-Type: text/markdown
8
13
  License-File: LICENSE
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import logging
4
- from typing import Optional, Self, Any
4
+ from typing import Optional, Any
5
5
 
6
6
  logger = logging.getLogger(__name__)
7
7
  logger.addHandler(logging.NullHandler())
@@ -226,7 +226,7 @@ class AgentID:
226
226
 
227
227
  return self.request(msg)
228
228
 
229
- def __getitem__(self, index) -> Self:
229
+ def __getitem__(self, index) -> AgentID:
230
230
  """ Supports indexed parameter access through the [] operator.
231
231
  Example: agent[1].param will refers to the first indexed parameter "param" of the agent."""
232
232
 
@@ -76,7 +76,6 @@ class Gateway:
76
76
  except Exception as e:
77
77
  logger.error(f"Failed to connect to {hostname}:{port}: {e}")
78
78
  raise e
79
- self.connector.send('{"alive": true}')
80
79
  self._update_watch()
81
80
 
82
81
  def send(self, msg: Message) -> None:
@@ -261,7 +260,9 @@ class Gateway:
261
260
 
262
261
  def close(self):
263
262
  """Closes the gateway and disconnects from the fjage container."""
264
- self.connector.disconnect()
263
+ if self.is_connected():
264
+ self.connector.send('{"alive": false}') # signal to container that we're disconnecting
265
+ self.connector.disconnect()
265
266
 
266
267
  @staticmethod
267
268
  def match_filter(filter: Union[Callable, Type[Message], Message, None], msg: Message) -> bool:
@@ -279,6 +280,7 @@ class Gateway:
279
280
  return False
280
281
  return False
281
282
 
283
+
282
284
  # Internal helper methods
283
285
  def _retrieve_from_queue(self, filter: Union[Callable, Type[Message], Message, None]) -> Optional[Message]:
284
286
  if not self._queue:
@@ -297,6 +299,9 @@ class Gateway:
297
299
  def _msg_rx(self, strings: list) -> None:
298
300
  for string in strings:
299
301
  logger.debug(f"<<< {string}")
302
+ if string == '{"alive": true}':
303
+ self.connector.send('{"alive": true}') # respond to alive messages to keep connection alive
304
+ continue
300
305
  try:
301
306
  json_msg = JSONMessage(string, owner=self)
302
307
  if hasattr(json_msg, 'id') and json_msg.id in self._pending_actions:
@@ -36,6 +36,7 @@ class JSONMessage:
36
36
  self.inResponseTo: Optional[str] = None
37
37
  self.agentID: Optional[AgentID] = None
38
38
  self.agentIDs: Optional[List[AgentID]] = None
39
+ self.agentTypes: Optional[List[str]] = None
39
40
  self.service: Optional[str] = None
40
41
  self.services: Optional[List[str]] = None
41
42
  self.answer: Optional[bool] = None
@@ -109,16 +109,10 @@ class Message:
109
109
  setattr(rv, key, value)
110
110
  return rv
111
111
 
112
- def __str__(self):
112
+ def __str__(self) -> str:
113
113
  p = self.perf.value if self.perf else 'MESSAGE'
114
114
  if self.__clazz__ == 'org.arl.fjage.Message':
115
115
  return p
116
- return f"{p}: {self.__clazz__.split('.')[-1]}"
117
-
118
- def _repr_pretty_(self, p, cycle):
119
- if cycle:
120
- p.text('...')
121
- return
122
116
  content = []
123
117
  for k, v in self.__dict__.items():
124
118
  if k.startswith('__') or k == 'sender' or k == 'recipient' or k == 'msgID' or k == 'perf' or k == 'inReplyTo':
@@ -135,11 +129,13 @@ class Message:
135
129
  content.append(f"{k}=({len(v)} bytes)")
136
130
  else:
137
131
  content.append(f"{k}={v}")
138
- if self.__clazz__ == 'org.arl.fjage.Message' and not content:
139
- p.text(str(self.perf))
132
+ if not content:
133
+ return f"{self.__clazz__.split('.')[-1]}:{p}"
140
134
  else:
141
- p.text(self.__clazz__.split(".")[-1] + ':' + str(self.perf) + '[' + (', '.join(content)) + ']')
135
+ return f"{self.__clazz__.split('.')[-1]}:{p}[" + (', '.join(content)) + ']'
142
136
 
137
+ def _repr_pretty_(self, p, cycle):
138
+ p.text(str(self) if not cycle else '...')
143
139
 
144
140
 
145
141
  class GenericMessage(Message):
@@ -1,8 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fjagepy
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: fjage Gateway in Python
5
5
  Author-email: Chinmay Pendharkar <chinmay@subnero.com>
6
+ License: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/org-arl/fjage/tree/master/gateways/python
8
+ Project-URL: Source, https://github.com/org-arl/fjage/tree/master/gateways/python
9
+ Project-URL: Issues, https://github.com/org-arl/fjage/issues
10
+ Keywords: fjage,agent,framework,gateway,python
6
11
  Requires-Python: >=3.9
7
12
  Description-Content-Type: text/markdown
8
13
  License-File: LICENSE
@@ -4,12 +4,19 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fjagepy"
7
- version = "2.0.0"
7
+ version = "2.0.2"
8
8
  description = "fjage Gateway in Python"
9
- authors = [{ name = "Chinmay Pendharkar", email = "chinmay@subnero.com" }]
10
9
  readme = "README.md"
10
+ license = {text = "BSD-3-Clause"}
11
+ authors = [{ name = "Chinmay Pendharkar", email = "chinmay@subnero.com" }]
12
+ keywords = ["fjage", "agent", "framework", "gateway", "python"]
11
13
  requires-python = ">=3.9"
12
14
 
15
+ [project.urls]
16
+ Homepage = "https://github.com/org-arl/fjage/tree/master/gateways/python"
17
+ Source = "https://github.com/org-arl/fjage/tree/master/gateways/python"
18
+ Issues = "https://github.com/org-arl/fjage/issues"
19
+
13
20
  [tool.pytest.ini_options]
14
21
  minversion = "8.0"
15
22
  testpaths = ["test"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes