machineconfig 2.0__py3-none-any.whl → 2.2__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.
- machineconfig/cluster/cloud_manager.py +0 -3
- machineconfig/cluster/data_transfer.py +0 -1
- machineconfig/cluster/file_manager.py +0 -1
- machineconfig/cluster/job_params.py +0 -3
- machineconfig/cluster/loader_runner.py +0 -3
- machineconfig/cluster/remote_machine.py +0 -1
- machineconfig/cluster/script_notify_upon_completion.py +0 -1
- machineconfig/cluster/sessions_managers/archive/create_zellij_template.py +5 -6
- machineconfig/cluster/sessions_managers/archive/session_managers.py +0 -1
- machineconfig/cluster/sessions_managers/enhanced_command_runner.py +17 -57
- machineconfig/cluster/sessions_managers/wt_local.py +36 -110
- machineconfig/cluster/sessions_managers/wt_local_manager.py +42 -112
- machineconfig/cluster/sessions_managers/wt_remote.py +23 -30
- machineconfig/cluster/sessions_managers/wt_remote_manager.py +20 -62
- machineconfig/cluster/sessions_managers/wt_utils/layout_generator.py +10 -15
- machineconfig/cluster/sessions_managers/wt_utils/process_monitor.py +27 -127
- machineconfig/cluster/sessions_managers/wt_utils/remote_executor.py +10 -43
- machineconfig/cluster/sessions_managers/wt_utils/session_manager.py +22 -101
- machineconfig/cluster/sessions_managers/wt_utils/status_reporter.py +11 -39
- machineconfig/cluster/sessions_managers/zellij_local.py +49 -102
- machineconfig/cluster/sessions_managers/zellij_local_manager.py +34 -78
- machineconfig/cluster/sessions_managers/zellij_remote.py +17 -24
- machineconfig/cluster/sessions_managers/zellij_remote_manager.py +7 -13
- machineconfig/cluster/sessions_managers/zellij_utils/example_usage.py +4 -2
- machineconfig/cluster/sessions_managers/zellij_utils/layout_generator.py +6 -6
- machineconfig/cluster/sessions_managers/zellij_utils/process_monitor.py +18 -88
- machineconfig/cluster/sessions_managers/zellij_utils/remote_executor.py +2 -6
- machineconfig/cluster/sessions_managers/zellij_utils/session_manager.py +12 -40
- machineconfig/cluster/sessions_managers/zellij_utils/status_reporter.py +3 -2
- machineconfig/cluster/templates/cli_click.py +0 -1
- machineconfig/cluster/templates/cli_gooey.py +0 -2
- machineconfig/cluster/templates/cli_trogon.py +0 -1
- machineconfig/cluster/templates/run_cloud.py +0 -1
- machineconfig/cluster/templates/run_cluster.py +0 -1
- machineconfig/cluster/templates/run_remote.py +0 -1
- machineconfig/cluster/templates/utils.py +27 -46
- machineconfig/jobs/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/jobs/linux/msc/cli_agents.sh +16 -0
- machineconfig/jobs/python/check_installations.py +2 -1
- machineconfig/jobs/python/create_bootable_media.py +0 -2
- machineconfig/jobs/python/python_ve_symlink.py +9 -11
- machineconfig/jobs/python/tasks.py +0 -1
- machineconfig/jobs/python/vscode/api.py +5 -5
- machineconfig/jobs/python/vscode/link_ve.py +13 -14
- machineconfig/jobs/python/vscode/select_interpreter.py +21 -22
- machineconfig/jobs/python/vscode/sync_code.py +9 -13
- machineconfig/jobs/python_custom_installers/archive/ngrok.py +13 -13
- machineconfig/jobs/python_custom_installers/dev/aider.py +7 -15
- machineconfig/jobs/python_custom_installers/dev/alacritty.py +9 -18
- machineconfig/jobs/python_custom_installers/dev/brave.py +10 -19
- machineconfig/jobs/python_custom_installers/dev/bypass_paywall.py +8 -15
- machineconfig/jobs/python_custom_installers/dev/code.py +12 -32
- machineconfig/jobs/python_custom_installers/dev/cursor.py +3 -14
- machineconfig/jobs/python_custom_installers/dev/docker_desktop.py +8 -7
- machineconfig/jobs/python_custom_installers/dev/espanso.py +15 -19
- machineconfig/jobs/python_custom_installers/dev/goes.py +5 -12
- machineconfig/jobs/python_custom_installers/dev/lvim.py +9 -17
- machineconfig/jobs/python_custom_installers/dev/nerdfont.py +12 -19
- machineconfig/jobs/python_custom_installers/dev/redis.py +12 -20
- machineconfig/jobs/python_custom_installers/dev/wezterm.py +12 -19
- machineconfig/jobs/python_custom_installers/dev/winget.py +5 -23
- machineconfig/jobs/python_custom_installers/docker.py +12 -21
- machineconfig/jobs/python_custom_installers/gh.py +11 -19
- machineconfig/jobs/python_custom_installers/hx.py +32 -16
- machineconfig/jobs/python_custom_installers/warp-cli.py +12 -20
- machineconfig/jobs/python_generic_installers/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/jobs/python_generic_installers/config.json +1 -1
- machineconfig/jobs/python_linux_installers/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/jobs/windows/archive/archive_pygraphviz.ps1 +1 -1
- machineconfig/jobs/windows/msc/cli_agents.bat +0 -0
- machineconfig/jobs/windows/msc/cli_agents.ps1 +0 -0
- machineconfig/jobs/windows/start_terminal.ps1 +1 -1
- machineconfig/profile/create.py +38 -26
- machineconfig/profile/create_hardlinks.py +29 -20
- machineconfig/profile/shell.py +56 -32
- machineconfig/scripts/__init__.py +0 -2
- machineconfig/scripts/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/scripts/cloud/init.sh +2 -2
- machineconfig/scripts/linux/checkout_versions +1 -1
- machineconfig/scripts/linux/choose_wezterm_theme +1 -1
- machineconfig/scripts/linux/cloud_copy +1 -1
- machineconfig/scripts/linux/cloud_manager +1 -1
- machineconfig/scripts/linux/cloud_mount +1 -1
- machineconfig/scripts/linux/cloud_repo_sync +1 -1
- machineconfig/scripts/linux/cloud_sync +1 -1
- machineconfig/scripts/linux/croshell +1 -1
- machineconfig/scripts/linux/devops +7 -7
- machineconfig/scripts/linux/fire +1 -1
- machineconfig/scripts/linux/fire_agents +3 -2
- machineconfig/scripts/linux/ftpx +1 -1
- machineconfig/scripts/linux/gh_models +1 -1
- machineconfig/scripts/linux/kill_process +1 -1
- machineconfig/scripts/linux/mcinit +1 -1
- machineconfig/scripts/linux/repos +1 -1
- machineconfig/scripts/linux/scheduler +1 -1
- machineconfig/scripts/linux/start_slidev +1 -1
- machineconfig/scripts/linux/start_terminals +1 -1
- machineconfig/scripts/linux/url2md +1 -1
- machineconfig/scripts/linux/warp-cli.sh +122 -0
- machineconfig/scripts/linux/wifi_conn +1 -1
- machineconfig/scripts/python/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops_devapps_install.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops_update_repos.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/fire_agents.cpython-313.pyc +0 -0
- machineconfig/scripts/python/ai/__init__.py +0 -0
- machineconfig/scripts/python/ai/generate_files.py +83 -0
- machineconfig/scripts/python/ai/instructions/python/dev.instructions.md +2 -2
- machineconfig/scripts/python/ai/mcinit.py +14 -7
- machineconfig/scripts/python/ai/scripts/lint_and_type_check.sh +10 -5
- machineconfig/scripts/python/archive/tmate_conn.py +5 -5
- machineconfig/scripts/python/archive/tmate_start.py +7 -7
- machineconfig/scripts/python/choose_wezterm_theme.py +35 -32
- machineconfig/scripts/python/cloud_copy.py +23 -14
- machineconfig/scripts/python/cloud_mount.py +36 -24
- machineconfig/scripts/python/cloud_repo_sync.py +40 -27
- machineconfig/scripts/python/cloud_sync.py +4 -4
- machineconfig/scripts/python/croshell.py +40 -29
- machineconfig/scripts/python/devops.py +45 -27
- machineconfig/scripts/python/devops_add_identity.py +15 -25
- machineconfig/scripts/python/devops_add_ssh_key.py +8 -8
- machineconfig/scripts/python/devops_backup_retrieve.py +18 -16
- machineconfig/scripts/python/devops_devapps_install.py +25 -20
- machineconfig/scripts/python/devops_update_repos.py +232 -59
- machineconfig/scripts/python/dotfile.py +17 -15
- machineconfig/scripts/python/fire_agents.py +48 -22
- machineconfig/scripts/python/fire_jobs.py +93 -58
- machineconfig/scripts/python/ftpx.py +26 -15
- machineconfig/scripts/python/get_zellij_cmd.py +8 -7
- machineconfig/scripts/python/helpers/cloud_helpers.py +33 -28
- machineconfig/scripts/python/helpers/helpers2.py +27 -16
- machineconfig/scripts/python/helpers/helpers4.py +45 -32
- machineconfig/scripts/python/helpers/helpers5.py +1 -1
- machineconfig/scripts/python/helpers/repo_sync_helpers.py +32 -10
- machineconfig/scripts/python/mount_nfs.py +9 -16
- machineconfig/scripts/python/mount_nw_drive.py +10 -5
- machineconfig/scripts/python/mount_ssh.py +9 -7
- machineconfig/scripts/python/repos.py +216 -58
- machineconfig/scripts/python/snapshot.py +0 -1
- machineconfig/scripts/python/start_slidev.py +11 -6
- machineconfig/scripts/python/start_terminals.py +22 -16
- machineconfig/scripts/python/viewer_template.py +0 -1
- machineconfig/scripts/python/wifi_conn.py +49 -75
- machineconfig/scripts/python/wsl_windows_transfer.py +9 -7
- machineconfig/scripts/windows/checkout_version.ps1 +1 -3
- machineconfig/scripts/windows/choose_wezterm_theme.ps1 +1 -3
- machineconfig/scripts/windows/cloud_copy.ps1 +2 -6
- machineconfig/scripts/windows/cloud_manager.ps1 +1 -1
- machineconfig/scripts/windows/cloud_repo_sync.ps1 +1 -2
- machineconfig/scripts/windows/cloud_sync.ps1 +2 -2
- machineconfig/scripts/windows/croshell.ps1 +2 -2
- machineconfig/scripts/windows/devops.ps1 +1 -4
- machineconfig/scripts/windows/dotfile.ps1 +1 -3
- machineconfig/scripts/windows/fire.ps1 +1 -1
- machineconfig/scripts/windows/ftpx.ps1 +2 -2
- machineconfig/scripts/windows/gpt.ps1 +1 -1
- machineconfig/scripts/windows/kill_process.ps1 +1 -2
- machineconfig/scripts/windows/mcinit.ps1 +1 -1
- machineconfig/scripts/windows/mount_nfs.ps1 +1 -1
- machineconfig/scripts/windows/mount_ssh.ps1 +1 -1
- machineconfig/scripts/windows/pomodoro.ps1 +1 -1
- machineconfig/scripts/windows/py2exe.ps1 +1 -3
- machineconfig/scripts/windows/repos.ps1 +1 -1
- machineconfig/scripts/windows/scheduler.ps1 +1 -1
- machineconfig/scripts/windows/snapshot.ps1 +2 -2
- machineconfig/scripts/windows/start_slidev.ps1 +1 -1
- machineconfig/scripts/windows/start_terminals.ps1 +1 -1
- machineconfig/scripts/windows/wifi_conn.ps1 +1 -1
- machineconfig/scripts/windows/wsl_windows_transfer.ps1 +1 -3
- machineconfig/settings/lf/linux/lfrc +2 -1
- machineconfig/settings/linters/.ruff_cache/.gitignore +2 -0
- machineconfig/settings/linters/.ruff_cache/CACHEDIR.TAG +1 -0
- machineconfig/settings/lvim/windows/archive/config_additional.lua +1 -1
- machineconfig/settings/svim/linux/init.toml +1 -1
- machineconfig/settings/svim/windows/init.toml +1 -1
- machineconfig/setup_linux/web_shortcuts/croshell.sh +3 -52
- machineconfig/setup_linux/web_shortcuts/interactive.sh +6 -6
- machineconfig/setup_linux/web_shortcuts/ssh.sh +0 -4
- machineconfig/setup_windows/web_shortcuts/all.ps1 +2 -2
- machineconfig/setup_windows/web_shortcuts/ascii_art.ps1 +1 -1
- machineconfig/setup_windows/web_shortcuts/croshell.ps1 +1 -1
- machineconfig/setup_windows/web_shortcuts/interactive.ps1 +5 -5
- machineconfig/setup_windows/wt_and_pwsh/install_fonts.ps1 +51 -15
- machineconfig/setup_windows/wt_and_pwsh/set_pwsh_theme.py +58 -13
- machineconfig/setup_windows/wt_and_pwsh/set_wt_settings.py +45 -37
- machineconfig/utils/ai/generate_file_checklist.py +8 -10
- machineconfig/utils/ai/url2md.py +4 -2
- machineconfig/utils/cloud/onedrive/setup_oauth.py +1 -0
- machineconfig/utils/cloud/onedrive/transaction.py +63 -98
- machineconfig/utils/code.py +62 -41
- machineconfig/utils/installer.py +29 -35
- machineconfig/utils/installer_utils/installer_abc.py +11 -11
- machineconfig/utils/installer_utils/installer_class.py +155 -74
- machineconfig/utils/links.py +112 -31
- machineconfig/utils/notifications.py +211 -0
- machineconfig/utils/options.py +41 -42
- machineconfig/utils/path.py +13 -6
- machineconfig/utils/path_reduced.py +614 -311
- machineconfig/utils/procs.py +48 -42
- machineconfig/utils/scheduling.py +0 -1
- machineconfig/utils/source_of_truth.py +27 -0
- machineconfig/utils/ssh.py +146 -85
- machineconfig/utils/terminal.py +84 -37
- machineconfig/utils/upgrade_packages.py +91 -0
- machineconfig/utils/utils2.py +39 -50
- machineconfig/utils/utils5.py +195 -116
- machineconfig/utils/ve.py +13 -5
- {machineconfig-2.0.dist-info → machineconfig-2.2.dist-info}/METADATA +14 -13
- {machineconfig-2.0.dist-info → machineconfig-2.2.dist-info}/RECORD +212 -237
- machineconfig/jobs/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/jobs/python/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/jobs/python/__pycache__/python_ve_symlink.cpython-311.pyc +0 -0
- machineconfig/jobs/python/archive/python_tools.txt +0 -12
- machineconfig/jobs/python/vscode/__pycache__/select_interpreter.cpython-311.pyc +0 -0
- machineconfig/jobs/python_custom_installers/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/jobs/python_generic_installers/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/jobs/python_generic_installers/update.py +0 -3
- machineconfig/jobs/python_linux_installers/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/profile/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/profile/__pycache__/create.cpython-311.pyc +0 -0
- machineconfig/profile/__pycache__/shell.cpython-311.pyc +0 -0
- machineconfig/scripts/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/scripts/linux/activate_ve +0 -87
- machineconfig/scripts/python/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/cloud_copy.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/cloud_mount.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/cloud_sync.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/croshell.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops_backup_retrieve.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops_devapps_install.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops_update_repos.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/fire_agents.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/fire_jobs.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/fire_jobs.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/get_zellij_cmd.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/repos.cpython-311.pyc +0 -0
- machineconfig/scripts/python/ai/__pycache__/init.cpython-311.pyc +0 -0
- machineconfig/scripts/python/ai/__pycache__/mcinit.cpython-311.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/cloud_helpers.cpython-311.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/helpers2.cpython-311.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/helpers4.cpython-311.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/helpers4.cpython-313.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/repo_sync_helpers.cpython-311.pyc +0 -0
- machineconfig/scripts/windows/activate_ve.ps1 +0 -54
- machineconfig/setup_linux/web_shortcuts/all.sh +0 -48
- machineconfig/setup_linux/web_shortcuts/update_system.sh +0 -48
- machineconfig/utils/utils.py +0 -95
- /machineconfig/setup_linux/web_shortcuts/{tmp.sh → android.sh} +0 -0
- {machineconfig-2.0.dist-info → machineconfig-2.2.dist-info}/WHEEL +0 -0
- {machineconfig-2.0.dist-info → machineconfig-2.2.dist-info}/top_level.txt +0 -0
machineconfig/utils/procs.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"""Procs
|
|
2
|
-
|
|
1
|
+
"""Procs"""
|
|
2
|
+
|
|
3
3
|
import psutil
|
|
4
4
|
from tqdm import tqdm
|
|
5
5
|
from pytz import timezone
|
|
6
|
-
from machineconfig.utils.
|
|
6
|
+
from machineconfig.utils.options import display_options
|
|
7
7
|
from typing import Optional, Any
|
|
8
8
|
from rich.console import Console
|
|
9
9
|
from rich.panel import Panel
|
|
@@ -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 = [{
|
|
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(
|
|
61
|
-
create_time_local = create_time_utc.astimezone(timezone(
|
|
62
|
-
|
|
63
|
-
process_info.append(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
|
74
77
|
|
|
75
78
|
# Sort by memory usage (descending)
|
|
76
|
-
process_info.sort(key=lambda x: x[
|
|
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
|
|
|
@@ -83,7 +86,7 @@ class ProcessManager:
|
|
|
83
86
|
return ""
|
|
84
87
|
|
|
85
88
|
# Create header
|
|
86
|
-
_headers = [
|
|
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
|
|
|
@@ -91,9 +94,9 @@ class ProcessManager:
|
|
|
91
94
|
|
|
92
95
|
for process in self.data:
|
|
93
96
|
# Format create_time as string
|
|
94
|
-
create_time_str = process[
|
|
97
|
+
create_time_str = process["create_time"].strftime("%Y-%m-%d %H:%M:%S")
|
|
95
98
|
# Truncate command if too long
|
|
96
|
-
command = process[
|
|
99
|
+
command = process["command"][:47] + "..." if len(process["command"]) > 50 else process["command"]
|
|
97
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)
|
|
@@ -123,7 +126,7 @@ class ProcessManager:
|
|
|
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[
|
|
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: ")
|
|
@@ -132,7 +135,7 @@ class ProcessManager:
|
|
|
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[
|
|
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):
|
|
@@ -141,12 +144,12 @@ class ProcessManager:
|
|
|
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[
|
|
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[
|
|
149
|
+
filtered_processes.sort(key=lambda x: x["create_time"])
|
|
147
150
|
|
|
148
151
|
print(f"🎯 Found {len(filtered_processes)} processes matching name: '{name}'")
|
|
149
|
-
self.kill(pids=[p[
|
|
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,19 +158,22 @@ 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(
|
|
159
|
-
if names is None:
|
|
160
|
-
|
|
161
|
-
if
|
|
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 = []
|
|
162
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[
|
|
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[
|
|
170
|
-
print(f
|
|
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
178
|
else:
|
|
173
179
|
print(f'❓ No process named "{name}" found')
|
|
@@ -181,13 +187,13 @@ class ProcessManager:
|
|
|
181
187
|
print(f'💀 Killed process with PID {pid} and name "{proc_name}". It lived {proc_lifetime}. RIP 🪦💐')
|
|
182
188
|
killed_count += 1
|
|
183
189
|
except psutil.NoSuchProcess:
|
|
184
|
-
print(f
|
|
190
|
+
print(f"❓ No process with PID {pid} found")
|
|
185
191
|
|
|
186
192
|
for command in commands:
|
|
187
|
-
matching_processes = [p for p in self.data if command in p[
|
|
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[
|
|
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
199
|
else:
|
|
@@ -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(
|
|
205
|
-
create_time_local = create_time_utc.astimezone(timezone(
|
|
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
215
|
|
|
210
|
-
now_local = datetime.now(tz=timezone(
|
|
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__ ==
|
|
233
|
+
if __name__ == "__main__":
|
|
228
234
|
pass
|
|
@@ -284,7 +284,6 @@
|
|
|
284
284
|
|
|
285
285
|
# print(f"Task: {task.name}")
|
|
286
286
|
|
|
287
|
-
# shell_script = get_shell_script_executing_python_file(python_file=str(task.task_root.joinpath("task.py")), ve_name=task.venv)
|
|
288
287
|
# shell_script_root = PathExtended.tmp().joinpath(f"tmp_scripts/scheduler/{task.name}")
|
|
289
288
|
# shell_script_root.mkdir(parents=True, exist_ok=True)
|
|
290
289
|
# try:
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Utils
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import machineconfig
|
|
6
|
+
import platform
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
LIBRARY_ROOT = Path(machineconfig.__file__).resolve().parent
|
|
10
|
+
REPO_ROOT = LIBRARY_ROOT.parent.parent
|
|
11
|
+
PROGRAM_PATH = Path(Path.home().joinpath("tmp_results", "shells", "python_return_command").__str__() + (".ps1" if platform.system() == "Windows" else ".sh"))
|
|
12
|
+
CONFIG_PATH = Path.home().joinpath(".config/machineconfig")
|
|
13
|
+
DEFAULTS_PATH = Path.home().joinpath("dotfiles/machineconfig/defaults.ini")
|
|
14
|
+
|
|
15
|
+
INSTALL_VERSION_ROOT = CONFIG_PATH.joinpath("cli_tools_installers/versions")
|
|
16
|
+
INSTALL_TMP_DIR = Path.home().joinpath("tmp_results", "tmp_installers")
|
|
17
|
+
|
|
18
|
+
# LINUX_INSTALL_PATH = '/usr/local/bin'
|
|
19
|
+
# LINUX_INSTALL_PATH = '~/.local/bin'
|
|
20
|
+
LINUX_INSTALL_PATH = Path.home().joinpath(".local/bin").__str__()
|
|
21
|
+
WINDOWS_INSTALL_PATH = Path.home().joinpath("AppData/Local/Microsoft/WindowsApps").__str__()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
if __name__ == "__main__":
|
|
25
|
+
# import typer
|
|
26
|
+
# typer.run(check_tool_exists)
|
|
27
|
+
pass
|