ironflock 0.1.1__py3-none-any.whl → 1.0.1__py3-none-any.whl

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.
@@ -9,8 +9,18 @@ try:
9
9
  except:
10
10
  raise Exception("Environment variable SWARM_KEY not set!")
11
11
 
12
- CB_REALM = "userapps"
13
- # CB_REALM = f"swarm{SWARM_KEY}"
12
+ try:
13
+ APP_KEY = os.environ["APP_KEY"]
14
+ except:
15
+ raise Exception("Environment variable APP_KEY not set!")
16
+
17
+ try:
18
+ ENV = os.environ["ENV"].lower()
19
+ except:
20
+ raise Exception("Environment variable ENV not set!")
21
+
22
+ # CB_REALM = "userapps"
23
+ CB_REALM = f"realm-{SWARM_KEY}-{APP_KEY}-{ENV}"
14
24
 
15
25
  DATAPODS_WS_URI = "wss://cbw.datapods.io/ws-ua-usr"
16
26
  STUDIO_WS_URI_OLD = "wss://cbw.record-evolution.com/ws-ua-usr"
@@ -69,7 +79,7 @@ class AppSession(ApplicationSession):
69
79
  def create_application_session(
70
80
  serial_number: str = None,
71
81
  ) -> Tuple[ApplicationSession, ApplicationRunner]:
72
- """Creates an Autobahn ApplicationSession and ApplicationRunner, which connects to the RE Platform
82
+ """Creates an Autobahn ApplicationSession and ApplicationRunner, which connects to the IronFlock Platform
73
83
 
74
84
  Args:
75
85
  serial_number (str, optional): serial_number of device.
@@ -91,7 +101,7 @@ def create_application_session(
91
101
 
92
102
 
93
103
  def create_application_component(serial_number: str = None) -> Component:
94
- """Creates an Autobahn Component, which connects to the RE Platform
104
+ """Creates an Autobahn Component, which connects to the IronFlock Platform
95
105
 
96
106
  Args:
97
107
  serial_number (str, optional): serial_number of device.
ironflock/ironflock.py CHANGED
@@ -9,22 +9,22 @@ from ironflock.AutobahnConnection import getSerialNumber, create_application_com
9
9
 
10
10
 
11
11
  class IronFlock:
12
- """Convenience class for easy to use message publishing to the RE platform.
12
+ """Conveniance class for easy-to-use message publishing in the IronFlock platform.
13
13
 
14
14
  Example:
15
15
 
16
- rw = IronFlock()
16
+ ironFlock = IronFlock()
17
17
 
18
18
  async def main():
19
19
  while True:
20
- publication = await rw.publish("test.publish.pw", 1, "two", 3, foo="bar")
20
+ publication = await ironFlock.publish("test.publish.pw", 1, "two", 3, foo="bar")
21
21
  print(publication)
22
22
  await asyncio.sleep(3)
23
23
 
24
24
 
25
25
  if __name__ == "__main__":
26
26
  asyncio.get_event_loop().create_task(main())
27
- rw.run()
27
+ ironFlock.run()
28
28
  """
29
29
 
30
30
  def __init__(self, serial_number: str = None, mainFunc=None) -> None:
@@ -36,6 +36,7 @@ class IronFlock:
36
36
  """
37
37
  self._serial_number = getSerialNumber(serial_number)
38
38
  self._device_name = os.environ.get("DEVICE_NAME")
39
+ self._device_key = os.environ.get("DEVICE_KEY")
39
40
  self._component = create_application_component(serial_number)
40
41
  self._session: ISession = None
41
42
  self.mainFunc = mainFunc
@@ -76,7 +77,7 @@ class IronFlock:
76
77
  return self._session
77
78
 
78
79
  async def publish(self, topic: str, *args, **kwargs) -> Optional[Publication]:
79
- """Publishes to the RE Platform Message Router
80
+ """Publishes to the IronFlock Platform Message Router
80
81
 
81
82
  Args:
82
83
  topic (str): The URI of the topic to publish to, e.g. "com.myapp.mytopic1"
@@ -88,6 +89,7 @@ class IronFlock:
88
89
 
89
90
  extra = {
90
91
  "DEVICE_SERIAL_NUMBER": self._serial_number,
92
+ "DEVICE_KEY": self._device_key,
91
93
  "DEVICE_NAME": self._device_name,
92
94
  "options": PublishOptions(acknowledge=True),
93
95
  }
@@ -102,6 +104,8 @@ class IronFlock:
102
104
  """Update the location of the device registered in the platform
103
105
  This will update the device's location in the master data of the platform.
104
106
  The maps in the device or group overviews will reflect the new device location in realtime.
107
+ The location history will not be stored in the platform.
108
+ If you need location history, then create a dedicated table for it.
105
109
  """
106
110
 
107
111
  payload = {
@@ -111,6 +115,7 @@ class IronFlock:
111
115
 
112
116
  extra = {
113
117
  "DEVICE_SERIAL_NUMBER": self._serial_number,
118
+ "DEVICE_KEY": self._device_key,
114
119
  "DEVICE_NAME": self._device_name
115
120
  }
116
121
 
@@ -121,8 +126,14 @@ class IronFlock:
121
126
  async def publish_to_table(
122
127
  self, tablename: str, *args, **kwargs
123
128
  ) -> Optional[Publication]:
124
- """Publishes Data to a Table in the RE Platform
125
-
129
+ """Publishes Data to a Table in the IronFlock Platform. This is a conveniance function.
130
+ You can achieve the same results by simply publishing a payload to the topic
131
+
132
+ [SWARM_KEY].[APP_KEY].[your_table_name]
133
+
134
+ The SWARM_KEY and APP_KEY are provided as environment variables to the device container.
135
+ The also provided ENV variable holds either PROD or DEV to decide which topic to use, above.
136
+ This function automatically detects the environment and publishes to the correct table.
126
137
  Args:
127
138
  tablename (str): The table name of the table to publish to, e.g. "sensordata"
128
139
 
@@ -144,16 +155,7 @@ class IronFlock:
144
155
  if app_key is None:
145
156
  raise Exception("Environment variable APP_KEY not set!")
146
157
 
147
- if env_value is None:
148
- raise Exception("Environment variable ENV not set!")
149
-
150
- if not env_value in ["DEV", "PROD"]:
151
- raise Exception("Environment variable ENV must be 'PROD' or 'DEV'!")
152
-
153
- if env_value == "PROD":
154
- topic = f"{swarm_key}.{app_key}.{tablename}"
155
- else:
156
- topic = f"dev.{swarm_key}.{app_key}.{tablename}"
158
+ topic = f"{swarm_key}.{app_key}.{tablename}"
157
159
 
158
160
  pub = await self.publish(topic, *args, **kwargs)
159
161
  return pub
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ironflock
3
- Version: 0.1.1
3
+ Version: 1.0.1
4
4
  Summary: Publishing data to a IronFlock Fleet Storage
5
5
  Home-page: https://github.com/RecordEvolution/ironflock-python
6
6
  Author: Record Evolution GmbH
@@ -9,16 +9,19 @@ License: MIT
9
9
  Requires-Python: >=3.6
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE
12
- Requires-Dist: autobahn[asyncio,compression,serialization] ==22.3.2
12
+ Requires-Dist: autobahn[asyncio,serialization] ==22.3.2
13
13
 
14
14
  # ironflock
15
15
 
16
16
  ## About
17
17
 
18
- With this library you can publishing data to IronFlock fleet storage. When this library is used on a certain device the library automatically uses the private messaging realm (Unified Name Space) of the device's fleet and the data is collected in the respective fleet database.
18
+ With this library you can publish data from your apps on your IoT edge hardware to the fleet data storage of the [IronFlock](https://studio.ironflock.com) devops platform.
19
+ When this library is used on a certain device the library automatically uses the private messaging realm (Unified Name Space)
20
+ of the device's fleet and the data is collected in the respective fleet database.
19
21
 
20
22
  So if you use the library in your app, the data collection will always be private to the app user's fleet.
21
23
 
24
+ For more information on the IronFlock IoT Devops Platform for engineers and developers visit our [IronFlock](https://www.ironflock.com) home page.
22
25
  ## Usage
23
26
 
24
27
  ```python
@@ -73,8 +76,7 @@ pip install --upgrade setuptools wheel twine
73
76
  Build and publish a new pypi package:
74
77
 
75
78
  ```shell
76
- python setup.py sdist bdist_wheel
77
- twine upload dist/*
79
+ make publish
78
80
  ```
79
81
 
80
82
  Check the package at https://pypi.org/project/ironflock/.
@@ -0,0 +1,8 @@
1
+ ironflock/AutobahnConnection.py,sha256=clwEsptqQFjDFn4dUGN4bQyb1cOnPmmNjetfTrRqckY,3687
2
+ ironflock/__init__.py,sha256=LsyyAenv7GrvQSmPc3QJDu7_VsK7BDIvbwGC8ebEI9A,265
3
+ ironflock/ironflock.py,sha256=ZVshk0ky9rOPbNlLHUW-LgjuFl_YJbm3zqLvKSLjRs8,5892
4
+ ironflock-1.0.1.dist-info/LICENSE,sha256=GpUKjPB381nmkbBIdX74vxXhsNZaNpngTOciss39Pjk,1073
5
+ ironflock-1.0.1.dist-info/METADATA,sha256=ONGtcs6swb7JV50gQZIIUYQSEOcVBsp3rXQ-2NJ_rV8,2491
6
+ ironflock-1.0.1.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
7
+ ironflock-1.0.1.dist-info/top_level.txt,sha256=hmMdMPJuvnOTlFKYl1XQOn81vg1DE2LT7xrEXgyxcRA,10
8
+ ironflock-1.0.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.1.1)
2
+ Generator: setuptools (72.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,8 +0,0 @@
1
- ironflock/AutobahnConnection.py,sha256=IX5VjUhRGq4-zo8cx2CH964pmoPH29sWc0eQAAG60gM,3438
2
- ironflock/__init__.py,sha256=LsyyAenv7GrvQSmPc3QJDu7_VsK7BDIvbwGC8ebEI9A,265
3
- ironflock/ironflock.py,sha256=I0T3NvY8kL7TzdjPdn7HfOxMDxsTF2qRhnklRU09dZ4,5385
4
- ironflock-0.1.1.dist-info/LICENSE,sha256=GpUKjPB381nmkbBIdX74vxXhsNZaNpngTOciss39Pjk,1073
5
- ironflock-0.1.1.dist-info/METADATA,sha256=HRePXC8dtOLvc-5tkJ347ZJEpTO0__K1pFJp_PsdzaA,2295
6
- ironflock-0.1.1.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
7
- ironflock-0.1.1.dist-info/top_level.txt,sha256=hmMdMPJuvnOTlFKYl1XQOn81vg1DE2LT7xrEXgyxcRA,10
8
- ironflock-0.1.1.dist-info/RECORD,,