neuronum 7.0.1__py3-none-any.whl → 7.0.3__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.

cli/main.py CHANGED
@@ -330,11 +330,19 @@ async def async_init_node(descr):
330
330
  import asyncio
331
331
  import neuronum
332
332
  import os
333
+ import json
333
334
  from dotenv import load_dotenv
334
335
  from jinja2 import Environment, FileSystemLoader
335
336
 
336
337
  env = Environment(loader=FileSystemLoader('.'))
337
- template = env.get_template('ping.html')
338
+ template = env.get_template('ping.html')
339
+
340
+ with open('config.json', 'r') as f:
341
+ data = json.load(f)
342
+ terms_url = data['legals']['terms']
343
+ privacy_url = data['legals']['privacy_policy']
344
+ last_update = data['legals']['last_update']
345
+
338
346
 
339
347
  load_dotenv()
340
348
  host = os.getenv("HOST")
@@ -360,10 +368,10 @@ async def main():
360
368
 
361
369
  if txID == "{txID}":
362
370
 
363
- def render_html_template(client, ts, data, operation_id):
364
- return template.render(client=client, ts=ts, data=data, operation_id=operation_id)
371
+ def render_html_template(client, ts, data, operation_id, terms_url, privacy_url, last_update):
372
+ return template.render(client=client, ts=ts, data=data, operation_id=operation_id, terms_url=terms_url, privacy_url=privacy_url, last_update=last_update)
365
373
 
366
- html_content = render_html_template(client, ts, data, operation_id)
374
+ html_content = render_html_template(client, ts, data, operation_id, terms_url, privacy_url, last_update)
367
375
 
368
376
  data = {{
369
377
  "json": f"{{operation_id}} - Reply from {nodeID}: Pinged by {{client}} at {{ts}} with data: {{data}}",
@@ -550,6 +558,25 @@ asyncio.run(main())
550
558
  }});
551
559
  }});
552
560
  </script>
561
+
562
+ <div id="legal-banner" style="border-radius: 10px; margin: 15px; position: fixed; bottom: 0; left: 0; right: 0; background-color: #2a2a2a; color: #e0e0e0; padding: 16px; text-align: center; font-size: 14px; z-index: 9999; box-shadow: 0 -2px 10px rgba(0,0,0,0.5);">
563
+ By continuing, you agree to our
564
+ Terms (<span style="color: #8cafff;">{{{{terms_url}}}}</span>) &
565
+ Privacy Policy (<span style="color: #8cafff;">{{{{privacy_url}}}}</span>)
566
+ <br>
567
+ <button id="accept-legal" style="margin-top: 15px; margin-bottom: 15px; background: #01c07d; color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer;">Accept</button>
568
+ <br>
569
+ Last Update: {{{{last_update}}}}
570
+ </div>
571
+
572
+ <script>
573
+ const banner = document.getElementById('legal-banner');
574
+ const acceptBtn = document.getElementById('accept-legal');
575
+ acceptBtn.addEventListener('click', () => {{
576
+ banner.remove();
577
+ }});
578
+ </script>
579
+
553
580
  </body>
554
581
  </html>
555
582
  """
@@ -572,8 +599,9 @@ f"""{{
572
599
  }}
573
600
  ],
574
601
  "legals": {{
575
- "terms_and_conditions": "https://neuronum.net/legals",
576
- "data_privacy": "https://neuronum.net/legals"
602
+ "terms": "https://url_to_your/terms",
603
+ "privacy_policy": "https://url_to_your/privacy_policy",
604
+ "last_update" : "DD/MM/YYYY"
577
605
  }}
578
606
  }}"""
579
607
  )
@@ -593,14 +621,6 @@ To ping this Node via the command-line interface, use the following command:
593
621
 
594
622
  ***
595
623
 
596
- ### 🌐 Via the Web
597
-
598
- You can also interact with this Node by simply visiting this URL in your web browser:
599
-
600
- [https://neuronum.net/tx/{txID}](https://neuronum.net/tx/{txID})
601
-
602
- ***
603
-
604
624
  ### 🐍 With Python
605
625
 
606
626
  For programmatic access, use the following Python code snippet. This script utilizes the `neuronum` library to activate the transaction and receive a response.
@@ -644,7 +664,7 @@ Send the command "Ping Node" to Cellai
644
664
  @click.command()
645
665
  @click.option('--d', is_flag=True, help="Start node in detached mode")
646
666
  def start_node(d):
647
- update_node()
667
+ update_node_at_start()
648
668
  pid_file = Path.cwd() / "status.txt"
649
669
  system_name = platform.system()
650
670
  active_pids = []
@@ -772,7 +792,7 @@ def check_node():
772
792
  @click.command()
773
793
  @click.option('--d', is_flag=True, help="Restart node in detached mode")
774
794
  def restart_node(d):
775
- update_node()
795
+ update_node_at_start()
776
796
  pid_file = Path.cwd() / "status.txt"
777
797
  system_name = platform.system()
778
798
 
@@ -903,6 +923,7 @@ async def async_stop_node():
903
923
  click.echo("Error: Unable to stop some node processes.")
904
924
 
905
925
 
926
+ @click.command()
906
927
  def update_node():
907
928
  click.echo("Update your Node")
908
929
  env_data = {}
@@ -1022,6 +1043,125 @@ async def async_update_node(node_type: str, descr: str, partners:str) -> None:
1022
1043
  click.echo(f"Neuronum Node '{nodeID}' updated!")
1023
1044
 
1024
1045
 
1046
+ def update_node_at_start():
1047
+ click.echo("Update your Node")
1048
+ env_data = {}
1049
+
1050
+ try:
1051
+ with open(".env", "r") as f:
1052
+ for line in f:
1053
+ key, value = line.strip().split("=")
1054
+ env_data[key] = value
1055
+
1056
+ host = env_data.get("HOST", "")
1057
+
1058
+ except FileNotFoundError:
1059
+ click.echo("Error: .env with credentials not found")
1060
+ return
1061
+ except Exception as e:
1062
+ click.echo(f"Error reading .env file: {e}")
1063
+ return
1064
+
1065
+ if host.startswith("CMTY_"):
1066
+ node_type = questionary.select(
1067
+ "Community Cells can only create private Nodes",
1068
+ choices=["private"]
1069
+ ).ask()
1070
+ else:
1071
+ node_type = questionary.select(
1072
+ "Who can view your Node?:",
1073
+ choices=["public", "private", "partners"]
1074
+ ).ask()
1075
+ partners = "None"
1076
+ if node_type == "partners":
1077
+ prompt_msg = (
1078
+ "Enter the list of partners who can view this Node.\n"
1079
+ "Format: partner::cell, partner::cell, partner::cell\n"
1080
+ "Press Enter to leave the list unchanged"
1081
+ )
1082
+ partners = click.prompt(
1083
+ prompt_msg,
1084
+ default="None",
1085
+ show_default=False
1086
+ ).strip()
1087
+ descr = click.prompt(
1088
+ "Update Node description: Type up to 25 characters, or press Enter to leave it unchanged",
1089
+ default="None",
1090
+ show_default=False
1091
+ ).strip()
1092
+ if descr and len(descr) > 25:
1093
+ click.echo("Description too long. Max 25 characters allowed.")
1094
+ return
1095
+ asyncio.run(async_update_node_at_start(node_type, descr, partners))
1096
+
1097
+ async def async_update_node_at_start(node_type: str, descr: str, partners:str) -> None:
1098
+ env_data = {}
1099
+
1100
+ try:
1101
+ with open(".env", "r") as f:
1102
+ for line in f:
1103
+ key, value = line.strip().split("=")
1104
+ env_data[key] = value
1105
+
1106
+ nodeID = env_data.get("NODE", "")
1107
+ host = env_data.get("HOST", "")
1108
+ password = env_data.get("PASSWORD", "")
1109
+ network = env_data.get("NETWORK", "")
1110
+ synapse = env_data.get("SYNAPSE", "")
1111
+
1112
+ except FileNotFoundError:
1113
+ click.echo("Error: .env with credentials not found")
1114
+ return
1115
+ except Exception as e:
1116
+ click.echo(f"Error reading .env file: {e}")
1117
+ return
1118
+
1119
+ try:
1120
+ with open("NODE.md", "r") as f:
1121
+ nodemd_file = f.read()
1122
+
1123
+ with open("config.json", "r") as f:
1124
+ config_file = f.read()
1125
+
1126
+ except FileNotFoundError:
1127
+ click.echo("Error: NODE.md file not found")
1128
+ return
1129
+ except Exception as e:
1130
+ click.echo(f"Error reading NODE.md file: {e}")
1131
+ return
1132
+
1133
+ if node_type == "partners":
1134
+ node_type = partners
1135
+
1136
+ url = f"https://{network}/api/update_node"
1137
+ node = {
1138
+ "nodeID": nodeID,
1139
+ "host": host,
1140
+ "password": password,
1141
+ "synapse": synapse,
1142
+ "node_type": node_type,
1143
+ "nodemd_file": nodemd_file,
1144
+ "config_file": config_file,
1145
+ "descr": descr,
1146
+ }
1147
+
1148
+ async with aiohttp.ClientSession() as session:
1149
+ try:
1150
+ async with session.post(url, json=node) as response:
1151
+ response.raise_for_status()
1152
+ data = await response.json()
1153
+ nodeID = data["nodeID"]
1154
+ node_url = data["node_url"]
1155
+ except aiohttp.ClientError as e:
1156
+ click.echo(f"Error sending request: {e}")
1157
+ return
1158
+
1159
+ if node_type == "public":
1160
+ click.echo(f"Neuronum Node '{nodeID}' updated! Visit: {node_url}")
1161
+ else:
1162
+ click.echo(f"Neuronum Node '{nodeID}' updated!")
1163
+
1164
+
1025
1165
  @click.command()
1026
1166
  def delete_node():
1027
1167
  asyncio.run(async_delete_node())
@@ -1199,6 +1339,7 @@ cli.add_command(view_cell)
1199
1339
  cli.add_command(disconnect_cell)
1200
1340
  cli.add_command(delete_cell)
1201
1341
  cli.add_command(init_node)
1342
+ cli.add_command(update_node)
1202
1343
  cli.add_command(start_node)
1203
1344
  cli.add_command(restart_node)
1204
1345
  cli.add_command(stop_node)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: neuronum
3
- Version: 7.0.1
3
+ Version: 7.0.3
4
4
  Summary: Official client library to interact with the Neuronum Network
5
5
  Home-page: https://neuronum.net
6
6
  Author: Neuronum Cybernetics
@@ -139,12 +139,6 @@ neuronum start-node # start Node
139
139
  ------------------
140
140
 
141
141
  ### **Interact with Neuronum**
142
- #### **Web-based**
143
- 1. [Visit Neuronum](https://neuronum.net)
144
- 2. [Connect your Cell](https://neuronum.net/connect)
145
- 3. [Explore Transmitters](https://neuronum.net/explore)
146
- 4. Activate Transmitters
147
-
148
142
  #### **Code-based**
149
143
  ```python
150
144
  import asyncio
@@ -0,0 +1,10 @@
1
+ cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ cli/main.py,sha256=MrRpf9AxBcl9e4B9pFVUxO2V1seliyGBK3XCuUzKjDc,41472
3
+ neuronum/__init__.py,sha256=tAdqNC9rByY_CwG63yAyEe34phBdQ_Vv3FyFpTXQ2wo,45
4
+ neuronum/neuronum.py,sha256=5OjJIAmY7haT6eJ3P767RFk-LTvNFRrlkjB9mOozgN8,17971
5
+ neuronum-7.0.3.dist-info/licenses/LICENSE.md,sha256=m7pw_FktMNCs4tcy2UXP3QQP2S_je28P1SepdYoo0Xo,1961
6
+ neuronum-7.0.3.dist-info/METADATA,sha256=Rn2WcJC83PX7ZmwveVqDQN0-bzkO6TcmO0SBbNPV6xE,5902
7
+ neuronum-7.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ neuronum-7.0.3.dist-info/entry_points.txt,sha256=XKYBcRNxGeJpZZkDPsa8HA_RaJ7Km_R_JaUq5T9Nk2U,42
9
+ neuronum-7.0.3.dist-info/top_level.txt,sha256=ru8Fr84cHm6oHr_DcJ8-uaq3RTiuCRFIr6AC8V0zPu4,13
10
+ neuronum-7.0.3.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- cli/main.py,sha256=nOoWfn7zdukLZQuGYx-47nINMZVSdPbcdMuu0bDCKzM,36520
3
- neuronum/__init__.py,sha256=tAdqNC9rByY_CwG63yAyEe34phBdQ_Vv3FyFpTXQ2wo,45
4
- neuronum/neuronum.py,sha256=5OjJIAmY7haT6eJ3P767RFk-LTvNFRrlkjB9mOozgN8,17971
5
- neuronum-7.0.1.dist-info/licenses/LICENSE.md,sha256=m7pw_FktMNCs4tcy2UXP3QQP2S_je28P1SepdYoo0Xo,1961
6
- neuronum-7.0.1.dist-info/METADATA,sha256=ymaVKlx87rwW30nBkXE-wxgPRo8KaI9cfjkV4etqZGM,6098
7
- neuronum-7.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- neuronum-7.0.1.dist-info/entry_points.txt,sha256=XKYBcRNxGeJpZZkDPsa8HA_RaJ7Km_R_JaUq5T9Nk2U,42
9
- neuronum-7.0.1.dist-info/top_level.txt,sha256=ru8Fr84cHm6oHr_DcJ8-uaq3RTiuCRFIr6AC8V0zPu4,13
10
- neuronum-7.0.1.dist-info/RECORD,,