ironflock 1.3.1__tar.gz → 1.3.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ironflock
3
- Version: 1.3.1
3
+ Version: 1.3.3
4
4
  Summary: IronFlock Python SDK for connecting to the IronFlock Platform
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ironflock"
3
- version = "1.3.1"
3
+ version = "1.3.3"
4
4
  description = "IronFlock Python SDK for connecting to the IronFlock Platform"
5
5
  authors = [
6
6
  {name = "Marko Petzold, IronFlock GmbH", email = "info@ironflock.com"}
@@ -7,4 +7,4 @@ __all__ = [
7
7
  "Stage"
8
8
  ]
9
9
 
10
- __version__ = "1.3.1"
10
+ __version__ = "1.3.3"
@@ -222,9 +222,15 @@ class IronFlock:
222
222
 
223
223
  # Convert options dict to RegisterOptions if provided
224
224
  register_options = RegisterOptions(**options) if options else None
225
+
226
+ swarm_key = os.environ.get("SWARM_KEY")
227
+ app_key = os.environ.get("APP_KEY")
228
+ env_value = os.environ.get("ENV")
229
+
230
+ full_topic = f"{swarm_key}.{self._device_key}.{app_key}.{env_value}.{topic}"
225
231
 
226
232
  try:
227
- reg = await self._connection.register(topic, endpoint, options=register_options)
233
+ reg = await self._connection.register(full_topic, endpoint, options=register_options)
228
234
  return reg
229
235
  except Exception as e:
230
236
  print(f"Register failed: {e}")
@@ -382,7 +388,7 @@ class IronFlock:
382
388
  sub = await self.subscribe(topic, handler, params.options)
383
389
  return sub
384
390
 
385
- async def getHistory(self, tablename: str, queryParams: Union[TableQueryParams, dict]) -> Optional[Any]:
391
+ async def getHistory(self, tablename: str, queryParams: Union[TableQueryParams, dict] = {"limit": 10}) -> Optional[Any]:
386
392
  """Get historical data from a table using the history service
387
393
 
388
394
  Calls the "history.table" topic with the specified table name and query parameters.
@@ -422,31 +428,29 @@ class IronFlock:
422
428
  return None
423
429
 
424
430
  # Prepare the call arguments
425
- call_args = {
426
- 'tablename': tablename,
427
- 'queryParams': validated_params.model_dump() # Convert to dict for serialization
428
- }
429
-
430
- # Add device metadata
431
- device_metadata = {
432
- "DEVICE_SERIAL_NUMBER": self._serial_number,
433
- "DEVICE_KEY": self._device_key,
434
- "DEVICE_NAME": self._device_name,
435
- }
436
-
437
- # Merge device metadata with call arguments
438
- combined_kwargs = {**device_metadata, **call_args}
431
+ queryParams = validated_params.model_dump()
439
432
 
433
+ topic = f"history.transformed.app.{self._app_key}.{tablename}"
440
434
  try:
441
435
  result = await self._connection.call(
442
- 'history.table',
443
- args=[],
444
- kwargs=combined_kwargs
436
+ topic,
437
+ args=[queryParams]
445
438
  )
446
439
  return result
447
440
  except Exception as e:
448
- print(f"Get history failed: {e}")
449
- return None
441
+ # Check for specific WAMP errors indicating procedure not available
442
+ error_str = str(e)
443
+ if (hasattr(e, 'error') and
444
+ ('no_such_procedure' in str(e.error) or 'runtime_error' in str(e.error))) or \
445
+ 'no callee registered for procedure' in error_str:
446
+ print(f"Get history failed: History service procedure '{topic}' not registered in Crossbar")
447
+ print(f" Error type: {getattr(e, 'error', 'Unknown')}")
448
+ print(f" Error details: {e}")
449
+ print(f" This indicates the history service is not available or not properly configured")
450
+ return None
451
+ else:
452
+ print(f"Get history failed: {e}")
453
+ return None
450
454
 
451
455
  async def start(self):
452
456
  """Start the connection and run the main function if provided"""
File without changes
File without changes