neuronum 1.2.5__tar.gz → 1.3.1__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.5
3
+ Version: 1.3.1
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
@@ -29,8 +29,8 @@ Interact with the `Neuronum Network` to build, connect & automate economic data
29
29
  - **Streams (STX)**: Stream economic data to synchronize devices and databases in real time
30
30
 
31
31
  ## Community Cell Features
32
- - **Circuits (CTX)**: A simple Key-Value-Label database (perfect for testing and side projects)
33
- - **Streams (STX)**: Stream economic data to synchronize devices and databases in real time
32
+ - **Circuits (CTX)**: A simple Key-Value-Label database (testing / side projects)
33
+ - **Streams (STX)**: Stream data to synchronize devices and databases in real time
34
34
 
35
35
  ## Getting Started
36
36
  Create your Neuronum Business/Community Cell: [Create Cell](https://neuronum.net/createcell)
@@ -121,8 +121,19 @@ label = "your_label"
121
121
  data = cell.delete(label, CTX)
122
122
  ```
123
123
 
124
+ Empty your private Circuit (CTX):
125
+ ```bash
126
+ cell.clear()
127
+ ```
128
+
129
+ Empty a public Circuit (CTX):
130
+ ```bash
131
+ CTX = "id::ctx"
132
+ cell.clear(CTX)
133
+ ```
134
+
124
135
  ### Streams (STX)
125
- Stream data:
136
+ Stream data to your private Stream (STX):
126
137
  ```bash
127
138
  label = "your_label"
128
139
  data = {
@@ -133,7 +144,19 @@ data = {
133
144
  cell.stream(label, data)
134
145
  ```
135
146
 
136
- Sync stream:
147
+ Stream data to a public Stream (STX):
148
+ ```bash
149
+ STX = "id::stx"
150
+ label = "your_label"
151
+ data = {
152
+ "key1": "value1",
153
+ "key2": "value2",
154
+ "key3": "value3",
155
+ }
156
+ cell.stream(label, data, STX)
157
+ ```
158
+
159
+ Sync data from your private Stream (STX):
137
160
  ```bash
138
161
  stream = cell.sync()
139
162
  for operation in stream:
@@ -144,3 +167,15 @@ for operation in stream:
144
167
  operator = operation.get("operator")
145
168
  ```
146
169
 
170
+ Sync data from a public Stream (STX):
171
+ ```bash
172
+ STX = "id::stx"
173
+ stream = cell.sync(STX)
174
+ for operation in stream:
175
+ label = operation.get("label")
176
+ value = operation.get("data").get("key1")
177
+ ts = operation.get("time")
178
+ stxID = operation.get("stxID")
179
+ operator = operation.get("operator")
180
+ ```
181
+
@@ -12,8 +12,8 @@ Interact with the `Neuronum Network` to build, connect & automate economic data
12
12
  - **Streams (STX)**: Stream economic data to synchronize devices and databases in real time
13
13
 
14
14
  ## Community Cell Features
15
- - **Circuits (CTX)**: A simple Key-Value-Label database (perfect for testing and side projects)
16
- - **Streams (STX)**: Stream economic data to synchronize devices and databases in real time
15
+ - **Circuits (CTX)**: A simple Key-Value-Label database (testing / side projects)
16
+ - **Streams (STX)**: Stream data to synchronize devices and databases in real time
17
17
 
18
18
  ## Getting Started
19
19
  Create your Neuronum Business/Community Cell: [Create Cell](https://neuronum.net/createcell)
@@ -104,8 +104,19 @@ label = "your_label"
104
104
  data = cell.delete(label, CTX)
105
105
  ```
106
106
 
107
+ Empty your private Circuit (CTX):
108
+ ```bash
109
+ cell.clear()
110
+ ```
111
+
112
+ Empty a public Circuit (CTX):
113
+ ```bash
114
+ CTX = "id::ctx"
115
+ cell.clear(CTX)
116
+ ```
117
+
107
118
  ### Streams (STX)
108
- Stream data:
119
+ Stream data to your private Stream (STX):
109
120
  ```bash
110
121
  label = "your_label"
111
122
  data = {
@@ -116,7 +127,19 @@ data = {
116
127
  cell.stream(label, data)
117
128
  ```
118
129
 
119
- Sync stream:
130
+ Stream data to a public Stream (STX):
131
+ ```bash
132
+ STX = "id::stx"
133
+ label = "your_label"
134
+ data = {
135
+ "key1": "value1",
136
+ "key2": "value2",
137
+ "key3": "value3",
138
+ }
139
+ cell.stream(label, data, STX)
140
+ ```
141
+
142
+ Sync data from your private Stream (STX):
120
143
  ```bash
121
144
  stream = cell.sync()
122
145
  for operation in stream:
@@ -127,3 +150,15 @@ for operation in stream:
127
150
  operator = operation.get("operator")
128
151
  ```
129
152
 
153
+ Sync data from a public Stream (STX):
154
+ ```bash
155
+ STX = "id::stx"
156
+ stream = cell.sync(STX)
157
+ for operation in stream:
158
+ label = operation.get("label")
159
+ value = operation.get("data").get("key1")
160
+ ts = operation.get("time")
161
+ stxID = operation.get("stxID")
162
+ operator = operation.get("operator")
163
+ ```
164
+
@@ -24,6 +24,16 @@ class Cell:
24
24
 
25
25
  def __repr__(self) -> str:
26
26
  return f"Cell(host={self.host}, password={self.password}, network={self.network}, synapse={self.synapse})"
27
+
28
+
29
+ def authenticate(self, stx: Optional[str] = None):
30
+ credentials = f"{self.host}\n{self.password}\n{self.synapse}\n{stx}\n"
31
+ self.sock.sendall(credentials.encode('utf-8'))
32
+
33
+ response = self.sock.recv(1024).decode('utf-8')
34
+ print(response)
35
+ return "Authentication successful" in response
36
+
27
37
 
28
38
  def activate(self, txID: str, data: dict):
29
39
  url = f"https://{self.network}/activateTX/{txID}"
@@ -161,29 +171,31 @@ class Cell:
161
171
 
162
172
 
163
173
  def stream(self, label: str, data: dict, stx: Optional[str] = None):
174
+ """Stream data after authenticating once."""
164
175
  context = ssl.create_default_context()
165
176
  context.check_hostname = True
166
177
  context.verify_mode = ssl.CERT_REQUIRED
178
+
167
179
  raw_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
168
180
  self.sock = context.wrap_socket(raw_sock, server_hostname=self.network)
169
181
 
170
182
  print("SSL socket set")
171
183
 
172
184
  try:
173
-
174
- stream = {
175
- "label": label,
176
- "data": data,
177
- }
178
-
179
185
  print(f"Connecting to {self.network}")
180
186
  self.sock.connect((self.network, 55555))
181
187
  print("SSL socket connected")
182
188
 
183
- if not self.authenticate(self.sock, stx):
189
+ if not self.authenticate(stx):
184
190
  print("Authentication failed. Cannot stream.")
185
191
  return
186
192
 
193
+ # Stream data
194
+ stream = {
195
+ "label": label,
196
+ "data": data,
197
+ }
198
+
187
199
  self.sock.sendall(json.dumps(stream).encode('utf-8'))
188
200
  print(f"Sent: {stream}")
189
201
 
@@ -197,16 +209,6 @@ class Cell:
197
209
  self.sock.close()
198
210
  print("SSL connection closed.")
199
211
 
200
-
201
- def authenticate(self, sock, stx: Optional[str] = None):
202
- credentials = f"{self.host}\n{self.password}\n{self.synapse}\n{stx}\n"
203
- sock.sendall(credentials.encode('utf-8'))
204
-
205
- response = sock.recv(1024).decode('utf-8')
206
- print(response)
207
- return "Authentication successful" in response
208
-
209
-
210
212
  def sync(self, stx: Optional[str] = None) -> Generator[str, None, None]:
211
213
  auth = {
212
214
  "host": self.host,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neuronum
3
- Version: 1.2.5
3
+ Version: 1.3.1
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
@@ -29,8 +29,8 @@ Interact with the `Neuronum Network` to build, connect & automate economic data
29
29
  - **Streams (STX)**: Stream economic data to synchronize devices and databases in real time
30
30
 
31
31
  ## Community Cell Features
32
- - **Circuits (CTX)**: A simple Key-Value-Label database (perfect for testing and side projects)
33
- - **Streams (STX)**: Stream economic data to synchronize devices and databases in real time
32
+ - **Circuits (CTX)**: A simple Key-Value-Label database (testing / side projects)
33
+ - **Streams (STX)**: Stream data to synchronize devices and databases in real time
34
34
 
35
35
  ## Getting Started
36
36
  Create your Neuronum Business/Community Cell: [Create Cell](https://neuronum.net/createcell)
@@ -121,8 +121,19 @@ label = "your_label"
121
121
  data = cell.delete(label, CTX)
122
122
  ```
123
123
 
124
+ Empty your private Circuit (CTX):
125
+ ```bash
126
+ cell.clear()
127
+ ```
128
+
129
+ Empty a public Circuit (CTX):
130
+ ```bash
131
+ CTX = "id::ctx"
132
+ cell.clear(CTX)
133
+ ```
134
+
124
135
  ### Streams (STX)
125
- Stream data:
136
+ Stream data to your private Stream (STX):
126
137
  ```bash
127
138
  label = "your_label"
128
139
  data = {
@@ -133,7 +144,19 @@ data = {
133
144
  cell.stream(label, data)
134
145
  ```
135
146
 
136
- Sync stream:
147
+ Stream data to a public Stream (STX):
148
+ ```bash
149
+ STX = "id::stx"
150
+ label = "your_label"
151
+ data = {
152
+ "key1": "value1",
153
+ "key2": "value2",
154
+ "key3": "value3",
155
+ }
156
+ cell.stream(label, data, STX)
157
+ ```
158
+
159
+ Sync data from your private Stream (STX):
137
160
  ```bash
138
161
  stream = cell.sync()
139
162
  for operation in stream:
@@ -144,3 +167,15 @@ for operation in stream:
144
167
  operator = operation.get("operator")
145
168
  ```
146
169
 
170
+ Sync data from a public Stream (STX):
171
+ ```bash
172
+ STX = "id::stx"
173
+ stream = cell.sync(STX)
174
+ for operation in stream:
175
+ label = operation.get("label")
176
+ value = operation.get("data").get("key1")
177
+ ts = operation.get("time")
178
+ stxID = operation.get("stxID")
179
+ operator = operation.get("operator")
180
+ ```
181
+
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='neuronum',
5
- version='1.2.5',
5
+ version='1.3.1',
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