naeural-client 2.6.1__py3-none-any.whl → 2.6.3__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
naeural_client/_ver.py CHANGED
@@ -1,4 +1,4 @@
1
- __VER__ = "2.6.1"
1
+ __VER__ = "2.6.3"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
naeural_client/bc/base.py CHANGED
@@ -1252,15 +1252,20 @@ class BaseBlockEngine:
1252
1252
  dct_env = {k : v for k,v in dct_result.items() if k.startswith('EE_')}
1253
1253
  self.P("Found {} keys in dAuth response.".format(len(dct_env)), color='g')
1254
1254
  for k, v in dct_env.items():
1255
+ try:
1256
+ if not isinstance(v, str):
1257
+ v = json.dumps(v)
1258
+ except:
1259
+ v = str(v)
1255
1260
  if k not in os.environ:
1256
- self.P(f" Adding key `{k}{'=' + str(v) if debug else ''}` to env.", color='y')
1261
+ self.P(f" Adding key `{k}{'=' + str(v) + ' ({})'.format(type(v).__name__) if debug else ''}` to env.", color='y')
1257
1262
  else:
1258
- self.P(f" Overwrite `{k}{'=' + str(v) if debug else ''}` in env.", color='y')
1263
+ self.P(f" Overwrite `{k}{'=' + str(v) + ' ({})'.format(type(v).__name__) if debug else ''}` in env.", color='y')
1259
1264
  if add_env:
1260
1265
  os.environ[k] = v
1261
1266
  done = True
1262
1267
  except Exception as exc:
1263
- self.P(f"Error in dAuth URL request: {exc}", color='r')
1268
+ self.P(f"Error in dAuth URL request: {exc}. Received: {dct_result}", color='r')
1264
1269
  #end try
1265
1270
  tries += 1
1266
1271
  if tries >= max_tries:
naeural_client/cli/cli.py CHANGED
@@ -34,7 +34,7 @@ def build_parser():
34
34
  """
35
35
  global_parser = create_global_parser() # Add global parameters
36
36
 
37
- title = f"nepctl v{version} - CLI for Naeural Edge Protocol SDK package"
37
+ title = f"nepctl for SDK v{version} - CLI for Naeural Edge Protocol SDK package"
38
38
  parser = argparse.ArgumentParser(description=title, parents=[global_parser])
39
39
  subparsers = parser.add_subparsers(dest="command", help="Available commands")
40
40
 
@@ -31,6 +31,11 @@ CLI_COMMANDS = {
31
31
  "reset": {
32
32
  "func": reset_config, # DONE
33
33
  "description": "Reset the configuration to default",
34
+ # "params": {
35
+ # ### use "(flag)" at the end of the description to indicate a boolean flag
36
+ # ### otherwise it will be treated as a str parameter
37
+ # "--force": "Force reset (flag)", # DONE
38
+ # }
34
39
  },
35
40
  "addr": {
36
41
  "func": show_address, # DONE
@@ -335,7 +335,13 @@ class BaseLogger(object):
335
335
  return False
336
336
 
337
337
  @staticmethod
338
- def replace_secrets(dct_config, pattern='$EE_', allow_missing=False):
338
+ def replace_secrets(dct_config, pattern='$EE_', allow_missing=True, missing_default=None):
339
+ """
340
+ TODO: maybe move to Jinja2 style
341
+ "{{ some_variable | default('my_default') }}"
342
+
343
+
344
+ """
339
345
  matches = []
340
346
  missing = []
341
347
  stack = [dct_config]
@@ -350,7 +356,7 @@ class BaseLogger(object):
350
356
  if env_var_name not in os.environ:
351
357
  missing.append(env_var_name)
352
358
  if allow_missing:
353
- current[key] = None
359
+ current[key] = missing_default
354
360
  else:
355
361
  current[key] = os.environ[env_var_name]
356
362
  elif isinstance(value, (dict, list)):
@@ -3,6 +3,7 @@ from pathlib import Path
3
3
  import shutil
4
4
 
5
5
  from naeural_client.const.base import BCct
6
+ from naeural_client._ver import __VER__ as version
6
7
 
7
8
 
8
9
  CONFIG_FILE = "config"
@@ -70,7 +71,9 @@ def log_with_color(s, color='n'):
70
71
  'b': "\033[36m", # bright cyan
71
72
  'w': '\033[97m', # Light white
72
73
  'c': "\033[36m", # bright cyan
73
- 'n': '\033[37m', # Dark white (default)
74
+ 'n': '\033[37m', # white (default)
75
+ 'd': "\033[90m", # dark gray
76
+
74
77
  }
75
78
 
76
79
  reset_code = '\033[0m' # Reset color
@@ -90,7 +93,7 @@ def get_user_config_file():
90
93
  """
91
94
  return get_user_folder() / CONFIG_FILE
92
95
 
93
- def reset_config(*larg, **kwargs):
96
+ def reset_config(*larg, keep_existing=False, **kwargs):
94
97
  """
95
98
  Resets the configuration by creating a ~/.naeural folder and populating
96
99
  ~/.naeural/config with values from a local .env file, if it exists.
@@ -130,7 +133,12 @@ def reset_config(*larg, **kwargs):
130
133
  log_with_color(f"Copying local PEM file {local_pem} to {target_pem}", color='y')
131
134
  shutil.copy(local_pem, target_pem)
132
135
  else:
133
- log_with_color(f"No local PEM file found at {local_pem}. A default private key will be generated.", color='r')
136
+ log_with_color(f"No local PEM file found locally {local_pem}.", color='r')
137
+ if target_pem.exists():
138
+ log_with_color(f"Found already existing {target_pem}.", color='y')
139
+ if not keep_existing:
140
+ target_pem.unlink()
141
+ log_with_color(f"Deleted {target_pem}. A default key will be generated.", color='b')
134
142
  return
135
143
 
136
144
  def show_address(args):
@@ -144,25 +152,29 @@ def show_address(args):
144
152
  log_with_color(f"{sess.get_client_address()}", color='b')
145
153
  return
146
154
 
147
-
148
- def show_config(args):
149
- """
150
- Displays the current configuration from ~/.naeural/config.
151
- """
155
+ def show_version():
152
156
  from naeural_client import Session
153
157
  sess = Session(
154
158
  silent=True
155
- )
159
+ )
156
160
 
157
- user_folder = get_user_folder()
158
- config_file = get_user_config_file()
161
+ user_folder = get_user_folder()
159
162
 
160
163
  log_with_color(f"NEP SDK folder: {user_folder}", color='b')
164
+ log_with_color(f"NEP SDK version: {version}", color='b')
161
165
  log_with_color(f"SDK Client address: {sess.get_client_address()}", color='b')
166
+ return
167
+
168
+
169
+ def show_config(args):
170
+ """
171
+ Displays the current configuration from ~/.naeural/config.
172
+ """
173
+ show_version()
174
+ config_file = get_user_config_file()
162
175
  if config_file.exists():
163
- log_with_color(f"Current configuration ({config_file}):", color='y')
164
176
  with config_file.open("r") as file:
165
- log_with_color(file.read())
177
+ log_with_color(f"Current configuration ({config_file}):\n{file.read()}", color='d')
166
178
  else:
167
179
  log_with_color(f"No configuration found at {config_file}. Please run `reset_config` first.", color="r")
168
180
  return
@@ -202,7 +214,7 @@ def maybe_init_config():
202
214
  """
203
215
  config_file = get_user_config_file()
204
216
  if not config_file.exists():
205
- log_with_color(f"No configuration file found at {config_file}. Initializing configuration...", color="y")
206
- reset_config()
217
+ log_with_color(f"No configuration file found at {config_file}. Initializing configuration...", color="y")
218
+ reset_config(keep_existing=True)
207
219
  return False
208
220
  return load_user_defined_config()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: naeural_client
3
- Version: 2.6.1
3
+ Version: 2.6.3
4
4
  Summary: `naeural_client` is the Python SDK required for client app development for the Naeural Edge Protocol Edge Protocol framework
5
5
  Project-URL: Homepage, https://github.com/NaeuralEdgeProtocol/naeural_client
6
6
  Project-URL: Bug Tracker, https://github.com/NaeuralEdgeProtocol/naeural_client/issues
@@ -1,5 +1,5 @@
1
1
  naeural_client/__init__.py,sha256=YimqgDbjLuywsf8zCWE0EaUXH4MBUrqLxt0TDV558hQ,632
2
- naeural_client/_ver.py,sha256=wxvGE0zwZeIkiIricsimOfmCLopTSbo_If_EzC5os7A,330
2
+ naeural_client/_ver.py,sha256=NuULiWsf-aS2VC8vLy2w45Z1bMlgxJj0Z1TPWjAF5dQ,330
3
3
  naeural_client/base_decentra_object.py,sha256=C4iwZTkhKNBS4VHlJs5DfElRYLo4Q9l1V1DNVSk1fyQ,4412
4
4
  naeural_client/plugins_manager_mixin.py,sha256=X1JdGLDz0gN1rPnTN_5mJXR8JmqoBFQISJXmPR9yvCo,11106
5
5
  naeural_client/base/__init__.py,sha256=hACh83_cIv7-PwYMM3bQm2IBmNqiHw-3PAfDfAEKz9A,259
@@ -14,14 +14,14 @@ naeural_client/base/webapp_pipeline.py,sha256=QmPLVmhP0CPdi0YuvbZEH4APYz2Amtw3gy
14
14
  naeural_client/base/payload/__init__.py,sha256=y8fBI8tG2ObNfaXFWjyWZXwu878FRYj_I8GIbHT4GKE,29
15
15
  naeural_client/base/payload/payload.py,sha256=x-au7l67Z_vfn_4R2C_pjZCaFuUVXHngJiGOfIAYVdE,2690
16
16
  naeural_client/bc/__init__.py,sha256=FQj23D1PrY06NUOARiKQi4cdj0-VxnoYgYDEht8lpr8,158
17
- naeural_client/bc/base.py,sha256=gKpwivIyxBeuTdbNTfAJEWTi5U6a4XAV63tD3QsuhYE,34280
17
+ naeural_client/bc/base.py,sha256=Egi9g_uW49QiRHx5xHr3GboM5Po3UG06VlOFnRXGcd0,34511
18
18
  naeural_client/bc/chain.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  naeural_client/bc/ec.py,sha256=qI8l7YqiS4MNftlx-tF7IZUswrSeQc7KMn5OZ0fEaJs,23370
20
20
  naeural_client/certs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  naeural_client/certs/r9092118.ala.eu-central-1.emqxsl.com.crt,sha256=y-6io0tseyx9-a4Pmde1z1gPULtJNSYUpG_YFkYaMKU,1337
22
22
  naeural_client/cli/README.md,sha256=WPdI_EjzAbUW1aPyj1sSR8rLydcJKZtoiaEtklQrjHo,74
23
- naeural_client/cli/cli.py,sha256=Lo5qsANtjvWP0CG2BxIdYF8QLSpUQoLmYIgCGCVZp9Y,3808
24
- naeural_client/cli/cli_commands.py,sha256=Y81oKz5Rx8qxYgzEzCwI9eB8iVL6iET7dETLVygs_VE,1686
23
+ naeural_client/cli/cli.py,sha256=c0ZavVwArQEGv8tueTnz3aGKTuUe6Sqmm5oTUFUVIUE,3816
24
+ naeural_client/cli/cli_commands.py,sha256=VffU1tpG1CGae6z4GtcAdktAlEAfIiXq9n2oHAx1kAI,1944
25
25
  naeural_client/cli/nodes.py,sha256=Oq7bh7kkU79doBLEa8ANU6OiWv83mJvyjFyZqwpKx1s,4595
26
26
  naeural_client/code_cheker/__init__.py,sha256=pwkdeZGVL16ZA4Qf2mRahEhoOvKhL7FyuQbMFLr1E5M,33
27
27
  naeural_client/code_cheker/base.py,sha256=lT5DRIFO5rqzsMNCmdMRfkAeevmezozehyfgmhnKpuI,19074
@@ -57,7 +57,7 @@ naeural_client/io_formatter/default/a_dummy.py,sha256=qr9eUizQ-NN5jdXVzkaZKMaf9K
57
57
  naeural_client/io_formatter/default/aixp1.py,sha256=MX0TeUR4APA-qN3vUC6uzcz8Pssz5lgrQWo7td5Ri1A,3052
58
58
  naeural_client/io_formatter/default/default.py,sha256=gEy78cP2D5s0y8vQh4aHuxqz7D10gGfuiKF311QhrpE,494
59
59
  naeural_client/logging/__init__.py,sha256=b79X45VC6c37u32flKB2GAK9f-RR0ocwP0JDCy0t7QQ,33
60
- naeural_client/logging/base_logger.py,sha256=K3pFqtM8bjQ8w9LqKXbDZodh77ZO-stTW_wN5KVe14U,66242
60
+ naeural_client/logging/base_logger.py,sha256=9H4ShdG4gsUCyznwficU4iym_kLZdNaxRAD_INfLV68,66392
61
61
  naeural_client/logging/small_logger.py,sha256=m12hCb_H4XifJYYfgCAOUDkcXm-h4pSODnFf277OFVI,2937
62
62
  naeural_client/logging/logger_mixins/__init__.py,sha256=yQO7umlRvz63FeWpi-F9GRmC_MOHcNW6R6pwvZZBy3A,600
63
63
  naeural_client/logging/logger_mixins/class_instance_mixin.py,sha256=xUXE2VZgmrlrSrvw0f6GF1jlTnVLeVkIiG0bhlBfq3o,2741
@@ -79,10 +79,10 @@ naeural_client/logging/tzlocal/win32.py,sha256=zBoj0vFVrGhnCm_f7xmYzGym4-fV-4Ij2
79
79
  naeural_client/logging/tzlocal/windows_tz.py,sha256=Sv9okktjZJfRGGUOOppsvQuX_eXyXUxkSKCAFmWT9Hw,34203
80
80
  naeural_client/utils/__init__.py,sha256=mAnke3-MeRzz3nhQvhuHqLnpaaCSmDxicd7Ck9uwpmI,77
81
81
  naeural_client/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,1072
82
- naeural_client/utils/config.py,sha256=JfW2gMQMYx9NzF2M4mJpioXawDHcOQ3deJprpCRtdOI,5874
82
+ naeural_client/utils/config.py,sha256=v7xHikr6Z5Sbvf3opYeMhYzGWD2pe0HlRwa-aGJzUh8,6323
83
83
  naeural_client/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
84
- naeural_client-2.6.1.dist-info/METADATA,sha256=5K50wytOF7_Wa3xjBuIy0YE7Dpxs-gmVGutEQT4-erE,14618
85
- naeural_client-2.6.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
86
- naeural_client-2.6.1.dist-info/entry_points.txt,sha256=PNdyotDaQBAslZREx5luVyj0kqpQnwNACwkFNTPIHU4,55
87
- naeural_client-2.6.1.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
88
- naeural_client-2.6.1.dist-info/RECORD,,
84
+ naeural_client-2.6.3.dist-info/METADATA,sha256=p53aQNM4rFJf6a3KmbVaniER0em60gR3IDGJ-dux3Es,14618
85
+ naeural_client-2.6.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
86
+ naeural_client-2.6.3.dist-info/entry_points.txt,sha256=PNdyotDaQBAslZREx5luVyj0kqpQnwNACwkFNTPIHU4,55
87
+ naeural_client-2.6.3.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
88
+ naeural_client-2.6.3.dist-info/RECORD,,