machineconfig 1.97__py3-none-any.whl → 2.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 machineconfig might be problematic. Click here for more details.

Files changed (268) hide show
  1. machineconfig/cluster/cloud_manager.py +22 -29
  2. machineconfig/cluster/data_transfer.py +2 -3
  3. machineconfig/cluster/distribute.py +0 -2
  4. machineconfig/cluster/file_manager.py +4 -5
  5. machineconfig/cluster/job_params.py +1 -4
  6. machineconfig/cluster/loader_runner.py +8 -11
  7. machineconfig/cluster/remote_machine.py +4 -5
  8. machineconfig/cluster/script_execution.py +2 -2
  9. machineconfig/cluster/script_notify_upon_completion.py +0 -1
  10. machineconfig/cluster/sessions_managers/archive/create_zellij_template.py +4 -6
  11. machineconfig/cluster/sessions_managers/archive/session_managers.py +0 -1
  12. machineconfig/cluster/sessions_managers/enhanced_command_runner.py +35 -75
  13. machineconfig/cluster/sessions_managers/wt_local.py +113 -185
  14. machineconfig/cluster/sessions_managers/wt_local_manager.py +127 -197
  15. machineconfig/cluster/sessions_managers/wt_remote.py +60 -67
  16. machineconfig/cluster/sessions_managers/wt_remote_manager.py +110 -149
  17. machineconfig/cluster/sessions_managers/wt_utils/layout_generator.py +61 -64
  18. machineconfig/cluster/sessions_managers/wt_utils/process_monitor.py +72 -172
  19. machineconfig/cluster/sessions_managers/wt_utils/remote_executor.py +27 -60
  20. machineconfig/cluster/sessions_managers/wt_utils/session_manager.py +58 -137
  21. machineconfig/cluster/sessions_managers/wt_utils/status_reporter.py +46 -74
  22. machineconfig/cluster/sessions_managers/zellij_local.py +91 -147
  23. machineconfig/cluster/sessions_managers/zellij_local_manager.py +165 -190
  24. machineconfig/cluster/sessions_managers/zellij_remote.py +51 -58
  25. machineconfig/cluster/sessions_managers/zellij_remote_manager.py +40 -46
  26. machineconfig/cluster/sessions_managers/zellij_utils/example_usage.py +19 -17
  27. machineconfig/cluster/sessions_managers/zellij_utils/layout_generator.py +30 -31
  28. machineconfig/cluster/sessions_managers/zellij_utils/process_monitor.py +64 -134
  29. machineconfig/cluster/sessions_managers/zellij_utils/remote_executor.py +7 -11
  30. machineconfig/cluster/sessions_managers/zellij_utils/session_manager.py +27 -55
  31. machineconfig/cluster/sessions_managers/zellij_utils/status_reporter.py +14 -13
  32. machineconfig/cluster/templates/cli_click.py +0 -1
  33. machineconfig/cluster/templates/cli_gooey.py +0 -2
  34. machineconfig/cluster/templates/cli_trogon.py +0 -1
  35. machineconfig/cluster/templates/run_cloud.py +0 -1
  36. machineconfig/cluster/templates/run_cluster.py +0 -1
  37. machineconfig/cluster/templates/run_remote.py +0 -1
  38. machineconfig/cluster/templates/utils.py +27 -11
  39. machineconfig/jobs/__pycache__/__init__.cpython-313.pyc +0 -0
  40. machineconfig/jobs/linux/msc/cli_agents.sh +16 -0
  41. machineconfig/jobs/python/check_installations.py +9 -9
  42. machineconfig/jobs/python/create_bootable_media.py +0 -2
  43. machineconfig/jobs/python/python_cargo_build_share.py +2 -2
  44. machineconfig/jobs/python/python_ve_symlink.py +9 -11
  45. machineconfig/jobs/python/tasks.py +0 -1
  46. machineconfig/jobs/python/vscode/api.py +5 -5
  47. machineconfig/jobs/python/vscode/link_ve.py +20 -21
  48. machineconfig/jobs/python/vscode/select_interpreter.py +28 -29
  49. machineconfig/jobs/python/vscode/sync_code.py +14 -18
  50. machineconfig/jobs/python_custom_installers/__pycache__/__init__.cpython-313.pyc +0 -0
  51. machineconfig/jobs/python_custom_installers/archive/ngrok.py +15 -15
  52. machineconfig/jobs/python_custom_installers/dev/aider.py +10 -18
  53. machineconfig/jobs/python_custom_installers/dev/alacritty.py +12 -21
  54. machineconfig/jobs/python_custom_installers/dev/brave.py +13 -22
  55. machineconfig/jobs/python_custom_installers/dev/bypass_paywall.py +13 -20
  56. machineconfig/jobs/python_custom_installers/dev/code.py +17 -24
  57. machineconfig/jobs/python_custom_installers/dev/cursor.py +10 -21
  58. machineconfig/jobs/python_custom_installers/dev/docker_desktop.py +12 -11
  59. machineconfig/jobs/python_custom_installers/dev/espanso.py +19 -23
  60. machineconfig/jobs/python_custom_installers/dev/goes.py +9 -16
  61. machineconfig/jobs/python_custom_installers/dev/lvim.py +13 -21
  62. machineconfig/jobs/python_custom_installers/dev/nerdfont.py +15 -22
  63. machineconfig/jobs/python_custom_installers/dev/redis.py +15 -23
  64. machineconfig/jobs/python_custom_installers/dev/wezterm.py +15 -22
  65. machineconfig/jobs/python_custom_installers/dev/winget.py +32 -50
  66. machineconfig/jobs/python_custom_installers/docker.py +15 -24
  67. machineconfig/jobs/python_custom_installers/gh.py +18 -26
  68. machineconfig/jobs/python_custom_installers/hx.py +33 -17
  69. machineconfig/jobs/python_custom_installers/warp-cli.py +15 -23
  70. machineconfig/jobs/python_generic_installers/__pycache__/__init__.cpython-313.pyc +0 -0
  71. machineconfig/jobs/python_generic_installers/config.json +412 -389
  72. machineconfig/jobs/python_linux_installers/__pycache__/__init__.cpython-313.pyc +0 -0
  73. machineconfig/jobs/python_windows_installers/dev/config.json +1 -1
  74. machineconfig/jobs/windows/archive/archive_pygraphviz.ps1 +1 -1
  75. machineconfig/jobs/windows/msc/cli_agents.bat +0 -0
  76. machineconfig/jobs/windows/msc/cli_agents.ps1 +0 -0
  77. machineconfig/jobs/windows/start_terminal.ps1 +1 -1
  78. machineconfig/logger.py +50 -0
  79. machineconfig/profile/create.py +50 -36
  80. machineconfig/profile/create_hardlinks.py +33 -26
  81. machineconfig/profile/shell.py +87 -60
  82. machineconfig/scripts/__pycache__/__init__.cpython-313.pyc +0 -0
  83. machineconfig/scripts/cloud/init.sh +2 -2
  84. machineconfig/scripts/linux/checkout_versions +1 -1
  85. machineconfig/scripts/linux/choose_wezterm_theme +1 -1
  86. machineconfig/scripts/linux/cloud_copy +1 -1
  87. machineconfig/scripts/linux/cloud_manager +1 -1
  88. machineconfig/scripts/linux/cloud_mount +1 -1
  89. machineconfig/scripts/linux/cloud_repo_sync +1 -1
  90. machineconfig/scripts/linux/cloud_sync +1 -1
  91. machineconfig/scripts/linux/croshell +1 -1
  92. machineconfig/scripts/linux/devops +3 -5
  93. machineconfig/scripts/linux/fire +2 -1
  94. machineconfig/scripts/linux/fire_agents +3 -3
  95. machineconfig/scripts/linux/ftpx +1 -1
  96. machineconfig/scripts/linux/gh_models +1 -1
  97. machineconfig/scripts/linux/kill_process +1 -1
  98. machineconfig/scripts/linux/mcinit +2 -2
  99. machineconfig/scripts/linux/repos +1 -1
  100. machineconfig/scripts/linux/scheduler +1 -1
  101. machineconfig/scripts/linux/start_slidev +1 -1
  102. machineconfig/scripts/linux/start_terminals +1 -1
  103. machineconfig/scripts/linux/url2md +1 -1
  104. machineconfig/scripts/linux/warp-cli.sh +122 -0
  105. machineconfig/scripts/linux/wifi_conn +1 -1
  106. machineconfig/scripts/python/__pycache__/__init__.cpython-313.pyc +0 -0
  107. machineconfig/scripts/python/__pycache__/croshell.cpython-313.pyc +0 -0
  108. machineconfig/scripts/python/__pycache__/devops.cpython-313.pyc +0 -0
  109. machineconfig/scripts/python/__pycache__/devops_devapps_install.cpython-313.pyc +0 -0
  110. machineconfig/scripts/python/__pycache__/devops_update_repos.cpython-313.pyc +0 -0
  111. machineconfig/scripts/python/__pycache__/fire_jobs.cpython-313.pyc +0 -0
  112. machineconfig/scripts/python/ai/__init__.py +0 -0
  113. machineconfig/scripts/python/ai/__pycache__/__init__.cpython-313.pyc +0 -0
  114. machineconfig/scripts/python/ai/__pycache__/generate_files.cpython-313.pyc +0 -0
  115. machineconfig/scripts/python/ai/__pycache__/mcinit.cpython-313.pyc +0 -0
  116. machineconfig/scripts/python/ai/chatmodes/Thinking-Beast-Mode.chatmode.md +337 -0
  117. machineconfig/scripts/python/ai/chatmodes/Ultimate-Transparent-Thinking-Beast-Mode.chatmode.md +644 -0
  118. machineconfig/scripts/python/ai/chatmodes/deepResearch.chatmode.md +81 -0
  119. machineconfig/scripts/python/ai/configs/.gemini/settings.json +81 -0
  120. machineconfig/scripts/python/ai/generate_files.py +84 -0
  121. machineconfig/scripts/python/ai/instructions/python/dev.instructions.md +45 -0
  122. machineconfig/scripts/python/ai/mcinit.py +107 -0
  123. machineconfig/scripts/python/ai/prompts/allLintersAndTypeCheckers.prompt.md +5 -0
  124. machineconfig/scripts/python/ai/prompts/research-report-skeleton.prompt.md +38 -0
  125. machineconfig/scripts/python/ai/scripts/lint_and_type_check.sh +52 -0
  126. machineconfig/scripts/python/archive/tmate_conn.py +5 -5
  127. machineconfig/scripts/python/archive/tmate_start.py +3 -3
  128. machineconfig/scripts/python/choose_wezterm_theme.py +2 -2
  129. machineconfig/scripts/python/cloud_copy.py +20 -19
  130. machineconfig/scripts/python/cloud_mount.py +10 -8
  131. machineconfig/scripts/python/cloud_repo_sync.py +15 -15
  132. machineconfig/scripts/python/cloud_sync.py +1 -1
  133. machineconfig/scripts/python/croshell.py +18 -16
  134. machineconfig/scripts/python/devops.py +6 -6
  135. machineconfig/scripts/python/devops_add_identity.py +9 -7
  136. machineconfig/scripts/python/devops_add_ssh_key.py +19 -19
  137. machineconfig/scripts/python/devops_backup_retrieve.py +14 -14
  138. machineconfig/scripts/python/devops_devapps_install.py +3 -3
  139. machineconfig/scripts/python/devops_update_repos.py +141 -53
  140. machineconfig/scripts/python/dotfile.py +3 -3
  141. machineconfig/scripts/python/fire_agents.py +202 -41
  142. machineconfig/scripts/python/fire_jobs.py +20 -21
  143. machineconfig/scripts/python/ftpx.py +4 -3
  144. machineconfig/scripts/python/gh_models.py +94 -94
  145. machineconfig/scripts/python/helpers/__pycache__/__init__.cpython-313.pyc +0 -0
  146. machineconfig/scripts/python/helpers/__pycache__/helpers4.cpython-313.pyc +0 -0
  147. machineconfig/scripts/python/helpers/cloud_helpers.py +3 -3
  148. machineconfig/scripts/python/helpers/helpers2.py +3 -3
  149. machineconfig/scripts/python/helpers/helpers4.py +8 -7
  150. machineconfig/scripts/python/helpers/helpers5.py +7 -7
  151. machineconfig/scripts/python/helpers/repo_sync_helpers.py +2 -2
  152. machineconfig/scripts/python/mount_nfs.py +4 -3
  153. machineconfig/scripts/python/mount_nw_drive.py +4 -4
  154. machineconfig/scripts/python/mount_ssh.py +4 -3
  155. machineconfig/scripts/python/repos.py +9 -9
  156. machineconfig/scripts/python/scheduler.py +1 -1
  157. machineconfig/scripts/python/start_slidev.py +9 -8
  158. machineconfig/scripts/python/start_terminals.py +1 -1
  159. machineconfig/scripts/python/viewer.py +40 -40
  160. machineconfig/scripts/python/wifi_conn.py +65 -66
  161. machineconfig/scripts/python/wsl_windows_transfer.py +2 -2
  162. machineconfig/scripts/windows/checkout_version.ps1 +1 -3
  163. machineconfig/scripts/windows/choose_wezterm_theme.ps1 +1 -3
  164. machineconfig/scripts/windows/cloud_copy.ps1 +2 -6
  165. machineconfig/scripts/windows/cloud_manager.ps1 +1 -1
  166. machineconfig/scripts/windows/cloud_repo_sync.ps1 +1 -2
  167. machineconfig/scripts/windows/cloud_sync.ps1 +2 -2
  168. machineconfig/scripts/windows/croshell.ps1 +2 -2
  169. machineconfig/scripts/windows/devops.ps1 +1 -4
  170. machineconfig/scripts/windows/dotfile.ps1 +1 -3
  171. machineconfig/scripts/windows/fire.ps1 +1 -1
  172. machineconfig/scripts/windows/ftpx.ps1 +2 -2
  173. machineconfig/scripts/windows/gpt.ps1 +1 -1
  174. machineconfig/scripts/windows/kill_process.ps1 +1 -2
  175. machineconfig/scripts/windows/mcinit.ps1 +2 -2
  176. machineconfig/scripts/windows/mount_nfs.ps1 +1 -1
  177. machineconfig/scripts/windows/mount_ssh.ps1 +1 -1
  178. machineconfig/scripts/windows/pomodoro.ps1 +1 -1
  179. machineconfig/scripts/windows/py2exe.ps1 +1 -3
  180. machineconfig/scripts/windows/repos.ps1 +1 -1
  181. machineconfig/scripts/windows/scheduler.ps1 +1 -1
  182. machineconfig/scripts/windows/snapshot.ps1 +2 -2
  183. machineconfig/scripts/windows/start_slidev.ps1 +1 -1
  184. machineconfig/scripts/windows/start_terminals.ps1 +1 -1
  185. machineconfig/scripts/windows/wifi_conn.ps1 +1 -1
  186. machineconfig/scripts/windows/wsl_windows_transfer.ps1 +1 -3
  187. machineconfig/settings/lf/linux/lfrc +1 -1
  188. machineconfig/settings/linters/.ruff.toml +2 -2
  189. machineconfig/settings/linters/.ruff_cache/.gitignore +2 -0
  190. machineconfig/settings/linters/.ruff_cache/CACHEDIR.TAG +1 -0
  191. machineconfig/settings/lvim/windows/archive/config_additional.lua +1 -1
  192. machineconfig/settings/shells/ipy/profiles/default/startup/playext.py +71 -71
  193. machineconfig/settings/shells/wt/settings.json +8 -8
  194. machineconfig/settings/svim/linux/init.toml +1 -1
  195. machineconfig/settings/svim/windows/init.toml +1 -1
  196. machineconfig/setup_linux/web_shortcuts/croshell.sh +0 -54
  197. machineconfig/setup_linux/web_shortcuts/interactive.sh +6 -6
  198. machineconfig/setup_linux/web_shortcuts/tmp.sh +2 -0
  199. machineconfig/setup_windows/web_shortcuts/all.ps1 +2 -2
  200. machineconfig/setup_windows/web_shortcuts/ascii_art.ps1 +1 -1
  201. machineconfig/setup_windows/web_shortcuts/croshell.ps1 +1 -1
  202. machineconfig/setup_windows/web_shortcuts/interactive.ps1 +5 -5
  203. machineconfig/setup_windows/wt_and_pwsh/install_fonts.ps1 +51 -15
  204. machineconfig/setup_windows/wt_and_pwsh/set_pwsh_theme.py +75 -18
  205. machineconfig/setup_windows/wt_and_pwsh/set_wt_settings.py +52 -42
  206. machineconfig/utils/ai/browser_user_wrapper.py +5 -5
  207. machineconfig/utils/ai/generate_file_checklist.py +19 -22
  208. machineconfig/utils/ai/url2md.py +5 -3
  209. machineconfig/utils/cloud/onedrive/setup_oauth.py +5 -4
  210. machineconfig/utils/cloud/onedrive/transaction.py +192 -227
  211. machineconfig/utils/code.py +71 -43
  212. machineconfig/utils/installer.py +77 -85
  213. machineconfig/utils/installer_utils/installer_abc.py +29 -17
  214. machineconfig/utils/installer_utils/installer_class.py +188 -83
  215. machineconfig/utils/io_save.py +3 -15
  216. machineconfig/utils/links.py +22 -11
  217. machineconfig/utils/notifications.py +197 -0
  218. machineconfig/utils/options.py +38 -25
  219. machineconfig/utils/path.py +18 -6
  220. machineconfig/utils/path_reduced.py +637 -316
  221. machineconfig/utils/procs.py +69 -63
  222. machineconfig/utils/scheduling.py +11 -13
  223. machineconfig/utils/ssh.py +351 -0
  224. machineconfig/utils/terminal.py +225 -0
  225. machineconfig/utils/utils.py +13 -12
  226. machineconfig/utils/utils2.py +43 -10
  227. machineconfig/utils/utils5.py +242 -46
  228. machineconfig/utils/ve.py +11 -6
  229. {machineconfig-1.97.dist-info → machineconfig-2.1.dist-info}/METADATA +15 -9
  230. {machineconfig-1.97.dist-info → machineconfig-2.1.dist-info}/RECORD +232 -235
  231. machineconfig/cluster/self_ssh.py +0 -57
  232. machineconfig/jobs/__pycache__/__init__.cpython-311.pyc +0 -0
  233. machineconfig/jobs/python/__pycache__/__init__.cpython-311.pyc +0 -0
  234. machineconfig/jobs/python/archive/python_tools.txt +0 -12
  235. machineconfig/jobs/python/vscode/__pycache__/select_interpreter.cpython-311.pyc +0 -0
  236. machineconfig/jobs/python_custom_installers/__pycache__/__init__.cpython-311.pyc +0 -0
  237. machineconfig/jobs/python_generic_installers/__pycache__/__init__.cpython-311.pyc +0 -0
  238. machineconfig/jobs/python_generic_installers/update.py +0 -3
  239. machineconfig/jobs/python_linux_installers/__pycache__/__init__.cpython-311.pyc +0 -0
  240. machineconfig/profile/__pycache__/__init__.cpython-311.pyc +0 -0
  241. machineconfig/profile/__pycache__/create.cpython-311.pyc +0 -0
  242. machineconfig/profile/__pycache__/shell.cpython-311.pyc +0 -0
  243. machineconfig/scripts/__pycache__/__init__.cpython-311.pyc +0 -0
  244. machineconfig/scripts/linux/activate_ve +0 -87
  245. machineconfig/scripts/python/__pycache__/__init__.cpython-311.pyc +0 -0
  246. machineconfig/scripts/python/__pycache__/cloud_copy.cpython-311.pyc +0 -0
  247. machineconfig/scripts/python/__pycache__/cloud_mount.cpython-311.pyc +0 -0
  248. machineconfig/scripts/python/__pycache__/cloud_sync.cpython-311.pyc +0 -0
  249. machineconfig/scripts/python/__pycache__/croshell.cpython-311.pyc +0 -0
  250. machineconfig/scripts/python/__pycache__/devops.cpython-311.pyc +0 -0
  251. machineconfig/scripts/python/__pycache__/devops_backup_retrieve.cpython-311.pyc +0 -0
  252. machineconfig/scripts/python/__pycache__/devops_devapps_install.cpython-311.pyc +0 -0
  253. machineconfig/scripts/python/__pycache__/devops_update_repos.cpython-311.pyc +0 -0
  254. machineconfig/scripts/python/__pycache__/fire_agents.cpython-311.pyc +0 -0
  255. machineconfig/scripts/python/__pycache__/fire_jobs.cpython-311.pyc +0 -0
  256. machineconfig/scripts/python/__pycache__/get_zellij_cmd.cpython-311.pyc +0 -0
  257. machineconfig/scripts/python/__pycache__/repos.cpython-311.pyc +0 -0
  258. machineconfig/scripts/python/ai/__pycache__/init.cpython-311.pyc +0 -0
  259. machineconfig/scripts/python/ai/init.py +0 -56
  260. machineconfig/scripts/python/ai/rules/python/dev.md +0 -31
  261. machineconfig/scripts/python/helpers/__pycache__/__init__.cpython-311.pyc +0 -0
  262. machineconfig/scripts/python/helpers/__pycache__/cloud_helpers.cpython-311.pyc +0 -0
  263. machineconfig/scripts/python/helpers/__pycache__/helpers2.cpython-311.pyc +0 -0
  264. machineconfig/scripts/python/helpers/__pycache__/helpers4.cpython-311.pyc +0 -0
  265. machineconfig/scripts/python/helpers/__pycache__/repo_sync_helpers.cpython-311.pyc +0 -0
  266. machineconfig/scripts/windows/activate_ve.ps1 +0 -54
  267. {machineconfig-1.97.dist-info → machineconfig-2.1.dist-info}/WHEEL +0 -0
  268. {machineconfig-1.97.dist-info → machineconfig-2.1.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
1
- """Procs
2
- """
1
+ """Procs"""
2
+
3
3
  import psutil
4
4
  from tqdm import tqdm
5
5
  from pytz import timezone
@@ -29,7 +29,7 @@ def get_processes_accessing_file(path: str):
29
29
  if len(tmp) > 0:
30
30
  res[proc.pid] = tmp
31
31
  # Convert to list of dictionaries for consistent data structure
32
- result_data = [{'pid': pid, 'files': files} for pid, files in res.items()]
32
+ result_data = [{"pid": pid, "files": files} for pid, files in res.items()]
33
33
  console.print(Panel(f"✅ Found {len(res)} processes accessing the specified file", title="[bold blue]Process Info[/bold blue]", border_style="blue"))
34
34
  return result_data
35
35
 
@@ -44,7 +44,7 @@ def kill_process(name: str):
44
44
  killed = True
45
45
  if not killed:
46
46
  print(f"❓ No process with name '{name}' was found")
47
- print(f"{'─'*80}\n")
47
+ print(f"{'─' * 80}\n")
48
48
 
49
49
 
50
50
  class ProcessManager:
@@ -57,23 +57,26 @@ class ProcessManager:
57
57
  try:
58
58
  mem_usage_mb = proc.memory_info().rss / (1024 * 1024)
59
59
  # Convert create_time to local timezone
60
- create_time_utc = datetime.fromtimestamp(proc.create_time(), tz=timezone('UTC'))
61
- create_time_local = create_time_utc.astimezone(timezone('Australia/Adelaide'))
62
-
63
- process_info.append({
64
- 'pid': proc.pid,
65
- 'name': proc.name(),
66
- 'username': proc.username(),
67
- 'cpu_percent': proc.cpu_percent(),
68
- 'memory_usage_mb': mem_usage_mb,
69
- 'status': proc.status(),
70
- 'create_time': create_time_local,
71
- 'command': " ".join(proc.cmdline())
72
- })
73
- except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): pass
74
-
60
+ create_time_utc = datetime.fromtimestamp(proc.create_time(), tz=timezone("UTC"))
61
+ create_time_local = create_time_utc.astimezone(timezone("Australia/Adelaide"))
62
+
63
+ process_info.append(
64
+ {
65
+ "pid": proc.pid,
66
+ "name": proc.name(),
67
+ "username": proc.username(),
68
+ "cpu_percent": proc.cpu_percent(),
69
+ "memory_usage_mb": mem_usage_mb,
70
+ "status": proc.status(),
71
+ "create_time": create_time_local,
72
+ "command": " ".join(proc.cmdline()),
73
+ }
74
+ )
75
+ except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
76
+ pass
77
+
75
78
  # Sort by memory usage (descending)
76
- process_info.sort(key=lambda x: x['memory_usage_mb'], reverse=True)
79
+ process_info.sort(key=lambda x: x["memory_usage_mb"], reverse=True)
77
80
  self.data = process_info
78
81
  console.print(Panel(f"✅ Process Manager initialized with {len(process_info)} processes", title="[bold blue]Process Info[/bold blue]", border_style="blue"))
79
82
 
@@ -81,72 +84,72 @@ class ProcessManager:
81
84
  """Format process data as table string for display."""
82
85
  if not self.data:
83
86
  return ""
84
-
87
+
85
88
  # Create header
86
- _headers = ['PID', 'Name', 'Username', 'CPU%', 'Memory(MB)', 'Status', 'Create Time', 'Command']
89
+ _headers = ["PID", "Name", "Username", "CPU%", "Memory(MB)", "Status", "Create Time", "Command"]
87
90
  header_line = f"{'PID':<8} {'Name':<20} {'Username':<12} {'CPU%':<8} {'Memory(MB)':<12} {'Status':<12} {'Create Time':<20} {'Command':<50}"
88
91
  separator = "-" * len(header_line)
89
-
92
+
90
93
  lines = [header_line, separator]
91
-
94
+
92
95
  for process in self.data:
93
96
  # Format create_time as string
94
- create_time_str = process['create_time'].strftime('%Y-%m-%d %H:%M:%S')
97
+ create_time_str = process["create_time"].strftime("%Y-%m-%d %H:%M:%S")
95
98
  # Truncate command if too long
96
- command = process['command'][:47] + "..." if len(process['command']) > 50 else process['command']
97
-
99
+ command = process["command"][:47] + "..." if len(process["command"]) > 50 else process["command"]
100
+
98
101
  line = f"{process['pid']:<8} {process['name'][:19]:<20} {process['username'][:11]:<12} {process['cpu_percent']:<8.1f} {process['memory_usage_mb']:<12.2f} {process['status'][:11]:<12} {create_time_str:<20} {command:<50}"
99
102
  lines.append(line)
100
-
103
+
101
104
  return "\n".join(lines)
102
105
 
103
106
  def choose_and_kill(self):
104
107
  # header for interactive process selection
105
108
  title = "ðŸŽŊ INTERACTIVE PROCESS SELECTION AND TERMINATION"
106
109
  console.print(Panel(title, title="[bold blue]Process Info[/bold blue]", border_style="blue"))
107
-
110
+
108
111
  # Format data as table for display
109
112
  formatted_data = self._format_process_table()
110
113
  options = formatted_data.split("\n")[1:] # Skip header
111
114
  res = display_options(options=formatted_data.split("\n"), msg="📋 Select processes to manage:", fzf=True, multi=True)
112
115
  indices = [options.index(val) for val in res]
113
116
  selected_processes = [self.data[i] for i in indices]
114
-
117
+
115
118
  print("\n📊 All Processes:")
116
119
  print(formatted_data)
117
120
  print("\nðŸŽŊ Selected Processes:")
118
121
  for process in selected_processes:
119
122
  print(f"PID: {process['pid']}, Name: {process['name']}, Memory: {process['memory_usage_mb']:.2f}MB")
120
-
123
+
121
124
  for idx, process in enumerate(selected_processes):
122
125
  pprint(process, f"📌 Process {idx}")
123
-
126
+
124
127
  kill_all = input("\n⚠ïļ Confirm killing ALL selected processes? y/[n] ").lower() == "y"
125
128
  if kill_all:
126
- self.kill(pids=[p['pid'] for p in selected_processes])
129
+ self.kill(pids=[p["pid"] for p in selected_processes])
127
130
  return
128
-
131
+
129
132
  kill_by_index = input("\nðŸ”Ŧ Kill by index? (enter numbers separated by spaces, e.g. '1 4') or [n] to cancel: ")
130
133
  if kill_by_index != "" and kill_by_index != "n":
131
134
  indices = [int(val) for val in kill_by_index.split(" ")]
132
135
  target_processes = [selected_processes[i] for i in indices]
133
136
  for idx2, process in enumerate(target_processes):
134
137
  pprint(process, f"ðŸŽŊ Target Process {idx2}")
135
- _ = self.kill(pids=[p['pid'] for p in target_processes]) if input("\n⚠ïļ Confirm termination? y/[n] ").lower() == "y" else None
138
+ _ = self.kill(pids=[p["pid"] for p in target_processes]) if input("\n⚠ïļ Confirm termination? y/[n] ").lower() == "y" else None
136
139
  console.print(Panel("🔔 No processes were terminated.", title="[bold blue]Process Info[/bold blue]", border_style="blue"))
137
140
 
138
141
  def filter_and_kill(self, name: Optional[str] = None):
139
142
  # header for filtering processes by name
140
143
  title = "🔍 FILTERING AND TERMINATING PROCESSES BY NAME"
141
144
  console.print(Panel(title, title="[bold blue]Process Info[/bold blue]", border_style="blue"))
142
-
145
+
143
146
  # Filter processes by name
144
- filtered_processes = [p for p in self.data if p['name'] == name]
147
+ filtered_processes = [p for p in self.data if p["name"] == name]
145
148
  # Sort by create_time (ascending)
146
- filtered_processes.sort(key=lambda x: x['create_time'])
147
-
149
+ filtered_processes.sort(key=lambda x: x["create_time"])
150
+
148
151
  print(f"ðŸŽŊ Found {len(filtered_processes)} processes matching name: '{name}'")
149
- self.kill(pids=[p['pid'] for p in filtered_processes])
152
+ self.kill(pids=[p["pid"] for p in filtered_processes])
150
153
  console.print(Panel("", title="[bold blue]Process Info[/bold blue]", border_style="blue"))
151
154
 
152
155
  def kill(self, names: Optional[list[str]] = None, pids: Optional[list[int]] = None, commands: Optional[list[str]] = None):
@@ -155,23 +158,26 @@ class ProcessManager:
155
158
  console.print(Panel(title, title="[bold blue]Process Info[/bold blue]", border_style="blue"))
156
159
  if names is None and pids is None and commands is None:
157
160
  print("❌ Error: No termination targets specified (names, pids, or commands)")
158
- raise ValueError('names, pids and commands cannot all be None')
159
- if names is None: names = []
160
- if pids is None: pids = []
161
- if commands is None: commands = []
162
-
161
+ raise ValueError("names, pids and commands cannot all be None")
162
+ if names is None:
163
+ names = []
164
+ if pids is None:
165
+ pids = []
166
+ if commands is None:
167
+ commands = []
168
+
163
169
  killed_count = 0
164
-
170
+
165
171
  for name in names:
166
- matching_processes = [p for p in self.data if p['name'] == name]
172
+ matching_processes = [p for p in self.data if p["name"] == name]
167
173
  if len(matching_processes) > 0:
168
174
  for process in matching_processes:
169
- psutil.Process(process['pid']).kill()
170
- print(f'💀 Killed process {name} with PID {process["pid"]}. It lived {get_age(process["create_time"])}. RIP ðŸŠĶ💐')
175
+ psutil.Process(process["pid"]).kill()
176
+ print(f"💀 Killed process {name} with PID {process['pid']}. It lived {get_age(process['create_time'])}. RIP ðŸŠĶ💐")
171
177
  killed_count += 1
172
- else:
178
+ else:
173
179
  print(f'❓ No process named "{name}" found')
174
-
180
+
175
181
  for pid in pids:
176
182
  try:
177
183
  proc = psutil.Process(pid)
@@ -180,19 +186,19 @@ class ProcessManager:
180
186
  proc.kill()
181
187
  print(f'💀 Killed process with PID {pid} and name "{proc_name}". It lived {proc_lifetime}. RIP ðŸŠĶ💐')
182
188
  killed_count += 1
183
- except psutil.NoSuchProcess:
184
- print(f'❓ No process with PID {pid} found')
185
-
189
+ except psutil.NoSuchProcess:
190
+ print(f"❓ No process with PID {pid} found")
191
+
186
192
  for command in commands:
187
- matching_processes = [p for p in self.data if command in p['command']]
193
+ matching_processes = [p for p in self.data if command in p["command"]]
188
194
  if len(matching_processes) > 0:
189
195
  for process in matching_processes:
190
- psutil.Process(process['pid']).kill()
196
+ psutil.Process(process["pid"]).kill()
191
197
  print(f'💀 Killed process with "{command}" in its command & PID {process["pid"]}. It lived {get_age(process["create_time"])}. RIP ðŸŠĶ💐')
192
198
  killed_count += 1
193
- else:
199
+ else:
194
200
  print(f'❓ No process has "{command}" in its command.')
195
-
201
+
196
202
  console.print(Panel(f"✅ Termination complete: {killed_count} processes terminated", title="[bold blue]Process Info[/bold blue]", border_style="blue"))
197
203
 
198
204
 
@@ -201,13 +207,13 @@ def get_age(create_time: Any) -> str:
201
207
  try:
202
208
  if isinstance(create_time, (int, float)):
203
209
  # Handle timestampz
204
- create_time_utc = datetime.fromtimestamp(create_time, tz=timezone('UTC'))
205
- create_time_local = create_time_utc.astimezone(timezone('Australia/Adelaide'))
210
+ create_time_utc = datetime.fromtimestamp(create_time, tz=timezone("UTC"))
211
+ create_time_local = create_time_utc.astimezone(timezone("Australia/Adelaide"))
206
212
  else:
207
213
  # Already a datetime object
208
214
  create_time_local = create_time
209
-
210
- now_local = datetime.now(tz=timezone('Australia/Adelaide'))
215
+
216
+ now_local = datetime.now(tz=timezone("Australia/Adelaide"))
211
217
  age = now_local - create_time_local
212
218
  return str(age)
213
219
  except Exception as e:
@@ -224,5 +230,5 @@ def get_age(create_time: Any) -> str:
224
230
  return f"unknown due to {ee} and {e}"
225
231
 
226
232
 
227
- if __name__ == '__main__':
233
+ if __name__ == "__main__":
228
234
  pass
@@ -16,13 +16,13 @@
16
16
  # """Convert string to timedelta. Simple implementation for common cases."""
17
17
  # # Handle common formats like "1h", "30m", "2d", etc.
18
18
  # import re
19
-
19
+
20
20
  # # Parse patterns like "1h", "30m", "2d", "1w"
21
21
  # match = re.match(r'^(\d+)([hdwm])$', time_str.lower())
22
22
  # if match:
23
23
  # value, unit = match.groups()
24
24
  # value = int(value)
25
-
25
+
26
26
  # if unit == 'h':
27
27
  # return timedelta(hours=value)
28
28
  # elif unit == 'd':
@@ -31,7 +31,7 @@
31
31
  # return timedelta(weeks=value)
32
32
  # elif unit == 'm':
33
33
  # return timedelta(minutes=value)
34
-
34
+
35
35
  # # Fallback: try to parse as seconds
36
36
  # try:
37
37
  # return timedelta(seconds=int(time_str))
@@ -43,18 +43,18 @@
43
43
  # """Convert list of dictionaries to markdown table format."""
44
44
  # if not data:
45
45
  # return ""
46
-
46
+
47
47
  # # Get all unique keys from all dictionaries
48
48
  # all_keys = set()
49
49
  # for row in data:
50
50
  # all_keys.update(row.keys())
51
-
51
+
52
52
  # keys = sorted(all_keys)
53
-
53
+
54
54
  # # Create header
55
55
  # header = "|" + "|".join(f" {key} " for key in keys) + "|"
56
56
  # separator = "|" + "|".join(" --- " for _ in keys) + "|"
57
-
57
+
58
58
  # # Create rows
59
59
  # rows = []
60
60
  # for row in data:
@@ -68,7 +68,7 @@
68
68
  # value = str(value)
69
69
  # row_values.append(f" {value} ")
70
70
  # rows.append("|" + "|".join(row_values) + "|")
71
-
71
+
72
72
  # return "\n".join([header, separator] + rows)
73
73
 
74
74
 
@@ -194,7 +194,6 @@
194
194
  # def main(root: Optional[str] = None, ignore_conditions: bool=True):
195
195
  # if root is None: root_resolved = SCHEDULER_DEFAULT_ROOT
196
196
  # else: root_resolved = PathExtended(root).expanduser().absolute()
197
- # # Replace crocodile List usage with pathlib iteration
198
197
  # from pathlib import Path
199
198
  # # Find all `task.py` files under root and use their parent directories
200
199
  # tasks_dirs = list({PathExtended(p.parent) for p in Path(str(root_resolved)).rglob("task.py")})
@@ -210,7 +209,7 @@
210
209
  # tasks.append(read_task_from_dir(a_dir))
211
210
 
212
211
  # from machineconfig.utils.utils import choose_multiple_options
213
-
212
+
214
213
  # # Create data for tasks display
215
214
  # task_data = [Report.from_path(path=a_task.report_path).__dict__ for a_task in tasks]
216
215
  # task_display = format_table_markdown(task_data)
@@ -285,15 +284,14 @@
285
284
 
286
285
  # print(f"Task: {task.name}")
287
286
 
288
- # shell_script = get_shell_script_executing_python_file(python_file=str(task.task_root.joinpath("task.py")), ve_name=task.venv)
289
287
  # shell_script_root = PathExtended.tmp().joinpath(f"tmp_scripts/scheduler/{task.name}")
290
288
  # shell_script_root.mkdir(parents=True, exist_ok=True)
291
289
  # try:
292
290
  # if platform.system() == 'Windows':
293
- # shell_script = shell_script_root.joinpath("run.ps1").write_text(shell_script)
291
+ # shell_script = shell_script_root.joinpath("run.ps1").write_text(shell_script, encoding="utf-8")
294
292
  # subprocess.run(['powershell', '-ExecutionPolicy', 'Unrestricted', shell_script], check=True)
295
293
  # elif platform.system() in ['Linux', 'Darwin']:
296
- # shell_script = shell_script_root.joinpath("run.sh").write_text(shell_script)
294
+ # shell_script = shell_script_root.joinpath("run.sh").write_text(shell_script, encoding="utf-8")
297
295
  # subprocess.run(['bash', shell_script], check=True)
298
296
  # else: res = f"Error: Unsupported platform {platform.system()}."
299
297
  # res = SUCCESS