micrOSDevToolKit 2.1.5__py3-none-any.whl → 2.26.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.
Files changed (400) hide show
  1. env/driver_cp210x/.DS_Store +0 -0
  2. env/driver_cp210x/macOS_VCP_Driver/SiLabsUSBDriverDisk.dmg +0 -0
  3. env/driver_cp210x/macOS_VCP_Driver/macOS_VCP_Driver_Release_Notes.txt +17 -1
  4. micrOS/micropython/esp32-20251209-v1.27.0.bin +0 -0
  5. micrOS/micropython/esp32c3-20251209-v1.27.0.bin +0 -0
  6. micrOS/micropython/esp32c6-20251209-v1.27.0.bin +0 -0
  7. micrOS/micropython/esp32s2-20251209-v1.27.0.bin +0 -0
  8. micrOS/micropython/esp32s2-LOLIN_MINI-20251209-v1.27.0.bin +0 -0
  9. micrOS/micropython/esp32s3-4MBflash-20241129-v1.24.1.bin +0 -0
  10. micrOS/micropython/esp32s3-8MBflash-20251209-v1.27.0.bin +0 -0
  11. micrOS/micropython/esp32s3_spiram_oct-20251209-v1.27.0.bin +0 -0
  12. micrOS/micropython/rpi-pico-w-20251209-v1.27.0.uf2 +0 -0
  13. micrOS/micropython/tinypico-20251209-v1.27.0.bin +0 -0
  14. micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +191 -151
  15. micrOS/source/Auth.py +37 -0
  16. micrOS/source/Common.py +376 -102
  17. micrOS/source/Config.py +55 -25
  18. micrOS/source/Debug.py +54 -193
  19. micrOS/source/Espnow.py +404 -0
  20. micrOS/source/Files.py +207 -0
  21. micrOS/source/Hooks.py +88 -16
  22. micrOS/source/InterConnect.py +130 -46
  23. micrOS/source/Interrupts.py +8 -8
  24. micrOS/source/Logger.py +131 -0
  25. micrOS/source/Network.py +41 -21
  26. micrOS/source/Notify.py +74 -198
  27. micrOS/source/Pacman.py +326 -0
  28. micrOS/source/Scheduler.py +18 -55
  29. micrOS/source/Server.py +84 -217
  30. micrOS/source/Shell.py +103 -93
  31. micrOS/source/Tasks.py +239 -173
  32. micrOS/source/Time.py +21 -22
  33. micrOS/source/Types.py +89 -54
  34. micrOS/source/Web.py +485 -0
  35. micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
  36. micrOS/source/__pycache__/Debug.cpython-312.pyc +0 -0
  37. micrOS/source/__pycache__/Files.cpython-312.pyc +0 -0
  38. micrOS/source/__pycache__/Logger.cpython-312.pyc +0 -0
  39. micrOS/source/__pycache__/Scheduler.cpython-312.pyc +0 -0
  40. micrOS/source/__pycache__/Server.cpython-312.pyc +0 -0
  41. micrOS/source/__pycache__/Shell.cpython-312.pyc +0 -0
  42. micrOS/source/__pycache__/replhelper.cpython-312.pyc +0 -0
  43. micrOS/source/helpers.py +132 -0
  44. micrOS/source/micrOS.py +25 -21
  45. micrOS/source/micrOSloader.py +14 -23
  46. micrOS/source/microIO.py +94 -57
  47. toolkit/simulator_lib/LP_darwin.py → micrOS/source/modules/IO_esp32.py +22 -11
  48. micrOS/source/{IO_esp32c3.py → modules/IO_esp32c3.py} +6 -1
  49. micrOS/source/modules/IO_esp32c6.py +38 -0
  50. micrOS/source/{IO_esp32s2.py → modules/IO_esp32s2.py} +6 -1
  51. micrOS/source/{IO_esp32s3.py → modules/IO_esp32s3.py} +43 -2
  52. micrOS/source/modules/IO_m5stamp.py +86 -0
  53. micrOS/source/{IO_qtpy.py → modules/IO_qtpy.py} +28 -18
  54. micrOS/source/{IO_tinypico.py → modules/IO_tinypico.py} +48 -3
  55. micrOS/source/modules/LM_L298N.py +161 -0
  56. {toolkit/workspace/precompiled → micrOS/source/modules}/LM_L9110_DCmotor.py +4 -4
  57. micrOS/source/{LM_OV2640.py → modules/LM_OV2640.py} +53 -42
  58. micrOS/source/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +5 -5
  59. micrOS/source/{LM_aht10.py → modules/LM_aht10.py} +12 -4
  60. micrOS/source/{LM_bme280.py → modules/LM_bme280.py} +13 -25
  61. micrOS/source/{LM_buzzer.py → modules/LM_buzzer.py} +42 -40
  62. micrOS/source/{LM_cct.py → modules/LM_cct.py} +22 -27
  63. micrOS/source/modules/LM_cluster.py +255 -0
  64. micrOS/source/{LM_co2.py → modules/LM_co2.py} +13 -6
  65. micrOS/source/{LM_dht11.py → modules/LM_dht11.py} +13 -29
  66. micrOS/source/{LM_dht22.py → modules/LM_dht22.py} +13 -28
  67. micrOS/source/{LM_dimmer.py → modules/LM_dimmer.py} +19 -16
  68. micrOS/source/modules/LM_distance.py +135 -0
  69. micrOS/source/{LM_ds18.py → modules/LM_ds18.py} +12 -4
  70. micrOS/source/{LM_esp32.py → modules/LM_esp32.py} +16 -4
  71. micrOS/source/modules/LM_espnow.py +53 -0
  72. micrOS/source/modules/LM_fileserver.py +265 -0
  73. micrOS/source/{LM_gameOfLife.py → modules/LM_gameOfLife.py} +5 -5
  74. micrOS/source/{LM_genIO.py → modules/LM_genIO.py} +49 -35
  75. micrOS/source/modules/LM_haptic.py +111 -0
  76. micrOS/source/modules/LM_i2c.py +61 -0
  77. micrOS/source/{LM_i2s_mic.py → modules/LM_i2s_mic.py} +20 -23
  78. micrOS/source/{LM_ld2410.py → modules/LM_ld2410.py} +3 -3
  79. micrOS/source/{LM_light_sensor.py → modules/LM_light_sensor.py} +22 -26
  80. micrOS/source/modules/LM_mh_z19c.py +198 -0
  81. micrOS/source/modules/LM_neoeffects.py +284 -0
  82. micrOS/source/{LM_neopixel.py → modules/LM_neopixel.py} +26 -31
  83. micrOS/source/{LM_oled.py → modules/LM_oled.py} +28 -20
  84. micrOS/source/{LM_oled_sh1106.py → modules/LM_oled_sh1106.py} +28 -24
  85. micrOS/source/{LM_oled_ui.py → modules/LM_oled_ui.py} +132 -174
  86. micrOS/source/modules/LM_pacman.py +320 -0
  87. micrOS/source/{LM_presence.py → modules/LM_presence.py} +24 -36
  88. micrOS/source/modules/LM_qmi8658.py +204 -0
  89. micrOS/source/{LM_rencoder.py → modules/LM_rencoder.py} +40 -11
  90. micrOS/source/modules/LM_rest.py +81 -0
  91. micrOS/source/{LM_rgb.py → modules/LM_rgb.py} +25 -34
  92. micrOS/source/{LM_rgbcct.py → modules/LM_rgbcct.py} +5 -5
  93. micrOS/source/{LM_roboarm.py → modules/LM_roboarm.py} +37 -45
  94. micrOS/source/modules/LM_robustness.py +137 -0
  95. micrOS/source/{LM_rp2w.py → modules/LM_rp2w.py} +3 -0
  96. micrOS/source/{LM_sdcard.py → modules/LM_sdcard.py} +3 -0
  97. micrOS/source/{LM_servo.py → modules/LM_servo.py} +4 -4
  98. micrOS/source/modules/LM_sound_event.py +751 -0
  99. micrOS/source/{LM_stepper.py → modules/LM_stepper.py} +8 -8
  100. micrOS/source/{LM_switch.py → modules/LM_switch.py} +21 -18
  101. micrOS/source/{LM_system.py → modules/LM_system.py} +96 -59
  102. micrOS/source/modules/LM_tcs3472.py +187 -0
  103. micrOS/source/modules/LM_telegram.py +388 -0
  104. micrOS/source/modules/LM_trackball.py +287 -0
  105. micrOS/source/modules/LM_veml7700.py +159 -0
  106. micrOS/source/modules/LM_web.py +38 -0
  107. micrOS/source/urequests.py +204 -91
  108. {toolkit/workspace/precompiled → micrOS/source/web}/dashboard.html +9 -4
  109. micrOS/source/web/editor.js +440 -0
  110. micrOS/source/web/filesui.html +178 -0
  111. micrOS/source/web/filesui.js +338 -0
  112. micrOS/source/{index.html → web/index.html} +44 -2
  113. micrOS/source/web/uapi.js +103 -0
  114. micrOS/source/web/udashboard.js +129 -0
  115. micrOS/source/web/ustyle.css +55 -0
  116. micrOS/source/web/uwidgets.js +172 -0
  117. micrOS/source/web/uwidgets_pro.js +99 -0
  118. micrOS/utests/__init__.py +0 -0
  119. micrOS/utests/test_scheduler.py +435 -0
  120. {micrOSDevToolKit-2.1.5.data → microsdevtoolkit-2.26.1.data}/scripts/devToolKit.py +47 -4
  121. {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/METADATA +392 -279
  122. microsdevtoolkit-2.26.1.dist-info/RECORD +396 -0
  123. {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/WHEEL +1 -1
  124. toolkit/DevEnvCompile.py +63 -33
  125. toolkit/DevEnvOTA.py +72 -22
  126. toolkit/DevEnvUSB.py +147 -77
  127. toolkit/Gateway.py +9 -9
  128. toolkit/LM_to_compile.dat +12 -4
  129. toolkit/MicrOSDevEnv.py +129 -51
  130. toolkit/WebRepl.py +73 -0
  131. toolkit/dashboard_apps/BackupRestore.py +171 -0
  132. toolkit/dashboard_apps/CCTDemo.py +12 -17
  133. toolkit/dashboard_apps/CCTTest.py +20 -24
  134. toolkit/dashboard_apps/CamStream.py +2 -6
  135. toolkit/dashboard_apps/CatGame.py +14 -16
  136. toolkit/dashboard_apps/Dimmer.py +11 -21
  137. toolkit/dashboard_apps/GetVersion.py +11 -19
  138. toolkit/dashboard_apps/MicrophoneTest.py +2 -7
  139. toolkit/dashboard_apps/NeoEffectsDemo.py +22 -35
  140. toolkit/dashboard_apps/NeopixelTest.py +20 -25
  141. toolkit/dashboard_apps/PresenceTest.py +2 -8
  142. toolkit/dashboard_apps/QMI8685_GYRO.py +68 -0
  143. toolkit/dashboard_apps/RGBTest.py +20 -24
  144. toolkit/dashboard_apps/RoboArm.py +24 -32
  145. toolkit/dashboard_apps/SED_test.py +10 -14
  146. toolkit/dashboard_apps/SensorsTest.py +61 -0
  147. toolkit/dashboard_apps/SystemTest.py +219 -117
  148. toolkit/dashboard_apps/Template_app.py +12 -19
  149. toolkit/dashboard_apps/_app_base.py +34 -0
  150. toolkit/dashboard_apps/_gyro_visualizer.py +78 -0
  151. toolkit/dashboard_apps/uLightDemo.py +15 -24
  152. toolkit/index.html +6 -5
  153. toolkit/lib/LocalMachine.py +6 -1
  154. toolkit/lib/MicrosFiles.py +46 -0
  155. toolkit/lib/Repository.py +64 -0
  156. toolkit/lib/TerminalColors.py +4 -0
  157. toolkit/lib/macroScript.py +371 -0
  158. toolkit/lib/micrOSClient.py +124 -51
  159. toolkit/lib/micrOSClientHistory.py +156 -0
  160. toolkit/lib/pip_package_installer.py +31 -4
  161. toolkit/micrOSdashboard.py +16 -21
  162. toolkit/micrOSlint.py +28 -10
  163. toolkit/simulator_lib/.DS_Store +0 -0
  164. micrOS/source/IO_esp32.py → toolkit/simulator_lib/IO_darwin.py +3 -0
  165. toolkit/simulator_lib/__pycache__/IO_darwin.cpython-312.pyc +0 -0
  166. toolkit/simulator_lib/__pycache__/aioespnow.cpython-312.pyc +0 -0
  167. toolkit/simulator_lib/__pycache__/camera.cpython-312.pyc +0 -0
  168. toolkit/simulator_lib/__pycache__/framebuf.cpython-312.pyc +0 -0
  169. toolkit/simulator_lib/__pycache__/machine.cpython-312.pyc +0 -0
  170. toolkit/simulator_lib/__pycache__/micropython.cpython-312.pyc +0 -0
  171. toolkit/simulator_lib/__pycache__/mip.cpython-312.pyc +0 -0
  172. toolkit/simulator_lib/__pycache__/neopixel.cpython-312.pyc +0 -0
  173. toolkit/simulator_lib/__pycache__/network.cpython-312.pyc +0 -0
  174. toolkit/simulator_lib/__pycache__/sim_common.cpython-312.pyc +0 -0
  175. toolkit/simulator_lib/__pycache__/simgc.cpython-312.pyc +0 -0
  176. toolkit/simulator_lib/__pycache__/simulator.cpython-312.pyc +0 -0
  177. toolkit/simulator_lib/__pycache__/uasyncio.cpython-312.pyc +0 -0
  178. toolkit/simulator_lib/__pycache__/uos.cpython-312.pyc +0 -0
  179. toolkit/simulator_lib/__pycache__/urandom.cpython-312.pyc +0 -0
  180. toolkit/simulator_lib/__pycache__/usocket.cpython-312.pyc +0 -0
  181. toolkit/simulator_lib/__pycache__/ussl.cpython-312.pyc +0 -0
  182. toolkit/simulator_lib/aioespnow.py +28 -0
  183. toolkit/simulator_lib/camera.py +84 -0
  184. toolkit/simulator_lib/dht.py +1 -1
  185. toolkit/simulator_lib/framebuf.py +49 -1
  186. toolkit/simulator_lib/machine.py +32 -2
  187. toolkit/simulator_lib/micropython.py +3 -3
  188. toolkit/simulator_lib/mip.py +165 -0
  189. toolkit/simulator_lib/neopixel.py +3 -2
  190. toolkit/simulator_lib/network.py +2 -1
  191. toolkit/simulator_lib/node_config.json +2 -3
  192. toolkit/simulator_lib/ntptime.py +1 -1
  193. toolkit/simulator_lib/{sim_console.py → sim_common.py} +2 -3
  194. toolkit/simulator_lib/simgc.py +6 -2
  195. toolkit/simulator_lib/simulator.py +138 -46
  196. toolkit/simulator_lib/uasyncio.py +34 -3
  197. toolkit/simulator_lib/uos.py +147 -0
  198. toolkit/simulator_lib/urandom.py +4 -0
  199. toolkit/simulator_lib/usocket.py +5 -1
  200. toolkit/simulator_lib/view01.jpg +0 -0
  201. toolkit/simulator_lib/view02.jpg +0 -0
  202. toolkit/socketClient.py +43 -23
  203. toolkit/user_data/webhooks/generic.py +1 -1
  204. toolkit/user_data/webhooks/macro.py +44 -0
  205. toolkit/user_data/webhooks/template.macro +20 -0
  206. toolkit/user_data/webhooks/template.py +1 -1
  207. toolkit/workspace/precompiled/Auth.mpy +0 -0
  208. toolkit/workspace/precompiled/Common.mpy +0 -0
  209. toolkit/workspace/precompiled/Config.mpy +0 -0
  210. toolkit/workspace/precompiled/Debug.mpy +0 -0
  211. toolkit/workspace/precompiled/Espnow.mpy +0 -0
  212. toolkit/workspace/precompiled/Files.mpy +0 -0
  213. toolkit/workspace/precompiled/Hooks.mpy +0 -0
  214. toolkit/workspace/precompiled/InterConnect.mpy +0 -0
  215. toolkit/workspace/precompiled/Interrupts.mpy +0 -0
  216. toolkit/workspace/precompiled/Logger.mpy +0 -0
  217. toolkit/workspace/precompiled/Network.mpy +0 -0
  218. toolkit/workspace/precompiled/Notify.mpy +0 -0
  219. toolkit/workspace/precompiled/Pacman.mpy +0 -0
  220. toolkit/workspace/precompiled/Scheduler.mpy +0 -0
  221. toolkit/workspace/precompiled/Server.mpy +0 -0
  222. toolkit/workspace/precompiled/Shell.mpy +0 -0
  223. toolkit/workspace/precompiled/Tasks.mpy +0 -0
  224. toolkit/workspace/precompiled/Time.mpy +0 -0
  225. toolkit/workspace/precompiled/Types.mpy +0 -0
  226. toolkit/workspace/precompiled/Web.mpy +0 -0
  227. toolkit/workspace/precompiled/_mpy.version +1 -1
  228. toolkit/workspace/precompiled/config/_git.keep +0 -0
  229. toolkit/workspace/precompiled/helpers.mpy +0 -0
  230. toolkit/workspace/precompiled/micrOS.mpy +0 -0
  231. toolkit/workspace/precompiled/micrOSloader.mpy +0 -0
  232. toolkit/workspace/precompiled/microIO.mpy +0 -0
  233. toolkit/workspace/precompiled/modules/IO_esp32.mpy +0 -0
  234. toolkit/workspace/precompiled/modules/IO_esp32c3.mpy +0 -0
  235. toolkit/workspace/precompiled/modules/IO_esp32c6.mpy +0 -0
  236. toolkit/workspace/precompiled/modules/IO_esp32s2.mpy +0 -0
  237. toolkit/workspace/precompiled/modules/IO_esp32s3.mpy +0 -0
  238. toolkit/workspace/precompiled/modules/IO_m5stamp.mpy +0 -0
  239. toolkit/workspace/precompiled/modules/IO_qtpy.mpy +0 -0
  240. toolkit/workspace/precompiled/modules/IO_rp2.mpy +0 -0
  241. toolkit/workspace/precompiled/modules/IO_tinypico.mpy +0 -0
  242. toolkit/workspace/precompiled/modules/LM_L298N.mpy +0 -0
  243. {micrOS/source → toolkit/workspace/precompiled/modules}/LM_L9110_DCmotor.py +4 -4
  244. toolkit/workspace/precompiled/modules/LM_OV2640.mpy +0 -0
  245. toolkit/workspace/precompiled/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +5 -5
  246. toolkit/workspace/precompiled/modules/LM_aht10.mpy +0 -0
  247. toolkit/workspace/precompiled/modules/LM_bme280.mpy +0 -0
  248. toolkit/workspace/precompiled/{LM_buzzer.mpy → modules/LM_buzzer.mpy} +0 -0
  249. toolkit/workspace/precompiled/modules/LM_cct.mpy +0 -0
  250. toolkit/workspace/precompiled/modules/LM_cluster.mpy +0 -0
  251. toolkit/workspace/precompiled/modules/LM_co2.mpy +0 -0
  252. toolkit/workspace/precompiled/modules/LM_dht11.mpy +0 -0
  253. toolkit/workspace/precompiled/modules/LM_dht22.mpy +0 -0
  254. toolkit/workspace/precompiled/modules/LM_dimmer.mpy +0 -0
  255. toolkit/workspace/precompiled/modules/LM_distance.mpy +0 -0
  256. toolkit/workspace/precompiled/modules/LM_ds18.mpy +0 -0
  257. toolkit/workspace/precompiled/{LM_esp32.py → modules/LM_esp32.py} +16 -4
  258. toolkit/workspace/precompiled/modules/LM_espnow.py +53 -0
  259. toolkit/workspace/precompiled/modules/LM_fileserver.mpy +0 -0
  260. toolkit/workspace/precompiled/{LM_gameOfLife.mpy → modules/LM_gameOfLife.mpy} +0 -0
  261. toolkit/workspace/precompiled/modules/LM_genIO.mpy +0 -0
  262. toolkit/workspace/precompiled/modules/LM_haptic.mpy +0 -0
  263. toolkit/workspace/precompiled/modules/LM_i2c.py +61 -0
  264. toolkit/workspace/precompiled/modules/LM_i2s_mic.mpy +0 -0
  265. toolkit/workspace/precompiled/{LM_ld2410.mpy → modules/LM_ld2410.mpy} +0 -0
  266. toolkit/workspace/precompiled/modules/LM_light_sensor.mpy +0 -0
  267. toolkit/workspace/precompiled/modules/LM_mh_z19c.py +198 -0
  268. toolkit/workspace/precompiled/modules/LM_neoeffects.mpy +0 -0
  269. toolkit/workspace/precompiled/modules/LM_neopixel.mpy +0 -0
  270. toolkit/workspace/precompiled/modules/LM_oled.mpy +0 -0
  271. toolkit/workspace/precompiled/modules/LM_oled_sh1106.mpy +0 -0
  272. toolkit/workspace/precompiled/modules/LM_oled_ui.mpy +0 -0
  273. toolkit/workspace/precompiled/modules/LM_pacman.mpy +0 -0
  274. toolkit/workspace/precompiled/modules/LM_presence.mpy +0 -0
  275. toolkit/workspace/precompiled/modules/LM_qmi8658.py +204 -0
  276. toolkit/workspace/precompiled/{LM_rencoder.py → modules/LM_rencoder.py} +40 -11
  277. toolkit/workspace/precompiled/modules/LM_rest.mpy +0 -0
  278. toolkit/workspace/precompiled/modules/LM_rgb.mpy +0 -0
  279. toolkit/workspace/precompiled/{LM_rgbcct.mpy → modules/LM_rgbcct.mpy} +0 -0
  280. toolkit/workspace/precompiled/modules/LM_roboarm.mpy +0 -0
  281. toolkit/workspace/precompiled/modules/LM_robustness.py +137 -0
  282. toolkit/workspace/precompiled/{LM_rp2w.py → modules/LM_rp2w.py} +3 -0
  283. toolkit/workspace/precompiled/{LM_sdcard.py → modules/LM_sdcard.py} +3 -0
  284. toolkit/workspace/precompiled/{LM_servo.mpy → modules/LM_servo.mpy} +0 -0
  285. toolkit/workspace/precompiled/modules/LM_sound_event.mpy +0 -0
  286. toolkit/workspace/precompiled/{LM_stepper.mpy → modules/LM_stepper.mpy} +0 -0
  287. toolkit/workspace/precompiled/modules/LM_switch.mpy +0 -0
  288. toolkit/workspace/precompiled/modules/LM_system.mpy +0 -0
  289. toolkit/workspace/precompiled/modules/LM_tcs3472.py +187 -0
  290. toolkit/workspace/precompiled/modules/LM_telegram.mpy +0 -0
  291. toolkit/workspace/precompiled/{LM_tinyrgb.mpy → modules/LM_tinyrgb.mpy} +0 -0
  292. toolkit/workspace/precompiled/modules/LM_trackball.mpy +0 -0
  293. toolkit/workspace/precompiled/modules/LM_veml7700.mpy +0 -0
  294. toolkit/workspace/precompiled/modules/LM_web.mpy +0 -0
  295. toolkit/workspace/precompiled/urequests.mpy +0 -0
  296. {micrOS/source → toolkit/workspace/precompiled/web}/dashboard.html +9 -4
  297. toolkit/workspace/precompiled/web/editor.js +440 -0
  298. toolkit/workspace/precompiled/web/filesui.html +178 -0
  299. toolkit/workspace/precompiled/web/filesui.js +338 -0
  300. toolkit/workspace/precompiled/{index.html → web/index.html} +44 -2
  301. toolkit/workspace/precompiled/web/uapi.js +103 -0
  302. toolkit/workspace/precompiled/web/udashboard.js +129 -0
  303. toolkit/workspace/precompiled/web/ustyle.css +55 -0
  304. toolkit/workspace/precompiled/web/uwidgets.js +172 -0
  305. toolkit/workspace/precompiled/web/uwidgets_pro.js +99 -0
  306. env/driver_cp210x/CH34XSER_MAC/CH34X_DRV_INSTALL_INSTRUCTIONS.pdf +0 -0
  307. env/driver_cp210x/CH34XSER_MAC/CH34xVCPDriver.pkg +0 -0
  308. micrOS/micropython/esp32-20231005-v1.21.0.bin +0 -0
  309. micrOS/micropython/esp32c3-GENERIC-20240105-v1.22.1.bin +0 -0
  310. micrOS/micropython/esp32c3-GENERIC-20240222-v1.22.2.bin +0 -0
  311. micrOS/micropython/esp32s2-GENERIC-20240105-v1.22.1.bin +0 -0
  312. micrOS/micropython/esp32s2-LOLIN_MINI-20220618-v1.19.1.bin +0 -0
  313. micrOS/micropython/esp32s3-GENERIC-20240105-v1.22.1.bin +0 -0
  314. micrOS/micropython/esp32s3_spiram_oct-20231005-v1.21.0.bin +0 -0
  315. micrOS/micropython/rpi-pico-w-20231005-v1.21.0.uf2 +0 -0
  316. micrOS/micropython/tinypico-20231005-v1.21.0.bin +0 -0
  317. micrOS/micropython/tinypico-usbc-UM-20240105-v1.22.1.bin +0 -0
  318. micrOS/source/LM_L298N_DCmotor.py +0 -86
  319. micrOS/source/LM_catgame.py +0 -74
  320. micrOS/source/LM_dashboard_be.py +0 -37
  321. micrOS/source/LM_demo.py +0 -85
  322. micrOS/source/LM_distance.py +0 -88
  323. micrOS/source/LM_i2c.py +0 -44
  324. micrOS/source/LM_intercon.py +0 -57
  325. micrOS/source/LM_keychain.py +0 -318
  326. micrOS/source/LM_lmpacman.py +0 -126
  327. micrOS/source/LM_neoeffects.py +0 -327
  328. micrOS/source/LM_pet_feeder.py +0 -76
  329. micrOS/source/LM_ph_sensor.py +0 -51
  330. micrOS/source/LM_rest.py +0 -40
  331. micrOS/source/LM_robustness.py +0 -73
  332. micrOS/source/LM_telegram.py +0 -96
  333. micrOS/source/reset.py +0 -11
  334. micrOS/source/uapi.js +0 -76
  335. micrOS/source/udashboard.js +0 -137
  336. micrOS/source/ustyle.css +0 -28
  337. micrOS/source/uwidgets.js +0 -179
  338. micrOSDevToolKit-2.1.5.dist-info/RECORD +0 -337
  339. toolkit/dashboard_apps/AirQualityBME280.py +0 -36
  340. toolkit/dashboard_apps/AirQualityDHT22_CO2.py +0 -36
  341. toolkit/lib/file_extensions.py +0 -16
  342. toolkit/simulator_lib/__pycache__/LP_darwin.cpython-312.pyc +0 -0
  343. toolkit/simulator_lib/__pycache__/LP_darwin.cpython-38.pyc +0 -0
  344. toolkit/simulator_lib/__pycache__/LP_darwin.cpython-39.pyc +0 -0
  345. toolkit/simulator_lib/__pycache__/sim_console.cpython-312.pyc +0 -0
  346. toolkit/simulator_lib/__pycache__/sim_console.cpython-38.pyc +0 -0
  347. toolkit/simulator_lib/__pycache__/sim_console.cpython-39.pyc +0 -0
  348. toolkit/workspace/precompiled/IO_esp32.mpy +0 -0
  349. toolkit/workspace/precompiled/IO_esp32c3.mpy +0 -0
  350. toolkit/workspace/precompiled/IO_esp32s2.mpy +0 -0
  351. toolkit/workspace/precompiled/IO_esp32s3.mpy +0 -0
  352. toolkit/workspace/precompiled/IO_qtpy.mpy +0 -0
  353. toolkit/workspace/precompiled/IO_rp2.mpy +0 -0
  354. toolkit/workspace/precompiled/IO_tinypico.mpy +0 -0
  355. toolkit/workspace/precompiled/LM_L298N_DCmotor.mpy +0 -0
  356. toolkit/workspace/precompiled/LM_OV2640.mpy +0 -0
  357. toolkit/workspace/precompiled/LM_aht10.mpy +0 -0
  358. toolkit/workspace/precompiled/LM_bme280.mpy +0 -0
  359. toolkit/workspace/precompiled/LM_catgame.py +0 -74
  360. toolkit/workspace/precompiled/LM_cct.mpy +0 -0
  361. toolkit/workspace/precompiled/LM_co2.mpy +0 -0
  362. toolkit/workspace/precompiled/LM_dashboard_be.py +0 -37
  363. toolkit/workspace/precompiled/LM_demo.py +0 -85
  364. toolkit/workspace/precompiled/LM_dht11.mpy +0 -0
  365. toolkit/workspace/precompiled/LM_dht22.mpy +0 -0
  366. toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
  367. toolkit/workspace/precompiled/LM_distance.py +0 -88
  368. toolkit/workspace/precompiled/LM_ds18.mpy +0 -0
  369. toolkit/workspace/precompiled/LM_genIO.mpy +0 -0
  370. toolkit/workspace/precompiled/LM_i2c.py +0 -44
  371. toolkit/workspace/precompiled/LM_i2s_mic.mpy +0 -0
  372. toolkit/workspace/precompiled/LM_intercon.mpy +0 -0
  373. toolkit/workspace/precompiled/LM_keychain.mpy +0 -0
  374. toolkit/workspace/precompiled/LM_light_sensor.mpy +0 -0
  375. toolkit/workspace/precompiled/LM_lmpacman.mpy +0 -0
  376. toolkit/workspace/precompiled/LM_neoeffects.mpy +0 -0
  377. toolkit/workspace/precompiled/LM_neopixel.mpy +0 -0
  378. toolkit/workspace/precompiled/LM_oled.mpy +0 -0
  379. toolkit/workspace/precompiled/LM_oled_sh1106.mpy +0 -0
  380. toolkit/workspace/precompiled/LM_oled_ui.mpy +0 -0
  381. toolkit/workspace/precompiled/LM_pet_feeder.py +0 -76
  382. toolkit/workspace/precompiled/LM_ph_sensor.py +0 -51
  383. toolkit/workspace/precompiled/LM_presence.mpy +0 -0
  384. toolkit/workspace/precompiled/LM_rest.mpy +0 -0
  385. toolkit/workspace/precompiled/LM_rgb.mpy +0 -0
  386. toolkit/workspace/precompiled/LM_roboarm.mpy +0 -0
  387. toolkit/workspace/precompiled/LM_robustness.py +0 -73
  388. toolkit/workspace/precompiled/LM_switch.mpy +0 -0
  389. toolkit/workspace/precompiled/LM_system.mpy +0 -0
  390. toolkit/workspace/precompiled/LM_telegram.mpy +0 -0
  391. toolkit/workspace/precompiled/reset.mpy +0 -0
  392. toolkit/workspace/precompiled/uapi.js +0 -76
  393. toolkit/workspace/precompiled/udashboard.js +0 -137
  394. toolkit/workspace/precompiled/ustyle.css +0 -28
  395. toolkit/workspace/precompiled/uwidgets.js +0 -179
  396. /toolkit/user_data/node_config_archive/.include → /micrOS/source/config/_git.keep +0 -0
  397. /micrOS/source/{IO_rp2.py → modules/IO_rp2.py} +0 -0
  398. /micrOS/source/{LM_tinyrgb.py → modules/LM_tinyrgb.py} +0 -0
  399. {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info/licenses}/LICENSE +0 -0
  400. {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/top_level.txt +0 -0
micrOS/source/Config.py CHANGED
@@ -12,20 +12,28 @@ Designed by Marcell Ban aka BxNxM
12
12
  #################################################################
13
13
  # IMPORTS #
14
14
  #################################################################
15
- from os import remove
15
+ from re import search
16
16
  from json import load, dump
17
+ from uos import remove
17
18
  from utime import sleep
18
- from Debug import DebugCfg, console_write, errlog_add
19
+ from Debug import DebugCfg, console_write, syslog
20
+ from Files import OSPath, path_join, is_file
21
+ from uos import rename as move_file
19
22
  try:
20
23
  from microIO import set_pinmap
21
24
  except:
22
- errlog_add("[ERR] LogicalPins import: set_pinmap")
25
+ syslog("[ERR] microIO import: set_pinmap")
23
26
  set_pinmap = None
24
27
 
25
28
 
26
29
  class Data:
27
- # micrOS config path
28
- CONFIG_PATH = "node_config.json"
30
+ """
31
+ Data class for managing configuration data.
32
+ """
33
+ __slots__ = []
34
+
35
+ CONFIG_NAME = "node_config.json"
36
+ CONFIG_PATH = path_join(OSPath.CONFIG, CONFIG_NAME)
29
37
  CONFIG_CACHE = {"version": "n/a",
30
38
  "auth": False,
31
39
  "staessid": "your_wifi_name",
@@ -58,21 +66,28 @@ class Data:
58
66
  "irq4_trig": "n/a",
59
67
  "irq_prell_ms": 300,
60
68
  "boothook": "n/a",
61
- "aioqueue": 4,
69
+ "aioqueue": 5,
62
70
  "utc": +60,
63
71
  "boostmd": True,
64
- "guimeta": "...", # special "offloaded" key indicator
72
+ "guimeta": "...", # special "offloaded" key indicator
65
73
  "cstmpmap": "n/a",
66
- "telegram": "n/a"} # telegram bot token
74
+ "espnow": False}
67
75
 
68
76
  @staticmethod
69
77
  def init():
78
+ # Migrate config from / to /config
79
+ if is_file(Data.CONFIG_NAME):
80
+ console_write(f"[CONF] Migrate {Data.CONFIG_NAME} to {Data.CONFIG_PATH}")
81
+ move_file(Data.CONFIG_NAME, Data.CONFIG_PATH)
70
82
  # Inject user config into template
71
83
  Data.__inject_default_conf()
72
84
  # [!!!] Init selected pinmap - default pinmap calculated by platform
73
- if set_pinmap is not None:
74
- pinmap = set_pinmap(Data.CONFIG_CACHE['cstmpmap'])
75
- console_write(f"[PIN MAP] {pinmap}")
85
+ if callable(set_pinmap):
86
+ try:
87
+ pinmap = set_pinmap(Data.CONFIG_CACHE['cstmpmap'])
88
+ console_write(f"[PIN MAP] {pinmap}")
89
+ except Exception as e:
90
+ console_write(f"\n[PIN MAP] !!! SETUP ERROR !!!: {e}\n")
76
91
  # SET dbg based on config settings (inject user conf)
77
92
  DebugCfg.DEBUG = Data.CONFIG_CACHE['dbg']
78
93
  if DebugCfg.DEBUG:
@@ -89,12 +104,12 @@ class Data:
89
104
  liveconf = Data.read_cfg_file(nosafe=True)
90
105
  # Remove obsolete keys from conf
91
106
  try:
92
- remove('cleanup.pds') # Try to remove cleanup.pds (cleanup indicator by micrOSloader)
107
+ remove('.cleanup') # Try to remove .cleanup (cleanup indicator by micrOSloader)
93
108
  console_write("[CONF] Purge obsolete keys")
94
109
  for key in (key for key in liveconf if key not in Data.CONFIG_CACHE):
95
110
  liveconf.pop(key, None)
96
111
  except Exception:
97
- console_write("[CONF] SKIP obsolete keys check (no cleanup.pds)")
112
+ console_write("[CONF] SKIP obsolete keys check (no .cleanup)")
98
113
  # Merge template to live conf (store active conf in Data.CONFIG_CACHE)
99
114
  Data.CONFIG_CACHE.update(liveconf)
100
115
  console_write("[CONF] User config injection done")
@@ -103,7 +118,7 @@ class Data:
103
118
  Data.write_cfg_file()
104
119
  console_write("[CONF] Save conf successful")
105
120
  except Exception as e:
106
- errlog_add(f"[ERR] Save (__inject) conf failed: {e}")
121
+ syslog(f"[ERR] Save (__inject) conf failed: {e}")
107
122
  finally:
108
123
  del liveconf
109
124
 
@@ -121,7 +136,7 @@ class Data:
121
136
  if nosafe:
122
137
  break
123
138
  sleep(0.2)
124
- errlog_add(f'[ERR] read_cfg_file error: {e}')
139
+ syslog(f'[ERR] read_cfg_file error: {e}')
125
140
  # Return config cache
126
141
  return conf
127
142
 
@@ -134,7 +149,7 @@ class Data:
134
149
  dump(Data.CONFIG_CACHE, f)
135
150
  break
136
151
  except Exception as e:
137
- errlog_add(f'[ERR] write_cfg_file {Data.CONFIG_PATH} (json): {e}')
152
+ syslog(f'[ERR] write_cfg_file {Data.CONFIG_PATH} (json): {e}')
138
153
  sleep(0.2)
139
154
  return True
140
155
 
@@ -143,20 +158,16 @@ class Data:
143
158
  value_in_cfg = Data.CONFIG_CACHE[key]
144
159
  try:
145
160
  if isinstance(value_in_cfg, bool):
146
- del value_in_cfg
147
161
  if str(value).lower() == 'true':
148
162
  return True
149
163
  if str(value).lower() == 'false':
150
164
  return False
151
165
  raise Exception("type_handler type handling error")
152
166
  if isinstance(value_in_cfg, str):
153
- del value_in_cfg
154
167
  return str(value)
155
168
  if isinstance(value_in_cfg, int):
156
- del value_in_cfg
157
169
  return int(value)
158
170
  if isinstance(value_in_cfg, float):
159
- del value_in_cfg
160
171
  return float(value)
161
172
  except Exception as e:
162
173
  console_write(f"Input value type error! {e}")
@@ -169,21 +180,37 @@ class Data:
169
180
  These kind of parameters are not cached in memory
170
181
  """
171
182
  # Write str value to file
183
+ offloaded_key = path_join(OSPath.CONFIG, f'.{key}.key')
172
184
  if isinstance(value, str) and key in Data.CONFIG_CACHE:
173
185
  try:
174
- with open(f'.{key}.key', 'w') as f:
186
+ with open(offloaded_key, 'w') as f:
175
187
  f.write(value)
176
188
  return True
177
189
  except Exception:
178
190
  return False
179
191
  # Read str value from file
180
192
  try:
181
- with open(f'.{key}.key', 'r') as f:
193
+ with open(offloaded_key, 'r') as f:
182
194
  return f.read().strip()
183
195
  except Exception:
184
196
  # Return default value if key not exists
185
197
  return 'n/a'
186
198
 
199
+ @staticmethod
200
+ def validate_pwd(password):
201
+ """
202
+ Validate appwd parameter
203
+ - webrepl password
204
+ - micrOS auth password (Shell/WebCli)
205
+ - wifi access point password
206
+ """
207
+ # Check password rules
208
+ if 4 <= len(password) <= 9:
209
+ if search(r"[A-Z]", password) and search(r"[a-z]", password):
210
+ if search(r"\d", password):
211
+ return True, ''
212
+ return False, 'Password must include [0-9] both [a-z][A-Z] and length between 4-9 char.'
213
+
187
214
 
188
215
  #################################################################
189
216
  # CONFIGHANDLER FUNCTIONS #
@@ -200,11 +227,14 @@ def cfgget(key=None):
200
227
  return Data.disk_keys(key)
201
228
  return val
202
229
  except Exception as e:
203
- errlog_add(f'[ERR] cfgget {key} error: {e}')
230
+ syslog(f'[ERR] cfgget {key} error: {e}')
204
231
  return None
205
232
 
206
-
207
233
  def cfgput(key, value, type_check=False):
234
+ if key == 'appwd':
235
+ is_valid, verdict = Data.validate_pwd(value)
236
+ if not is_valid:
237
+ raise Exception(verdict)
208
238
  # Handle special "offloaded" keys
209
239
  if str(Data.CONFIG_CACHE.get(key, None)) == '...':
210
240
  return Data.disk_keys(key, value)
@@ -222,7 +252,7 @@ def cfgput(key, value, type_check=False):
222
252
  del value
223
253
  return True
224
254
  except Exception as e:
225
- errlog_add(f'[ERR] cfgput {key} error: {e}')
255
+ syslog(f'[ERR] cfgput {key} error: {e}')
226
256
  return False
227
257
 
228
258
  #################################################################
micrOS/source/Debug.py CHANGED
@@ -1,11 +1,18 @@
1
- import os
2
- from time import localtime
3
- from machine import Pin
1
+ """
2
+ micrOS Console and Log write interface implementations.
3
+ - with progress led feature, simple and custom
4
+ Designed by Marcell Ban aka BxNxM
5
+ """
4
6
 
7
+ from machine import Pin
8
+ try:
9
+ from Logger import syslog as logger_syslog
10
+ except:
11
+ logger_syslog = None
5
12
  try:
6
- from microIO import physical_pin, pinmap_dump, detect_platform
13
+ from microIO import resolve_pin, pinmap_search, register_pin
7
14
  except:
8
- detect_platform = None
15
+ pinmap_search = None
9
16
 
10
17
 
11
18
  #############################################
@@ -16,109 +23,60 @@ except:
16
23
  class DebugCfg:
17
24
  DEBUG = True # DEBUG PRINT ON/OFF - SET FROM ConfigHandler
18
25
  PLED_STEP = None # PROGRESS LED OBJECT - init in init_pled
19
- NEO_WHEEL = None # NEOPIXEL (ws2812/esp32s3) color wheel object
20
- COLOR_INDEX = 0 # APA102 TinyPico color wheel counter
21
26
 
22
27
  @staticmethod
23
28
  def init_pled():
24
29
  # CALL FROM ConfigHandler
25
- if detect_platform is None:
30
+ if pinmap_search is None:
26
31
  # Check LogicalPins module loadable (robustness...)
27
32
  return
28
- micro_platform = detect_platform()
29
- pled = pinmap_dump('builtin')['builtin']
30
- if micro_platform == "tinypico":
31
- # Progress led for TinyPico
32
- DebugCfg._init_apa102()
33
- elif pled is not None:
34
- if isinstance(pled, int):
35
- # SET PROGRESS LED WITH BUILT-IN step FUNCTION
36
- if micro_platform == "esp32s3":
37
- # Progress led for esp32s3
38
- DebugCfg._init_ws2812()
39
- else:
40
- # Progress led for esp32/etc
41
- DebugCfg._init_simple()
42
- else:
43
- # OVERRIDE PROGRESS LED WITH CUSTOM step FUNCTION
44
- DebugCfg.PLED_STEP = pled
45
-
46
- @staticmethod
47
- def step():
48
- """
49
- DEBUG LED FEEDBACK
50
- - handle 3 types of builtin LEDs: analog, neopixel(ws2812), apa102
51
- - automatic selection based on board type + builtin logical pin number
52
- """
53
- try:
54
- if callable(DebugCfg.PLED_STEP):
55
- return DebugCfg.PLED_STEP() # Run step function (return None: double-blink OR True: no d-b)
56
- except Exception as e:
57
- errlog_add(f"[PLED] step error: {e}")
58
- return True
33
+ pled = pinmap_search('builtin')['builtin']
34
+ if pled is None:
35
+ # No available builtin pin, skip pled init...
36
+ return
37
+ # CONFIGURE PROGRESS LED
38
+ if isinstance(pled, int):
39
+ # [MODE] Simple flashing progress LED
40
+ try:
41
+ # Progress led for esp32/etc
42
+ led_obj = Pin(abs(resolve_pin('builtin')), Pin.OUT)
43
+ if resolve_pin('builtin') < 0:
44
+ # Pin number start with (-), like -8 (means inverted output)
45
+ led_obj.value(1) # Turn OFF built-in LED state invert (1:OFF)
46
+ # Set function callback for step function (simple led - blink)
47
+ DebugCfg.PLED_STEP = lambda: led_obj.value(not led_obj.value()) # # double-blink: return None
48
+ except Exception as e:
49
+ syslog(f"[PLED] led error: {e}")
50
+ elif callable(pled):
51
+ # [MODE] OVERRIDE PROGRESS LED WITH CUSTOM step FUNCTION
52
+ DebugCfg.PLED_STEP = pled
53
+ DebugCfg._auto_register_pin()
54
+ else:
55
+ syslog(f"[WARN] pled type not supported: {pled}")
59
56
 
60
- @staticmethod
61
- def _init_simple():
62
- try:
63
- # Progress led for esp32/etc
64
- led_obj = Pin(abs(physical_pin('builtin')), Pin.OUT)
65
- if physical_pin('builtin') < 0: # Pin number start with (-), like -8 (means inverted output)
66
- led_obj.value(1) # Turn OFF built-in LED state invert (1:OFF)
67
- # Set function callback for step function (simple led - blink)
68
- DebugCfg.PLED_STEP = lambda: led_obj.value(not led_obj.value()) # # double-blink: return None
69
- except Exception as e:
70
- errlog_add(f"[PLED] led error: {e}")
71
57
 
72
58
  @staticmethod
73
- def _init_apa102():
59
+ def _auto_register_pin():
74
60
  try:
75
- from machine import SoftSPI
76
- from dotstar import DotStar
77
- from tinypico import DOTSTAR_CLK, DOTSTAR_DATA, SPI_MISO, set_dotstar_power, dotstar_color_wheel
78
- spi = SoftSPI(sck=Pin(DOTSTAR_CLK), mosi=Pin(DOTSTAR_DATA), miso=Pin(SPI_MISO))
79
- # Create a DotStar instance
80
- dotstar = DotStar(spi, 1, brightness=0.4) # Just one DotStar, half brightness
81
- # Turn on the power to the DotStar
82
- set_dotstar_power(True)
83
- DebugCfg.PLED_STEP = lambda: DebugCfg._step_apa102(led_obj=dotstar, color_wheel=dotstar_color_wheel)
61
+ pin = DebugCfg.PLED_STEP(pin=True)
62
+ if isinstance(pin, int):
63
+ register_pin('builtin', pin)
84
64
  except Exception as e:
85
- errlog_add(f"[PLED] apa102 error: {e}")
65
+ syslog(f"[ERR] pled pin registration: {e}", console=False)
86
66
 
87
- @staticmethod
88
- def _step_apa102(led_obj, color_wheel):
89
- # Get the R,G,B values of the next colour
90
- r, g, b = color_wheel(DebugCfg.COLOR_INDEX*2)
91
- # Set the colour on the DOTSTAR
92
- led_obj[0] = (int(r * 0.6), g, b, 0.4)
93
- # Increase the wheel index
94
- DebugCfg.COLOR_INDEX = 0 if DebugCfg.COLOR_INDEX > 1000 else DebugCfg.COLOR_INDEX + 2
95
- return True # No double-blink
96
67
 
97
68
  @staticmethod
98
- def _init_ws2812():
69
+ def step():
70
+ """
71
+ DEBUG LED FLASHING FEEDBACK
72
+ - handle step callback function execution
73
+ """
99
74
  try:
100
- from neopixel import NeoPixel
101
- neo_pin = Pin(physical_pin('builtin'))
102
- led_obj = NeoPixel(neo_pin, 1)
103
- DebugCfg.PLED_STEP = lambda: DebugCfg._step_ws2812(led_obj)
75
+ if callable(DebugCfg.PLED_STEP):
76
+ return DebugCfg.PLED_STEP() # Run step function (return None: double-blink OR True: no d-b)
104
77
  except Exception as e:
105
- errlog_add(f"[PLED] ws2812 error: {e}")
106
-
107
- @staticmethod
108
- def _step_ws2812(led_obj):
109
- def _color_wheel():
110
- while True:
111
- yield 10, 0, 0
112
- yield 5, 5, 0
113
- yield 0, 10, 0
114
- yield 0, 5, 5
115
- yield 0, 0, 10
116
- yield 5, 0, 5
117
- if DebugCfg.NEO_WHEEL is None:
118
- DebugCfg.NEO_WHEEL = _color_wheel()
119
- led_obj[0] = next(DebugCfg.NEO_WHEEL)
120
- led_obj.write()
121
- return True # No double-blink
78
+ syslog(f"[PLED] step error: {e}")
79
+ return True
122
80
 
123
81
 
124
82
  def console_write(msg):
@@ -129,112 +87,15 @@ def console_write(msg):
129
87
  if analog is None:
130
88
  DebugCfg.step() # Double-blink
131
89
  except Exception as e:
132
- errlog_add(f"[ERR] console_write: {e}", console=False)
133
-
134
- #############################################
135
- # LOGGING WITH DATA ROTATION #
136
- #############################################
90
+ syslog(f"[ERR] console_write: {e}", console=False)
137
91
 
138
92
 
139
- def logger(data, f_name, limit):
140
- """
141
- Create generic logger function
142
- - implements log line rotation
143
- - automatic time stump
144
- :param data: input string data to log
145
- :param f_name: file name to use
146
- :param limit: line limit for log rotation
147
- return write verdict - true / false
148
- INFO: hardcoded max data number = 30
149
- """
150
- def _logger(_data, _f_name, _limit, f_mode='r+'):
151
- _limit = 30 if _limit > 30 else _limit
152
- # [1] GET TIME STUMP
153
- ts_buff = [str(k) for k in localtime()]
154
- ts = ".".join(ts_buff[0:3]) + "-" + ":".join(ts_buff[3:6])
155
- # [2] OPEN FILE - WRITE DATA WITH TS
156
- with open(_f_name, f_mode) as f:
157
- _data = f"{ts} {_data}\n"
158
- # read file lines and filter by time stump chunks (hack for replace truncate)
159
- lines = [_l for _l in f.readlines() if '-' in _l and '.' in _l]
160
- # get file params
161
- lines_len = len(lines)
162
- lines.append(_data)
163
- f.seek(0)
164
- # line data rotate
165
- if lines_len >= _limit:
166
- lines = lines[-_limit:]
167
- lines_str = ''.join(lines)
168
- else:
169
- lines_str = ''.join(lines)
170
- # write file
171
- f.write(lines_str)
172
-
173
- # Run logger
174
- try:
175
- # There is file - append 'r+'
176
- _logger(data, f_name, limit)
177
- except:
178
- try:
179
- # There is no file - create 'a+'
180
- _logger(data, f_name, limit, 'a+')
181
- except:
182
- return False
183
- return True
184
-
185
-
186
- def log_get(f_name, msgobj=None):
187
- """
188
- Get and stream (ver osocket/stdout) .log file's content and count "critical" errors
189
- - critical error tag in log line: [ERR]
190
- """
191
- err_cnt = 0
192
- try:
193
- with open(f_name, 'r') as f:
194
- eline = f.readline().strip()
195
- while eline:
196
- # GET error from log line (tag: [ERR])
197
- err_cnt += 1 if "[ERR]" in eline else 0
198
- # GIVE BACK .log file contents
199
- if msgobj is None:
200
- console_write(eline)
201
- else:
202
- msgobj(eline)
203
- eline = f.readline().strip()
204
- except:
205
- pass
206
- return err_cnt
207
-
208
-
209
- #############################################
210
- # ERROR LOGGING #
211
- #############################################
212
-
213
-
214
- def errlog_add(data, console=True):
93
+ def syslog(data, console=True):
215
94
  """
216
95
  :param data: msg string / data
217
96
  :param console: activate console_write (default: True)
218
97
  :return: is ok
219
98
  """
220
99
  if console:
221
- console_write(msg=data)
222
- return logger(data, 'err.log', limit=6)
223
-
224
-
225
- def errlog_get(msgobj=None):
226
- f_name = 'err.log'
227
- errcnt = log_get(f_name, msgobj)
228
- # Return error number
229
- return errcnt
230
-
231
-
232
- def errlog_clean(msgobj=None):
233
- to_del = [file for file in os.listdir() if file.endswith('.log')]
234
- for _del in to_del:
235
- del_msg = f" Delete: {_del}"
236
- if msgobj is None:
237
- console_write(del_msg)
238
- else:
239
- msgobj(del_msg)
240
- os.remove(_del)
100
+ console_write(data)
101
+ return False if logger_syslog is None else logger_syslog(data)