micrOSDevToolKit 2.9.4__py3-none-any.whl → 2.9.7__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 micrOSDevToolKit might be problematic. Click here for more details.

Files changed (57) hide show
  1. micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +19 -19
  2. micrOS/source/Config.py +6 -6
  3. micrOS/source/LM_pacman.py +248 -0
  4. micrOS/source/LM_rest.py +0 -1
  5. micrOS/source/LM_robustness.py +2 -2
  6. micrOS/source/LM_system.py +4 -16
  7. micrOS/source/LM_telegram.py +95 -61
  8. micrOS/source/Logger.py +41 -15
  9. micrOS/source/Notify.py +4 -3
  10. micrOS/source/Server.py +5 -2
  11. micrOS/source/Shell.py +2 -2
  12. micrOS/source/Web.py +22 -23
  13. micrOS/source/microIO.py +1 -2
  14. micrOS/source/reset.py +5 -1
  15. micrOS/source/urequests.py +12 -4
  16. {micrOSDevToolKit-2.9.4.data → micrOSDevToolKit-2.9.7.data}/scripts/devToolKit.py +3 -2
  17. {micrOSDevToolKit-2.9.4.dist-info → micrOSDevToolKit-2.9.7.dist-info}/METADATA +1 -1
  18. {micrOSDevToolKit-2.9.4.dist-info → micrOSDevToolKit-2.9.7.dist-info}/RECORD +55 -52
  19. toolkit/Gateway.py +2 -2
  20. toolkit/LM_to_compile.dat +1 -1
  21. toolkit/dashboard_apps/SystemTest.py +12 -11
  22. toolkit/index.html +4 -4
  23. toolkit/lib/macroScript.py +6 -0
  24. toolkit/lib/micrOSClient.py +35 -8
  25. toolkit/lib/micrOSClientHistory.py +122 -0
  26. toolkit/micrOSlint.py +1 -1
  27. toolkit/simulator_lib/__pycache__/machine.cpython-312.pyc +0 -0
  28. toolkit/simulator_lib/__pycache__/uasyncio.cpython-312.pyc +0 -0
  29. toolkit/simulator_lib/__pycache__/uos.cpython-312.pyc +0 -0
  30. toolkit/simulator_lib/__pycache__/ussl.cpython-312.pyc +0 -0
  31. toolkit/simulator_lib/machine.py +4 -0
  32. toolkit/simulator_lib/node_config.json +1 -1
  33. toolkit/simulator_lib/uasyncio.py +7 -1
  34. toolkit/simulator_lib/uos.py +138 -0
  35. toolkit/socketClient.py +2 -2
  36. toolkit/workspace/precompiled/Config.mpy +0 -0
  37. toolkit/workspace/precompiled/Espnow.mpy +0 -0
  38. toolkit/workspace/precompiled/LM_pacman.mpy +0 -0
  39. toolkit/workspace/precompiled/LM_rest.mpy +0 -0
  40. toolkit/workspace/precompiled/LM_robustness.py +2 -2
  41. toolkit/workspace/precompiled/LM_system.mpy +0 -0
  42. toolkit/workspace/precompiled/LM_telegram.mpy +0 -0
  43. toolkit/workspace/precompiled/Logger.mpy +0 -0
  44. toolkit/workspace/precompiled/Notify.mpy +0 -0
  45. toolkit/workspace/precompiled/Server.mpy +0 -0
  46. toolkit/workspace/precompiled/Shell.mpy +0 -0
  47. toolkit/workspace/precompiled/Web.mpy +0 -0
  48. toolkit/workspace/precompiled/_mpy.version +1 -1
  49. toolkit/workspace/precompiled/microIO.mpy +0 -0
  50. toolkit/workspace/precompiled/node_config.json +1 -1
  51. toolkit/workspace/precompiled/reset.mpy +0 -0
  52. toolkit/workspace/precompiled/urequests.mpy +0 -0
  53. micrOS/source/LM_lmpacman.py +0 -126
  54. toolkit/workspace/precompiled/LM_lmpacman.mpy +0 -0
  55. {micrOSDevToolKit-2.9.4.dist-info → micrOSDevToolKit-2.9.7.dist-info}/LICENSE +0 -0
  56. {micrOSDevToolKit-2.9.4.dist-info → micrOSDevToolKit-2.9.7.dist-info}/WHEEL +0 -0
  57. {micrOSDevToolKit-2.9.4.dist-info → micrOSDevToolKit-2.9.7.dist-info}/top_level.txt +0 -0
@@ -214,3 +214,7 @@ def unique_id():
214
214
 
215
215
  def time_pulse_us():
216
216
  return time.time_ns()*1000
217
+
218
+
219
+ def SDCard():
220
+ pass
@@ -2,6 +2,6 @@
2
2
  "devfid": "simulator",
3
3
  "appwd": "ADmin123",
4
4
  "webui": true,
5
- "boothook": "dashboard_be load; neopixel load; #system top",
5
+ "boothook": "dashboard_be load; neopixel load; #telegram receiver_loop &2000",
6
6
  "aioqueue": 4,
7
7
  "telegram": "6185435843:AAH71wEyoOil8bRKecQHp4zazTQ_MmE7bvE"}
@@ -1,8 +1,14 @@
1
1
  import asyncio
2
+ import ssl
3
+
4
+ ssl_context = ssl.create_default_context()
5
+ ssl_context.check_hostname = False # Disable hostname check
6
+ ssl_context.verify_mode = ssl.CERT_NONE # Disable certificate verification
2
7
 
3
8
 
4
9
  def open_connection(host, port, ssl=False):
5
- return asyncio.open_connection(host, port, ssl=ssl)
10
+ #return asyncio.open_connection(host, port, ssl=ssl)
11
+ return asyncio.open_connection(host, port, ssl=ssl_context if ssl else None)
6
12
 
7
13
 
8
14
  class Lock(asyncio.Lock):
@@ -0,0 +1,138 @@
1
+ import os
2
+ import stat as py_fs_stat
3
+
4
+ # https://docs.micropython.org/en/v1.9.2/pyboard/library/uos.html
5
+ # https://docs.micropython.org/en/v1.18/library/os.html
6
+
7
+ MOCK_SIM = False
8
+
9
+ def listdir(path=None):
10
+ if path is None:
11
+ return os.listdir()
12
+ path = __mock_sim_dir(path)
13
+ print(f"[uos.SIM] listdir: {path}")
14
+ return os.listdir(path)
15
+
16
+
17
+ def getcwd():
18
+ _cwd = os.getcwd()
19
+ if MOCK_SIM:
20
+ cwd = f"{_cwd}/../workspace/simulator/"
21
+ print(f"MOCK PATH: {cwd}")
22
+ elif "workspace/simulator" not in _cwd:
23
+ cwd = f"{_cwd}/toolkit/workspace/simulator/"
24
+ print(f"[uos.SIM] MOCK PATH: {_cwd} -> {cwd}")
25
+ else:
26
+ cwd = _cwd
27
+ return cwd
28
+
29
+
30
+ def __mock_sim_dir(path):
31
+ """
32
+ micropython sim hack
33
+ """
34
+ if MOCK_SIM:
35
+ cwd = getcwd()
36
+ path = f"{cwd}{path}"
37
+ print(f"[!!!] [uos.SIM] CWD PATH HACK: {path}")
38
+ elif "workspace/simulator" not in path:
39
+ path = f"{getcwd()}{path}"
40
+ return path
41
+
42
+
43
+ def ilistdir(path):
44
+ buffer = []
45
+ for filename in listdir(path):
46
+ _name, _type, _inode = filename, stat(f"{path}/{filename}")[0], 0
47
+ print(f"[uos.SIM] ilistdir {path}: ({_name}, {_type:#x}, {_inode}")
48
+ buffer.append((_name, _type, _inode))
49
+ return tuple(buffer)
50
+
51
+
52
+ def mkdir(path):
53
+ print(f"[uos.SIM] mkdir: {path}")
54
+ return os.mkdir(path)
55
+
56
+
57
+ def remove(path):
58
+ path = __mock_sim_dir(path)
59
+ print(f"[uos.SIM] remove: {path}")
60
+ if "simulator" in path and path.replace('/', '').endswith('simulator'):
61
+ print(f"\t[uos.SIM] rmdir: Invalid path! {path}")
62
+ return False
63
+ return os.remove(path)
64
+
65
+
66
+ def rename(old_path, new_path):
67
+ old_path, new_path = __mock_sim_dir(old_path), __mock_sim_dir(new_path)
68
+ print(f"[uos.SIM] rename: {old_path} -> {new_path}")
69
+ os.rename(old_path, new_path)
70
+
71
+ def _stat_eval(stat_result):
72
+ """
73
+ micropython converter
74
+ """
75
+ micropython_file_identifier = {'dir': 0x4000, 'file': 0x8000}
76
+ # Check if it's a file
77
+ if py_fs_stat.S_ISREG(stat_result.st_mode):
78
+ # FILE
79
+ return (micropython_file_identifier['file'],)
80
+ if py_fs_stat.S_ISDIR(stat_result.st_mode):
81
+ # DIRECTORY
82
+ return (micropython_file_identifier['dir'],)
83
+ return (0x0,)
84
+
85
+ def stat(path):
86
+ path = __mock_sim_dir(path)
87
+ stat_result = os.stat(path)
88
+ micropython_stat_result = _stat_eval(stat_result)
89
+ path_type = 'dir' if micropython_stat_result[0] & 0x4000 else 'file'
90
+ print(f"[uos.SIM] stat: {path} {path_type}({micropython_stat_result[0]:#x})")
91
+ return micropython_stat_result
92
+
93
+
94
+ def rmdir(path):
95
+ print(f"[uos.SIM] rmdir: {path}")
96
+ if "simulator" in path and path.replace('/', '').endswith('simulator'):
97
+ print(f"\t[uos.SIM] rmdir: Invalid path! {path}")
98
+ return False
99
+ return os.rmdir(path)
100
+
101
+
102
+ def statvfs(path=None):
103
+ if path is None:
104
+ return os.statvfs(__mock_sim_dir(path))
105
+ return os.statvfs(path)
106
+
107
+
108
+ def uname():
109
+ return os.uname()
110
+
111
+
112
+ def sync():
113
+ print("[uos.SIM] sync - dummy")
114
+
115
+
116
+ def urandom(n):
117
+ print(f"[uos.SIM] sync {n}")
118
+ return os.urandom(n)
119
+
120
+
121
+ def dupterm(stream_object):
122
+ print("[uos.SIM] dupterm - dummy")
123
+
124
+
125
+ def mount(*args, **kwargs):
126
+ print("[uos.SIM] mount - dummy")
127
+
128
+
129
+ def umount(*args, **kwargs):
130
+ print("[uos.SIM] unmount - dummy")
131
+
132
+
133
+ if __name__ == "__main__":
134
+ MOCK_SIM = True
135
+ print(f"SIM root (mock: {MOCK_SIM}): {__mock_sim_dir('/')}\ngetcwd: {getcwd()}")
136
+ print(listdir("/"))
137
+ print(stat('/'))
138
+ print(ilistdir('/'))
toolkit/socketClient.py CHANGED
@@ -341,7 +341,7 @@ class SocketDictClient:
341
341
  #########################################################
342
342
 
343
343
 
344
- def main(args, host='127.0.0.1', port=9008, timeout=3, pwd=None, verbose=False):
344
+ def main(args, host='127.0.0.1', port=9008, timeout=5, pwd=None, verbose=False):
345
345
  """ main connection wrapper function """
346
346
  answer_msg = None
347
347
 
@@ -426,7 +426,7 @@ def socket_commandline_args(arg_list):
426
426
  return ' <a> '.join(command_buffer), return_action_dict
427
427
 
428
428
 
429
- def run(arg_list=[], timeout=5):
429
+ def run(arg_list=[], timeout=10):
430
430
  """ Run from code
431
431
  - Handles extra command line arguments
432
432
  """
Binary file
Binary file
Binary file
@@ -9,8 +9,8 @@ def raise_error(msgobj=None):
9
9
  """
10
10
  if msgobj is not None:
11
11
  msgobj("Raise test exception")
12
- syslog('Robustness TeSt ErRoR')
13
- raise Exception("Test exception")
12
+ state = syslog('Robustness TeSt ErRoR')
13
+ raise Exception(f"Test exception: {'OK' if state else 'NOK'}")
14
14
 
15
15
 
16
16
  @socket_stream
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1 +1 @@
1
- 1.20.0
1
+ 1.24.1
Binary file
@@ -1 +1 @@
1
- {"stapwd": "BNM3,1415", "cron": false, "crontasks": "n/a", "timirq": false, "timirqcbf": "n/a", "irq1": false, "irq1_cbf": "n/a", "irq2": true, "appwd": "ADmin123", "auth": false, "webui": true, "irq2_cbf": "basic_led toggle", "irq2_trig": "n/a", "irq3": false, "irq3_cbf": "n/a", "irq3_trig": "n/a", "irq_prell_ms": 300, "boothook": "types_demo load", "aioqueue": 5, "utc": 60, "boostmd": true, "espnow": false, "irq1_trig": "n/a", "irq4_cbf": "n/a", "guimeta": "...", "devip": "10.0.1.179", "timirqseq": 1000, "cstmpmap": "n/a", "telegram": "n/a", "dbg": true, "hwuid": "micr7c9ebd6147c4OS", "devfid": "TestBird", "staessid": "elektroncsakpozitivan_2G", "soctout": 30, "irq4_trig": "n/a", "irq4": false, "version": "2.8.1-0", "nwmd": "STA", "socport": 9008}
1
+ {"irq2": false, "irq2_cbf": "n/a", "irq3_cbf": "n/a", "timirq": true, "irq4": false, "auth": false, "irq4_cbf": "n/a", "devip": "10.0.1.129", "soctout": 100, "appwd": "ADmin123", "timirqcbf": "rgb run_transition", "timirqseq": 800, "hwuid": "micr8caab594e9d4OS", "staessid": "T-3588F3;elektroncsakpozitivan_2G", "irq1_cbf": "rgb toggle", "cron": true, "irq4_trig": "n/a", "nwmd": "STA", "boothook": "rgb load_n_init", "version": "1.41.0-0", "irq_prell_ms": 300, "crontasks": "sunrise!rgb set_transition 400 0 0 3600;sunset!rgb run_transition 143 330 0 300;*:9:0:0!rgb set_transition 0 300 300 1800;*:12:0:0!rgb toggle False;*:20:0:0!rgb set_transition 600 211 2 3600;*:21:2:0!rgb rgb 100 30 0;*:23:0:0!rgb toggle False", "aioqueue": 3, "utc": 60, "boostmd": true, "irq1_trig": "n/a", "guimeta": "...", "socport": 9008, "webui": true, "cstmpmap": "n/a", "telegram": "n/a", "irq3_trig": "n/a", "dbg": true, "irq2_trig": "n/a", "irq3": false, "devfid": "ujelet", "stapwd": "jBRU7SJmreae8n5p;BNM3,1415", "irq1": false}
Binary file
Binary file
@@ -1,126 +0,0 @@
1
- from os import listdir, remove
2
- from sys import modules
3
- from Common import socket_stream
4
-
5
- WEB_EXT = ('html', 'js', 'css')
6
-
7
- @socket_stream
8
- def listmods(msgobj=None):
9
- """
10
- Load module package manager
11
- - list all load modules
12
- """
13
- # Dump available LMs
14
- msg_buf = []
15
- for k in (res.replace('LM_', '') for res in listdir()
16
- if res.startswith('LM_') or res.split('.')[-1] in WEB_EXT):
17
- if msgobj is None:
18
- msg_buf.append(f' {k}')
19
- else:
20
- msgobj(f' {k}')
21
- return msg_buf if len(msg_buf) > 0 else ''
22
-
23
-
24
- def delmod(mod=None):
25
- """
26
- Module package manager
27
- :param mod:
28
- Delete Load Module with full name: module.py or module.mpy
29
- OR delete any web resource: *.js, *.css, *.html
30
- """
31
- if mod is not None and (mod.endswith('py') or mod.split('.')[-1] in WEB_EXT):
32
- # LM exception list - system and lmpacman cannot be deleted
33
- if 'lmpacman.' in mod or 'system.' in mod:
34
- return f'Load module {mod} is in use, skip delete.'
35
- try:
36
- to_remove = mod if mod.split('.')[-1] in WEB_EXT else f'LM_{mod}'
37
- remove(to_remove)
38
- return f'Delete module: {mod}'
39
- except Exception as e:
40
- return f'Cannot delete: {mod}: {e}'
41
- return f'Invalid value: {mod}'
42
-
43
-
44
- def del_duplicates():
45
- """
46
- Load module package manager (Not just load modules)
47
- - delete duplicated .mpy and .py resources, keep .mpy resource!
48
- """
49
- msg_buf = []
50
- py = list((res.split('.')[0] for res in listdir() if res.endswith('.py'))) # Normally smaller list
51
- mpy = (res.split('.')[0] for res in listdir() if res.endswith('.mpy'))
52
- for m in mpy:
53
- # Iterate over mpy resources
54
- state = True
55
- if m in py and m != 'main':
56
- to_delete = f'{m}.py'
57
- try:
58
- remove(to_delete)
59
- except:
60
- state = False
61
- msg_buf.append(f' Delete {to_delete} {state}')
62
- return '\n'.join(msg_buf) if len(msg_buf) > 0 else 'Nothing to delete.'
63
-
64
-
65
- def module(unload=None):
66
- """
67
- List / unload loaded upython Load Modules
68
- :param unload: module name to unload
69
- :param unload: None - list active modules
70
- :return str: verdict
71
- """
72
- if unload is None:
73
- return list(modules.keys())
74
- if unload in modules.keys():
75
- del modules[unload]
76
- return f"Module unload {unload} done."
77
- return f"Module unload {unload} failed."
78
-
79
-
80
- @socket_stream
81
- def cachedump(cdel=None, msgobj=None):
82
- """
83
- Cache system persistent data storage files (.pds)
84
- """
85
- if cdel is None:
86
- # List pds files aka application cache
87
- msg_buf = []
88
- for pds in (_pds for _pds in listdir() if _pds.endswith('.pds')):
89
- with open(pds, 'r') as f:
90
- if msgobj is None:
91
- msg_buf.append(f'{pds}: {f.read()}')
92
- else:
93
- msgobj(f'{pds}: {f.read()}')
94
- return msg_buf if len(msg_buf) > 0 else ''
95
- # Remove given pds file
96
- try:
97
- remove(f'{cdel}.pds')
98
- return f'{cdel}.pds delete done.'
99
- except:
100
- return f'{cdel}.pds not exists'
101
-
102
-
103
- @socket_stream
104
- def micros_checksum(msgobj=None):
105
- from hashlib import sha1
106
- from binascii import hexlify
107
- from Config import cfgget
108
-
109
- for f_name in (_pds for _pds in listdir() if _pds.endswith('py')):
110
- with open(f_name, 'rb') as f:
111
- cs = hexlify(sha1(f.read()).digest()).decode('utf-8')
112
- msgobj(f"{cs} {f_name}")
113
- # GC collect?
114
- return f"micrOS version: {cfgget('version')}"
115
-
116
-
117
- def help(widgets=False):
118
- """
119
- [i] micrOS LM naming convention - built-in help message
120
- :return tuple:
121
- (widgets=False) list of functions implemented by this application
122
- (widgets=True) list of widget json for UI generation
123
- """
124
- return 'listmods', 'delmod mod=<module>.py/.mpy or .js/.html/.css', 'del_duplicates',\
125
- 'module unload="LM_rgb/None"',\
126
- 'cachedump cdel="rgb.pds/None"', 'micros_checksum'