neuronum 1.2.3__tar.gz → 1.2.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.

Potentially problematic release.


This version of neuronum might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neuronum
3
- Version: 1.2.3
3
+ Version: 1.2.5
4
4
  Summary: Interact with the Neuronum Network to build, connect & automate economic data streams
5
5
  Home-page: https://neuronum.net
6
6
  Author: Neuronum Cybernetics
@@ -136,5 +136,11 @@ cell.stream(label, data)
136
136
  Sync stream:
137
137
  ```bash
138
138
  stream = cell.sync()
139
+ for operation in stream:
140
+ label = operation.get("label")
141
+ value = operation.get("data").get("key1")
142
+ ts = operation.get("time")
143
+ stxID = operation.get("stxID")
144
+ operator = operation.get("operator")
139
145
  ```
140
146
 
@@ -119,5 +119,11 @@ cell.stream(label, data)
119
119
  Sync stream:
120
120
  ```bash
121
121
  stream = cell.sync()
122
+ for operation in stream:
123
+ label = operation.get("label")
124
+ value = operation.get("data").get("key1")
125
+ ts = operation.get("time")
126
+ stxID = operation.get("stxID")
127
+ operator = operation.get("operator")
122
128
  ```
123
129
 
@@ -1,6 +1,6 @@
1
1
  import requests
2
2
  import socket
3
- from typing import Optional
3
+ from typing import Optional, Generator
4
4
  import ssl
5
5
  from websocket import create_connection
6
6
  from typing import List
@@ -207,8 +207,7 @@ class Cell:
207
207
  return "Authentication successful" in response
208
208
 
209
209
 
210
- def sync(self, stx: Optional[str] = None) -> List[str]:
211
- stream = []
210
+ def sync(self, stx: Optional[str] = None) -> Generator[str, None, None]:
212
211
  auth = {
213
212
  "host": self.host,
214
213
  "password": self.password,
@@ -219,22 +218,21 @@ class Cell:
219
218
  while True:
220
219
  try:
221
220
  ws = create_connection(f"wss://{self.network}/sync/{stx}")
222
- ws.settimeout(1) # Set timeout for receiving data
221
+ ws.settimeout(1)
223
222
  ws.send(json.dumps(auth))
224
223
  print("Connected to WebSocket.")
225
224
 
226
225
  while True:
227
226
  try:
228
- message = ws.recv()
229
- print(f"Received Data: {message}")
230
- stream.append(message)
227
+ raw_operation = ws.recv()
228
+ operation = json.loads(raw_operation)
229
+ yield operation
231
230
  except socket.timeout:
232
- # Timeout occurred, but keep the connection open
233
231
  print("Timeout occurred, no data received.")
234
232
  except KeyboardInterrupt:
235
233
  print("Closing connection...")
236
234
  ws.close()
237
- return stream
235
+ return
238
236
  except Exception as e:
239
237
  print(f"Connection failed: {e}")
240
238
  finally:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neuronum
3
- Version: 1.2.3
3
+ Version: 1.2.5
4
4
  Summary: Interact with the Neuronum Network to build, connect & automate economic data streams
5
5
  Home-page: https://neuronum.net
6
6
  Author: Neuronum Cybernetics
@@ -136,5 +136,11 @@ cell.stream(label, data)
136
136
  Sync stream:
137
137
  ```bash
138
138
  stream = cell.sync()
139
+ for operation in stream:
140
+ label = operation.get("label")
141
+ value = operation.get("data").get("key1")
142
+ ts = operation.get("time")
143
+ stxID = operation.get("stxID")
144
+ operator = operation.get("operator")
139
145
  ```
140
146
 
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='neuronum',
5
- version='1.2.3',
5
+ version='1.2.5',
6
6
  author='Neuronum Cybernetics',
7
7
  author_email='welcome@neuronum.net',
8
8
  description='Interact with the Neuronum Network to build, connect & automate economic data streams',
File without changes
File without changes
File without changes