neuronum 0.9.0__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.

Potentially problematic release.


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

neuronum/neuronum.py CHANGED
@@ -1,5 +1,7 @@
1
1
  import requests
2
+ import socket
2
3
  from typing import Optional
4
+ import ssl
3
5
 
4
6
 
5
7
  class Cell:
@@ -8,6 +10,7 @@ class Cell:
8
10
  self.password = password
9
11
  self.network = network
10
12
  self.synapse = synapse
13
+ self.sock = None
11
14
 
12
15
  def to_dict(self) -> dict:
13
16
  return {
@@ -19,7 +22,7 @@ class Cell:
19
22
  def __repr__(self) -> str:
20
23
  return f"Cell(host={self.host}, password={self.password}, network={self.network}, synapse={self.synapse})"
21
24
 
22
- def activate(self, txID: str, data: dict, base_url: str = "http://{network}/activateTX"):
25
+ def activate(self, txID: str, data: dict, base_url: str = "https://{network}/activateTX"):
23
26
  full_url = base_url.format(network=self.network) + f"/{txID}"
24
27
 
25
28
  TX = {
@@ -44,39 +47,30 @@ class Cell:
44
47
 
45
48
 
46
49
 
47
- def test_connection(self, base_url: str = "http://{network}/testConnection"):
50
+ def test_connection(self, base_url: str = "https://{network}/testConnection"):
48
51
  full_url = base_url.format(network=self.network)
49
52
 
50
- TX = {
51
- "host": self.host,
52
- "password": self.password,
53
- "synapse": self.synapse
54
- }
53
+ print(f"Full URL: {full_url}")
55
54
 
56
- print(TX)
55
+ test = {
56
+ "cell": self.to_dict()
57
+ }
57
58
 
58
59
  try:
59
- response = requests.post(
60
- full_url,
61
- json=TX,
62
- )
63
-
60
+ response = requests.post(full_url, json=test)
64
61
  response.raise_for_status()
65
- print(f"Response from FastAPI backend: {response.json()}")
66
-
62
+ print(response.json())
67
63
  except requests.exceptions.RequestException as e:
68
64
  print(f"Error sending request: {e}")
69
65
  except Exception as e:
70
66
  print(f"Unexpected error: {e}")
71
67
 
72
-
73
-
74
-
68
+
75
69
  def store(self, label: str, data: dict, ctx: Optional[str] = None):
76
70
  if ctx:
77
- full_url = f"http://{self.network}/store_ctx/{ctx}"
71
+ full_url = f"https://{self.network}/store_ctx/{ctx}"
78
72
  else:
79
- full_url = f"http://{self.network}/store"
73
+ full_url = f"https://{self.network}/store"
80
74
 
81
75
  store = {
82
76
  "label": label,
@@ -97,9 +91,9 @@ class Cell:
97
91
 
98
92
  def load(self, label: str, ctx: Optional[str] = None):
99
93
  if ctx:
100
- full_url = f"http://{self.network}/load_ctx/{ctx}"
94
+ full_url = f"https://{self.network}/load_ctx/{ctx}"
101
95
  else:
102
- full_url = f"http://{self.network}/load"
96
+ full_url = f"https://{self.network}/load"
103
97
 
104
98
  print(f"Full URL: {full_url}")
105
99
 
@@ -121,9 +115,9 @@ class Cell:
121
115
 
122
116
  def delete(self, label: str, ctx: Optional[str] = None):
123
117
  if ctx:
124
- full_url = f"http://{self.network}/delete_ctx/{ctx}"
118
+ full_url = f"https://{self.network}/delete_ctx/{ctx}"
125
119
  else:
126
- full_url = f"http://{self.network}/delete"
120
+ full_url = f"https://{self.network}/delete"
127
121
 
128
122
  print(f"Full URL: {full_url}")
129
123
 
@@ -142,4 +136,69 @@ class Cell:
142
136
  print(f"Unexpected error: {e}")
143
137
 
144
138
 
139
+ def clear(self, ctx: Optional[str] = None):
140
+ if ctx:
141
+ full_url = f"https://{self.network}/clear_ctx/{ctx}"
142
+ else:
143
+ full_url = f"https://{self.network}/clear"
144
+
145
+ print(f"Full URL: {full_url}")
146
+
147
+ clear = {
148
+ "cell": self.to_dict()
149
+ }
150
+
151
+ try:
152
+ response = requests.post(full_url, json=clear)
153
+ response.raise_for_status()
154
+ print(response.json())
155
+ except requests.exceptions.RequestException as e:
156
+ print(f"Error sending request: {e}")
157
+ except Exception as e:
158
+ print(f"Unexpected error: {e}")
159
+
160
+
161
+
162
+ def stream(self, data):
163
+ context = ssl.create_default_context()
164
+ context.check_hostname = True
165
+ context.verify_mode = ssl.CERT_REQUIRED
166
+ raw_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
167
+ self.sock = context.wrap_socket(raw_sock, server_hostname=self.network)
168
+
169
+ print("SSL socket set")
170
+
171
+ try:
172
+ print(f"Connecting to {self.network} on port 55555...")
173
+ self.sock.connect((self.network, 55555))
174
+ print("SSL socket connected")
175
+
176
+ if not self.authenticate(self.sock):
177
+ print("Authentication failed. Cannot stream.")
178
+ return
179
+
180
+ self.sock.sendall(data.encode('utf-8'))
181
+ print(f"Sent: {data}")
182
+
183
+ except ssl.SSLError as e:
184
+ print(f"SSL error occurred: {e}")
185
+
186
+ except Exception as e:
187
+ print(f"An unexpected error occurred: {e}")
188
+
189
+ finally:
190
+ self.sock.close()
191
+ print("SSL connection closed.")
192
+
193
+
194
+ def authenticate(self, sock):
195
+ credentials = f"{self.host}\n{self.password}\n{self.synapse}\n"
196
+ sock.sendall(credentials.encode('utf-8'))
197
+
198
+ response = sock.recv(1024).decode('utf-8')
199
+ print(response)
200
+ return "Authentication successful" in response
201
+
202
+
203
+
145
204
  __all__ = ['Cell']
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2025] [Neuronum Cybernetics UG (limited liability)]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.2
2
+ Name: neuronum
3
+ Version: 1.0.1
4
+ Summary: Interact with the Neuronum Network to build, connect & automate economic data streams
5
+ Author: Neuronum Cybernetics
6
+ Author-email: welcome@neuronum.net
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.6
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: requests
14
+ Dynamic: author
15
+ Dynamic: author-email
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: requires-dist
20
+ Dynamic: requires-python
21
+ Dynamic: summary
22
+
23
+ # Neuronum
24
+
25
+ ![Neuronum Logo](https://www.neuronum.net/logo_pip.png "Neuronum")
26
+
27
+ Interact with the `Neuronum` Network to build, connect & automate economic data streams.
28
+
29
+ ## Links and Resources
30
+ [![Website](https://img.shields.io/badge/Website-Neuronum-blue)](https://www.neuronum.net)
31
+ [![Documentation](https://img.shields.io/badge/Docs-Read%20now-green)](https://www.neuronum.net/docs)
32
+
33
+
34
+ ## Installation
35
+ Install the library using pip:
36
+
37
+ ```bash
38
+ pip install neuronum
@@ -0,0 +1,7 @@
1
+ neuronum/__init__.py,sha256=P0KTJMGY_eT3l5YzR4LHfl64KH5Qt_qhcrqf9Ld2G00,74
2
+ neuronum/neuronum.py,sha256=gDzg9aN4jjaBnKLLD9YRSvmV1uffKZOBJb8Fv-WDtfM,6186
3
+ neuronum-1.0.1.dist-info/LICENSE,sha256=UiZjNHiCyRP6WoZfbYQh9cv4JW96wIofKXmzBJrYSUk,1125
4
+ neuronum-1.0.1.dist-info/METADATA,sha256=RacuQWJASGGE7YZT1TBPtBo8cFxffGYdIDpu0nbmU2I,1148
5
+ neuronum-1.0.1.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
6
+ neuronum-1.0.1.dist-info/top_level.txt,sha256=73zXVVO9UTTiwEcSaXytsJ8n0q47OCwAqPlIh-hzWJU,9
7
+ neuronum-1.0.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,9 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: neuronum
3
- Version: 0.9.0
4
- Summary: A high-level coding library to build & automate economic data streams - The Neuronum Team
5
- Author: Neuronum Cybernetics
6
- Author-email: welcome@neuronum.net
7
- Requires-Python: >=3.6
8
- Requires-Dist: requests
9
-
@@ -1,6 +0,0 @@
1
- neuronum/__init__.py,sha256=P0KTJMGY_eT3l5YzR4LHfl64KH5Qt_qhcrqf9Ld2G00,74
2
- neuronum/neuronum.py,sha256=Qpcal4FhbUFpZoVaEJxVD_qM9X-Eq4Lw-vYqr_JbEGU,4259
3
- neuronum-0.9.0.dist-info/METADATA,sha256=jInFhXYs5P0s1oMWwASUi7vg02OkR-ZwaXdfPMexb_Q,272
4
- neuronum-0.9.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
5
- neuronum-0.9.0.dist-info/top_level.txt,sha256=73zXVVO9UTTiwEcSaXytsJ8n0q47OCwAqPlIh-hzWJU,9
6
- neuronum-0.9.0.dist-info/RECORD,,