ironflock 1.0.3__tar.gz → 1.0.5__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.
- {ironflock-1.0.3/ironflock.egg-info → ironflock-1.0.5}/PKG-INFO +12 -2
- {ironflock-1.0.3 → ironflock-1.0.5}/ironflock/__init__.py +1 -1
- {ironflock-1.0.3 → ironflock-1.0.5}/ironflock/ironflock.py +31 -9
- {ironflock-1.0.3 → ironflock-1.0.5/ironflock.egg-info}/PKG-INFO +12 -2
- {ironflock-1.0.3 → ironflock-1.0.5}/setup.py +1 -1
- {ironflock-1.0.3 → ironflock-1.0.5}/LICENSE +0 -0
- {ironflock-1.0.3 → ironflock-1.0.5}/MANIFEST.in +0 -0
- {ironflock-1.0.3 → ironflock-1.0.5}/README.md +0 -0
- {ironflock-1.0.3 → ironflock-1.0.5}/ironflock/AutobahnConnection.py +0 -0
- {ironflock-1.0.3 → ironflock-1.0.5}/ironflock.egg-info/SOURCES.txt +0 -0
- {ironflock-1.0.3 → ironflock-1.0.5}/ironflock.egg-info/dependency_links.txt +0 -0
- {ironflock-1.0.3 → ironflock-1.0.5}/ironflock.egg-info/requires.txt +0 -0
- {ironflock-1.0.3 → ironflock-1.0.5}/ironflock.egg-info/top_level.txt +0 -0
- {ironflock-1.0.3 → ironflock-1.0.5}/pyproject.toml +0 -0
- {ironflock-1.0.3 → ironflock-1.0.5}/requirements.txt +0 -0
- {ironflock-1.0.3 → ironflock-1.0.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ironflock
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
4
4
|
Summary: SDK to integrate your IronFlock Industry 4 Apps with the IronFlock Data Infrastructure
|
|
5
5
|
Home-page: https://github.com/RecordEvolution/ironflock-py
|
|
6
6
|
Author: Record Evolution GmbH
|
|
@@ -10,6 +10,16 @@ Requires-Python: >=3.8
|
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Requires-Dist: autobahn[asyncio,serialization]==22.3.2
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: author-email
|
|
15
|
+
Dynamic: description
|
|
16
|
+
Dynamic: description-content-type
|
|
17
|
+
Dynamic: home-page
|
|
18
|
+
Dynamic: license
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
Dynamic: requires-dist
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
13
23
|
|
|
14
24
|
# ironflock
|
|
15
25
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import asyncio
|
|
2
3
|
from typing import Optional
|
|
3
4
|
from autobahn.asyncio.component import Component, run
|
|
4
5
|
from autobahn.wamp.interfaces import ISession
|
|
5
|
-
from autobahn.wamp.types import PublishOptions
|
|
6
|
+
from autobahn.wamp.types import PublishOptions, RegisterOptions
|
|
6
7
|
from autobahn.wamp.request import Publication
|
|
7
8
|
|
|
8
9
|
from ironflock.AutobahnConnection import getSerialNumber, create_application_component
|
|
@@ -13,8 +14,6 @@ class IronFlock:
|
|
|
13
14
|
|
|
14
15
|
Example:
|
|
15
16
|
|
|
16
|
-
ironFlock = IronFlock()
|
|
17
|
-
|
|
18
17
|
async def main():
|
|
19
18
|
while True:
|
|
20
19
|
publication = await ironFlock.publish("test.publish.pw", 1, "two", 3, foo="bar")
|
|
@@ -23,7 +22,7 @@ class IronFlock:
|
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
if __name__ == "__main__":
|
|
26
|
-
|
|
25
|
+
ironflock = IronFlock(mainFunc=main)
|
|
27
26
|
ironFlock.run()
|
|
28
27
|
"""
|
|
29
28
|
|
|
@@ -45,17 +44,22 @@ class IronFlock:
|
|
|
45
44
|
async def onJoin(session, details):
|
|
46
45
|
print("component joined")
|
|
47
46
|
self._session = session
|
|
47
|
+
self._main_task = asyncio.create_task(mainFunc())
|
|
48
|
+
|
|
48
49
|
if self.mainFunc:
|
|
49
50
|
await self.mainFunc()
|
|
50
51
|
|
|
51
52
|
@self._component.on_disconnect
|
|
52
|
-
def onDisconnect(*args, **kwargs):
|
|
53
|
-
print("component disconnected")
|
|
54
|
-
self._session = None
|
|
55
|
-
|
|
56
53
|
@self._component.on_leave
|
|
57
|
-
def onLeave(*args, **kwargs):
|
|
54
|
+
async def onLeave(*args, **kwargs):
|
|
58
55
|
print("component left")
|
|
56
|
+
if self._main_task:
|
|
57
|
+
self._main_task.cancel()
|
|
58
|
+
try:
|
|
59
|
+
await self._main_task
|
|
60
|
+
except asyncio.CancelledError:
|
|
61
|
+
pass
|
|
62
|
+
self._main_task = None
|
|
59
63
|
self._session = None
|
|
60
64
|
|
|
61
65
|
@property
|
|
@@ -122,6 +126,24 @@ class IronFlock:
|
|
|
122
126
|
if hasattr(self, "_session") and hasattr(self._session, "call"):
|
|
123
127
|
res = await self._session.call('ironflock.location_service.update', payload, **extra)
|
|
124
128
|
return res
|
|
129
|
+
|
|
130
|
+
async def register_function(self, topic: str, func):
|
|
131
|
+
"""Registers a function to be called when a message is received on the given topic.
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
topic (str): The URI of the topic to register the function for, e.g. "example.mytopic1".
|
|
135
|
+
func (callable): The function to call when a message is received on the topic.
|
|
136
|
+
"""
|
|
137
|
+
swarm_key = os.environ.get("SWARM_KEY")
|
|
138
|
+
app_key = os.environ.get("APP_KEY")
|
|
139
|
+
env_value = os.environ.get("ENV")
|
|
140
|
+
|
|
141
|
+
topic = f"{swarm_key}.{self._device_key}.{app_key}.{env_value}.{topic}"
|
|
142
|
+
|
|
143
|
+
if self._session is not None:
|
|
144
|
+
await self._session.register(topic, func, options=RegisterOptions(force_reregister=True))
|
|
145
|
+
else:
|
|
146
|
+
print("cannot register function, not connected")
|
|
125
147
|
|
|
126
148
|
async def publish_to_table(
|
|
127
149
|
self, tablename: str, *args, **kwargs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ironflock
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
4
4
|
Summary: SDK to integrate your IronFlock Industry 4 Apps with the IronFlock Data Infrastructure
|
|
5
5
|
Home-page: https://github.com/RecordEvolution/ironflock-py
|
|
6
6
|
Author: Record Evolution GmbH
|
|
@@ -10,6 +10,16 @@ Requires-Python: >=3.8
|
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Requires-Dist: autobahn[asyncio,serialization]==22.3.2
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: author-email
|
|
15
|
+
Dynamic: description
|
|
16
|
+
Dynamic: description-content-type
|
|
17
|
+
Dynamic: home-page
|
|
18
|
+
Dynamic: license
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
Dynamic: requires-dist
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
13
23
|
|
|
14
24
|
# ironflock
|
|
15
25
|
|
|
@@ -10,7 +10,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
|
|
10
10
|
|
|
11
11
|
setup(
|
|
12
12
|
name="ironflock",
|
|
13
|
-
version="1.0.
|
|
13
|
+
version="1.0.5",
|
|
14
14
|
description="SDK to integrate your IronFlock Industry 4 Apps with the IronFlock Data Infrastructure",
|
|
15
15
|
long_description=long_description,
|
|
16
16
|
long_description_content_type="text/markdown",
|
|
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
|