neuronum 1.2.5__py3-none-any.whl → 1.3.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.
Potentially problematic release.
This version of neuronum might be problematic. Click here for more details.
- neuronum/neuronum.py +19 -17
- {neuronum-1.2.5.dist-info → neuronum-1.3.1.dist-info}/METADATA +40 -5
- neuronum-1.3.1.dist-info/RECORD +7 -0
- neuronum-1.2.5.dist-info/RECORD +0 -7
- {neuronum-1.2.5.dist-info → neuronum-1.3.1.dist-info}/LICENSE +0 -0
- {neuronum-1.2.5.dist-info → neuronum-1.3.1.dist-info}/WHEEL +0 -0
- {neuronum-1.2.5.dist-info → neuronum-1.3.1.dist-info}/top_level.txt +0 -0
neuronum/neuronum.py
CHANGED
|
@@ -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(
|
|
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.
|
|
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 (
|
|
33
|
-
- **Streams (STX)**: Stream
|
|
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
|
-
|
|
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
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
neuronum/__init__.py,sha256=Drsm263_w3_VWgl1YsKLUr8WwVodqV3TSjqpxLjyq_M,46
|
|
2
|
+
neuronum/neuronum.py,sha256=KPo6VIcSx1FKGL7V-idLbyIh2Zo7XaHucwl6HHQkkQs,7581
|
|
3
|
+
neuronum-1.3.1.dist-info/LICENSE,sha256=UiZjNHiCyRP6WoZfbYQh9cv4JW96wIofKXmzBJrYSUk,1125
|
|
4
|
+
neuronum-1.3.1.dist-info/METADATA,sha256=k7rd7a4tuuhg_-DZ3gwGzMGYDZK8SzW7aKG7n-_DBbA,4346
|
|
5
|
+
neuronum-1.3.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
6
|
+
neuronum-1.3.1.dist-info/top_level.txt,sha256=73zXVVO9UTTiwEcSaXytsJ8n0q47OCwAqPlIh-hzWJU,9
|
|
7
|
+
neuronum-1.3.1.dist-info/RECORD,,
|
neuronum-1.2.5.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
neuronum/__init__.py,sha256=Drsm263_w3_VWgl1YsKLUr8WwVodqV3TSjqpxLjyq_M,46
|
|
2
|
-
neuronum/neuronum.py,sha256=UZw5oocfxTJslee0YB74_cWEre3JsyKLoCkh0Lpk3rs,7531
|
|
3
|
-
neuronum-1.2.5.dist-info/LICENSE,sha256=UiZjNHiCyRP6WoZfbYQh9cv4JW96wIofKXmzBJrYSUk,1125
|
|
4
|
-
neuronum-1.2.5.dist-info/METADATA,sha256=pGAdlwA-BOJQcTJzg4UDxqvuLB1S9FFKG3qyrEpay1g,3642
|
|
5
|
-
neuronum-1.2.5.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
6
|
-
neuronum-1.2.5.dist-info/top_level.txt,sha256=73zXVVO9UTTiwEcSaXytsJ8n0q47OCwAqPlIh-hzWJU,9
|
|
7
|
-
neuronum-1.2.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|