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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
# """
|
|
3
2
|
# Runner
|
|
4
3
|
# """
|
|
@@ -124,7 +123,6 @@
|
|
|
124
123
|
# )
|
|
125
124
|
|
|
126
125
|
|
|
127
|
-
|
|
128
126
|
# @dataclass
|
|
129
127
|
# class RemoteMachineConfig:
|
|
130
128
|
# # conn
|
|
@@ -179,6 +177,5 @@
|
|
|
179
177
|
# except (FileNotFoundError, KeyError, IndexError) as err: raise ValueError(f"Email config name is not provided. 🤷♂️ & default could not be read @ `{DEFAULTS_PATH}`") from err
|
|
180
178
|
|
|
181
179
|
|
|
182
|
-
|
|
183
180
|
# if __name__ == '__main__':
|
|
184
181
|
# pass
|
|
@@ -144,7 +144,6 @@
|
|
|
144
144
|
# echo "~~~~~~~~~~~~~~~~SHELL START~~~~~~~~~~~~~~~"
|
|
145
145
|
# {'~/scripts/devops -w update' if self.config.update_essential_repos else ''}
|
|
146
146
|
# {f'cd {P(self.job_params.repo_path_rh).collapseuser().as_posix()}'}
|
|
147
|
-
# . activate_ve {ve_name}
|
|
148
147
|
# {'git pull' if self.config.update_repo else ''}
|
|
149
148
|
# {'pip install -e .' if self.config.install_repo else ''}
|
|
150
149
|
# echo "~~~~~~~~~~~~~~~~SHELL END ~~~~~~~~~~~~~~~"
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
"""ZT
|
|
3
|
-
"""
|
|
1
|
+
"""ZT"""
|
|
4
2
|
|
|
5
3
|
import socket
|
|
6
|
-
from machineconfig.utils.
|
|
7
|
-
from machineconfig.utils.
|
|
4
|
+
from machineconfig.utils.options import choose_ssh_host
|
|
5
|
+
from machineconfig.utils.code import write_shell_script_to_default_program_path
|
|
6
|
+
from machineconfig.utils.path_reduced import PathExtended as PathExtended
|
|
8
7
|
|
|
9
8
|
prefix = """
|
|
10
9
|
|
|
@@ -57,5 +56,5 @@ def launch_from_ssh_config():
|
|
|
57
56
|
return None
|
|
58
57
|
|
|
59
58
|
|
|
60
|
-
if __name__ ==
|
|
59
|
+
if __name__ == "__main__":
|
|
61
60
|
launch_from_ssh_config()
|
|
@@ -13,12 +13,8 @@ from rich import box
|
|
|
13
13
|
|
|
14
14
|
console = Console()
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
description: Optional[str] = None,
|
|
19
|
-
show_progress: bool = True,
|
|
20
|
-
timeout: Optional[int] = None
|
|
21
|
-
) -> Dict[str, Any]:
|
|
16
|
+
|
|
17
|
+
def run_enhanced_command(command: str, description: Optional[str] = None, show_progress: bool = True, timeout: Optional[int] = None) -> Dict[str, Any]:
|
|
22
18
|
"""
|
|
23
19
|
Run a command with enhanced Rich formatting and user feedback.
|
|
24
20
|
|
|
@@ -37,31 +33,14 @@ def run_enhanced_command(
|
|
|
37
33
|
|
|
38
34
|
try:
|
|
39
35
|
if show_progress:
|
|
40
|
-
with Progress(
|
|
41
|
-
SpinnerColumn(),
|
|
42
|
-
TextColumn("[progress.description]{task.description}"),
|
|
43
|
-
console=console,
|
|
44
|
-
transient=True
|
|
45
|
-
) as progress:
|
|
36
|
+
with Progress(SpinnerColumn(), TextColumn("[progress.description]{task.description}"), console=console, transient=True) as progress:
|
|
46
37
|
task = progress.add_task(f"[cyan]{description}[/cyan]", total=None)
|
|
47
38
|
|
|
48
|
-
result = subprocess.run(
|
|
49
|
-
command,
|
|
50
|
-
shell=True,
|
|
51
|
-
capture_output=True,
|
|
52
|
-
text=True,
|
|
53
|
-
timeout=timeout
|
|
54
|
-
)
|
|
39
|
+
result = subprocess.run(command, shell=True, capture_output=True, text=True, timeout=timeout)
|
|
55
40
|
|
|
56
41
|
progress.update(task, completed=True)
|
|
57
42
|
else:
|
|
58
|
-
result = subprocess.run(
|
|
59
|
-
command,
|
|
60
|
-
shell=True,
|
|
61
|
-
capture_output=True,
|
|
62
|
-
text=True,
|
|
63
|
-
timeout=timeout
|
|
64
|
-
)
|
|
43
|
+
result = subprocess.run(command, shell=True, capture_output=True, text=True, timeout=timeout)
|
|
65
44
|
|
|
66
45
|
# Enhanced output processing
|
|
67
46
|
stdout = result.stdout.strip() if result.stdout else ""
|
|
@@ -75,8 +54,7 @@ def run_enhanced_command(
|
|
|
75
54
|
console.print(f"[bold red]🗑️ Session[/bold red] [yellow]'{session_name}'[/yellow] [red]successfully deleted[/red]")
|
|
76
55
|
|
|
77
56
|
if "zellij layout is running" in stdout:
|
|
78
|
-
console.print(stdout.replace("zellij layout is running @",
|
|
79
|
-
"[bold green]🚀 Zellij layout is running[/bold green] [yellow]@[/yellow]"))
|
|
57
|
+
console.print(stdout.replace("zellij layout is running @", "[bold green]🚀 Zellij layout is running[/bold green] [yellow]@[/yellow]"))
|
|
80
58
|
|
|
81
59
|
# Handle pseudo-terminal warnings with less alarming appearance
|
|
82
60
|
if "Pseudo-terminal will not be allocated" in stderr:
|
|
@@ -86,43 +64,26 @@ def run_enhanced_command(
|
|
|
86
64
|
if result.returncode == 0:
|
|
87
65
|
if stdout and not any(msg in stdout for msg in ["Session:", "zellij layout is running"]):
|
|
88
66
|
console.print(f"[green]{stdout}[/green]")
|
|
89
|
-
return {
|
|
90
|
-
"success": True,
|
|
91
|
-
"returncode": result.returncode,
|
|
92
|
-
"stdout": stdout,
|
|
93
|
-
"stderr": stderr
|
|
94
|
-
}
|
|
67
|
+
return {"success": True, "returncode": result.returncode, "stdout": stdout, "stderr": stderr}
|
|
95
68
|
else:
|
|
96
69
|
if stderr:
|
|
97
70
|
console.print(f"[bold red]Error:[/bold red] [red]{stderr}[/red]")
|
|
98
|
-
return {
|
|
99
|
-
"success": False,
|
|
100
|
-
"returncode": result.returncode,
|
|
101
|
-
"stdout": stdout,
|
|
102
|
-
"stderr": stderr
|
|
103
|
-
}
|
|
71
|
+
return {"success": False, "returncode": result.returncode, "stdout": stdout, "stderr": stderr}
|
|
104
72
|
|
|
105
73
|
except subprocess.TimeoutExpired:
|
|
106
74
|
console.print(f"[bold red]⏰ Command timed out after {timeout} seconds[/bold red]")
|
|
107
|
-
return {
|
|
108
|
-
"success": False,
|
|
109
|
-
"error": "Timeout",
|
|
110
|
-
"timeout": timeout
|
|
111
|
-
}
|
|
75
|
+
return {"success": False, "error": "Timeout", "timeout": timeout}
|
|
112
76
|
except Exception as e:
|
|
113
77
|
console.print(f"[bold red]💥 Unexpected error:[/bold red] [red]{str(e)}[/red]")
|
|
114
|
-
return {
|
|
115
|
-
|
|
116
|
-
"error": str(e)
|
|
117
|
-
}
|
|
78
|
+
return {"success": False, "error": str(e)}
|
|
79
|
+
|
|
118
80
|
|
|
119
81
|
def enhanced_zellij_session_start(session_name: str, layout_path: str) -> Dict[str, Any]:
|
|
120
82
|
"""
|
|
121
83
|
Start a Zellij session with enhanced visual feedback.
|
|
122
84
|
"""
|
|
123
85
|
console.print()
|
|
124
|
-
console.print(Panel.fit(f"🚀 Starting Zellij Session: [bold cyan]{session_name}[/bold cyan]",
|
|
125
|
-
style="green", box=box.ROUNDED))
|
|
86
|
+
console.print(Panel.fit(f"🚀 Starting Zellij Session: [bold cyan]{session_name}[/bold cyan]", style="green", box=box.ROUNDED))
|
|
126
87
|
|
|
127
88
|
# Delete existing session first (suppress normal output)
|
|
128
89
|
delete_cmd = f"zellij delete-session --force {session_name}"
|
|
@@ -130,7 +91,7 @@ def enhanced_zellij_session_start(session_name: str, layout_path: str) -> Dict[s
|
|
|
130
91
|
delete_cmd,
|
|
131
92
|
f"Cleaning up existing session '{session_name}'",
|
|
132
93
|
show_progress=False,
|
|
133
|
-
timeout=5 # Quick timeout for cleanup
|
|
94
|
+
timeout=5, # Quick timeout for cleanup
|
|
134
95
|
)
|
|
135
96
|
|
|
136
97
|
# Start new session (use -b for background to avoid hanging)
|
|
@@ -139,18 +100,17 @@ def enhanced_zellij_session_start(session_name: str, layout_path: str) -> Dict[s
|
|
|
139
100
|
start_cmd,
|
|
140
101
|
f"Starting session '{session_name}' with layout",
|
|
141
102
|
show_progress=False,
|
|
142
|
-
timeout=10 # Add timeout to prevent hanging
|
|
103
|
+
timeout=10, # Add timeout to prevent hanging
|
|
143
104
|
)
|
|
144
105
|
|
|
145
106
|
if start_result["success"]:
|
|
146
|
-
console.print(Panel(f"[bold green]✅ Session '{session_name}' is now running![/bold green]\n[dim]Layout: {layout_path}[/dim]",
|
|
147
|
-
style="green", title="🎉 Success"))
|
|
107
|
+
console.print(Panel(f"[bold green]✅ Session '{session_name}' is now running![/bold green]\n[dim]Layout: {layout_path}[/dim]", style="green", title="🎉 Success"))
|
|
148
108
|
else:
|
|
149
|
-
console.print(Panel(f"[bold red]❌ Failed to start session '{session_name}'[/bold red]\n[red]{start_result.get('stderr', 'Unknown error')}[/red]",
|
|
150
|
-
style="red", title="💥 Error"))
|
|
109
|
+
console.print(Panel(f"[bold red]❌ Failed to start session '{session_name}'[/bold red]\n[red]{start_result.get('stderr', 'Unknown error')}[/red]", style="red", title="💥 Error"))
|
|
151
110
|
|
|
152
111
|
return start_result
|
|
153
112
|
|
|
113
|
+
|
|
154
114
|
if __name__ == "__main__":
|
|
155
115
|
# Demo the enhanced command execution
|
|
156
116
|
console.print(Panel.fit("🎨 Enhanced Command Execution Demo", style="bold cyan"))
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Windows Terminal local layout generator and session manager.
|
|
4
4
|
Equivalent to zellij_local.py but for Windows Terminal.
|
|
5
5
|
"""
|
|
6
|
+
|
|
6
7
|
import shlex
|
|
7
8
|
import subprocess
|
|
8
9
|
import random
|
|
@@ -26,13 +27,14 @@ class WTLayoutGenerator:
|
|
|
26
27
|
@staticmethod
|
|
27
28
|
def _generate_random_suffix(length: int = 8) -> str:
|
|
28
29
|
"""Generate a random string suffix for unique script file names."""
|
|
29
|
-
return
|
|
30
|
+
return "".join(random.choices(string.ascii_lowercase + string.digits, k=length))
|
|
30
31
|
|
|
31
32
|
@staticmethod
|
|
32
33
|
def _parse_command(command: str) -> tuple[str, List[str]]:
|
|
33
34
|
try:
|
|
34
35
|
parts = shlex.split(command)
|
|
35
|
-
if not parts:
|
|
36
|
+
if not parts:
|
|
37
|
+
raise ValueError("Empty command provided")
|
|
36
38
|
return parts[0], parts[1:] if len(parts) > 1 else []
|
|
37
39
|
except ValueError as e:
|
|
38
40
|
logger.error(f"Error parsing command '{command}': {e}")
|
|
@@ -44,7 +46,7 @@ class WTLayoutGenerator:
|
|
|
44
46
|
"""Escape text for use in Windows Terminal commands."""
|
|
45
47
|
# Windows Terminal uses PowerShell-style escaping
|
|
46
48
|
text = text.replace('"', '""') # Escape quotes for PowerShell
|
|
47
|
-
if
|
|
49
|
+
if " " in text or ";" in text or "&" in text or "|" in text:
|
|
48
50
|
return f'"{text}"'
|
|
49
51
|
return text
|
|
50
52
|
|
|
@@ -52,9 +54,9 @@ class WTLayoutGenerator:
|
|
|
52
54
|
def _create_tab_command(tab_name: str, cwd: str, command: str, is_first_tab: bool = False) -> str:
|
|
53
55
|
"""Create a Windows Terminal tab command string."""
|
|
54
56
|
# Convert paths to Windows format if needed
|
|
55
|
-
if cwd.startswith(
|
|
56
|
-
cwd = cwd.replace(
|
|
57
|
-
elif cwd ==
|
|
57
|
+
if cwd.startswith("~/"):
|
|
58
|
+
cwd = cwd.replace("~/", f"{Path.home()}/")
|
|
59
|
+
elif cwd == "~":
|
|
58
60
|
cwd = str(Path.home())
|
|
59
61
|
|
|
60
62
|
# Build the wt command parts
|
|
@@ -117,7 +119,7 @@ REM Windows Terminal layout for {self.session_name}
|
|
|
117
119
|
script_file.write_text(text, encoding="utf-8")
|
|
118
120
|
|
|
119
121
|
# Also create PowerShell script for better command handling
|
|
120
|
-
ps1_file = script_file.with_suffix(
|
|
122
|
+
ps1_file = script_file.with_suffix(".ps1")
|
|
121
123
|
text = f"""# Windows Terminal layout for {self.session_name}
|
|
122
124
|
# Generated with random suffix: {random_suffix}
|
|
123
125
|
{wt_command}
|
|
@@ -179,12 +181,7 @@ REM Windows Terminal layout for {self.session_name}
|
|
|
179
181
|
def check_wt_session_status(session_name: str) -> Dict[str, Any]:
|
|
180
182
|
try:
|
|
181
183
|
# Check for Windows Terminal processes
|
|
182
|
-
wt_check_cmd = [
|
|
183
|
-
"powershell", "-Command",
|
|
184
|
-
"Get-Process -Name 'WindowsTerminal' -ErrorAction SilentlyContinue | "
|
|
185
|
-
"Select-Object Id, ProcessName, StartTime, MainWindowTitle | "
|
|
186
|
-
"ConvertTo-Json -Depth 2"
|
|
187
|
-
]
|
|
184
|
+
wt_check_cmd = ["powershell", "-Command", "Get-Process -Name 'WindowsTerminal' -ErrorAction SilentlyContinue | Select-Object Id, ProcessName, StartTime, MainWindowTitle | ConvertTo-Json -Depth 2"]
|
|
188
185
|
|
|
189
186
|
result = subprocess.run(wt_check_cmd, capture_output=True, text=True, timeout=10)
|
|
190
187
|
|
|
@@ -193,6 +190,7 @@ REM Windows Terminal layout for {self.session_name}
|
|
|
193
190
|
if output and output != "":
|
|
194
191
|
try:
|
|
195
192
|
import json
|
|
193
|
+
|
|
196
194
|
processes = json.loads(output)
|
|
197
195
|
if not isinstance(processes, list):
|
|
198
196
|
processes = [processes]
|
|
@@ -204,75 +202,37 @@ REM Windows Terminal layout for {self.session_name}
|
|
|
204
202
|
if session_name in window_title or not window_title:
|
|
205
203
|
session_windows.append(proc)
|
|
206
204
|
|
|
207
|
-
return {
|
|
208
|
-
"wt_running": True,
|
|
209
|
-
"session_exists": len(session_windows) > 0,
|
|
210
|
-
"session_name": session_name,
|
|
211
|
-
"all_windows": processes,
|
|
212
|
-
"session_windows": session_windows
|
|
213
|
-
}
|
|
205
|
+
return {"wt_running": True, "session_exists": len(session_windows) > 0, "session_name": session_name, "all_windows": processes, "session_windows": session_windows}
|
|
214
206
|
except Exception as e:
|
|
215
|
-
return {
|
|
216
|
-
"wt_running": True,
|
|
217
|
-
"session_exists": False,
|
|
218
|
-
"error": f"Failed to parse process info: {e}",
|
|
219
|
-
"session_name": session_name
|
|
220
|
-
}
|
|
207
|
+
return {"wt_running": True, "session_exists": False, "error": f"Failed to parse process info: {e}", "session_name": session_name}
|
|
221
208
|
else:
|
|
222
|
-
return {
|
|
223
|
-
"wt_running": False,
|
|
224
|
-
"session_exists": False,
|
|
225
|
-
"session_name": session_name,
|
|
226
|
-
"all_windows": []
|
|
227
|
-
}
|
|
209
|
+
return {"wt_running": False, "session_exists": False, "session_name": session_name, "all_windows": []}
|
|
228
210
|
else:
|
|
229
|
-
return {
|
|
230
|
-
"wt_running": False,
|
|
231
|
-
"error": result.stderr,
|
|
232
|
-
"session_name": session_name
|
|
233
|
-
}
|
|
211
|
+
return {"wt_running": False, "error": result.stderr, "session_name": session_name}
|
|
234
212
|
|
|
235
213
|
except subprocess.TimeoutExpired:
|
|
236
|
-
return {
|
|
237
|
-
"wt_running": False,
|
|
238
|
-
"error": "Timeout while checking Windows Terminal processes",
|
|
239
|
-
"session_name": session_name
|
|
240
|
-
}
|
|
214
|
+
return {"wt_running": False, "error": "Timeout while checking Windows Terminal processes", "session_name": session_name}
|
|
241
215
|
except FileNotFoundError:
|
|
242
|
-
return {
|
|
243
|
-
"wt_running": False,
|
|
244
|
-
"error": "PowerShell not found in PATH",
|
|
245
|
-
"session_name": session_name
|
|
246
|
-
}
|
|
216
|
+
return {"wt_running": False, "error": "PowerShell not found in PATH", "session_name": session_name}
|
|
247
217
|
except Exception as e:
|
|
248
|
-
return {
|
|
249
|
-
"wt_running": False,
|
|
250
|
-
"error": str(e),
|
|
251
|
-
"session_name": session_name
|
|
252
|
-
}
|
|
218
|
+
return {"wt_running": False, "error": str(e), "session_name": session_name}
|
|
253
219
|
|
|
254
220
|
@staticmethod
|
|
255
221
|
def check_command_status(tab_name: str, tab_config: Dict[str, tuple[str, str]]) -> Dict[str, Any]:
|
|
256
222
|
"""Check if a command is running by looking for processes."""
|
|
257
223
|
if tab_name not in tab_config:
|
|
258
|
-
return {
|
|
259
|
-
"status": "unknown",
|
|
260
|
-
"error": f"Tab '{tab_name}' not found in tracked configuration",
|
|
261
|
-
"running": False,
|
|
262
|
-
"pid": None,
|
|
263
|
-
"command": None
|
|
264
|
-
}
|
|
224
|
+
return {"status": "unknown", "error": f"Tab '{tab_name}' not found in tracked configuration", "running": False, "pid": None, "command": None}
|
|
265
225
|
|
|
266
226
|
_, command = tab_config[tab_name]
|
|
267
227
|
|
|
268
228
|
try:
|
|
269
229
|
# Create PowerShell script to check for processes
|
|
270
230
|
cmd_parts = [part for part in command.split() if len(part) > 2]
|
|
271
|
-
primary_cmd = cmd_parts[0] if cmd_parts else
|
|
231
|
+
primary_cmd = cmd_parts[0] if cmd_parts else ""
|
|
272
232
|
|
|
273
233
|
ps_script = f"""
|
|
274
234
|
$targetCommand = '{command.replace("'", "''")}'
|
|
275
|
-
$cmdParts = @({
|
|
235
|
+
$cmdParts = @({", ".join([f"'{part}'" for part in cmd_parts])})
|
|
276
236
|
$primaryCmd = '{primary_cmd}'
|
|
277
237
|
$currentPid = $PID
|
|
278
238
|
$matchingProcesses = @()
|
|
@@ -314,19 +274,14 @@ Get-Process | ForEach-Object {{
|
|
|
314
274
|
}}
|
|
315
275
|
"""
|
|
316
276
|
|
|
317
|
-
result = subprocess.run(
|
|
318
|
-
["powershell", "-Command", ps_script],
|
|
319
|
-
capture_output=True,
|
|
320
|
-
text=True,
|
|
321
|
-
timeout=15
|
|
322
|
-
)
|
|
277
|
+
result = subprocess.run(["powershell", "-Command", ps_script], capture_output=True, text=True, timeout=15)
|
|
323
278
|
|
|
324
279
|
if result.returncode == 0:
|
|
325
|
-
output_lines = [line.strip() for line in result.stdout.strip().split(
|
|
280
|
+
output_lines = [line.strip() for line in result.stdout.strip().split("\n") if line.strip()]
|
|
326
281
|
matching_processes = []
|
|
327
282
|
|
|
328
283
|
for line in output_lines:
|
|
329
|
-
if line.startswith(
|
|
284
|
+
if line.startswith("{") and line.endswith("}"):
|
|
330
285
|
try:
|
|
331
286
|
proc_info = json.loads(line)
|
|
332
287
|
matching_processes.append(proc_info)
|
|
@@ -334,39 +289,15 @@ Get-Process | ForEach-Object {{
|
|
|
334
289
|
continue
|
|
335
290
|
|
|
336
291
|
if matching_processes:
|
|
337
|
-
return {
|
|
338
|
-
"status": "running",
|
|
339
|
-
"running": True,
|
|
340
|
-
"processes": matching_processes,
|
|
341
|
-
"command": command,
|
|
342
|
-
"tab_name": tab_name
|
|
343
|
-
}
|
|
292
|
+
return {"status": "running", "running": True, "processes": matching_processes, "command": command, "tab_name": tab_name}
|
|
344
293
|
else:
|
|
345
|
-
return {
|
|
346
|
-
"status": "not_running",
|
|
347
|
-
"running": False,
|
|
348
|
-
"processes": [],
|
|
349
|
-
"command": command,
|
|
350
|
-
"tab_name": tab_name
|
|
351
|
-
}
|
|
294
|
+
return {"status": "not_running", "running": False, "processes": [], "command": command, "tab_name": tab_name}
|
|
352
295
|
else:
|
|
353
|
-
return {
|
|
354
|
-
"status": "error",
|
|
355
|
-
"error": f"Command failed: {result.stderr}",
|
|
356
|
-
"running": False,
|
|
357
|
-
"command": command,
|
|
358
|
-
"tab_name": tab_name
|
|
359
|
-
}
|
|
296
|
+
return {"status": "error", "error": f"Command failed: {result.stderr}", "running": False, "command": command, "tab_name": tab_name}
|
|
360
297
|
|
|
361
298
|
except Exception as e:
|
|
362
299
|
logger.error(f"Error checking command status for tab '{tab_name}': {e}")
|
|
363
|
-
return {
|
|
364
|
-
"status": "error",
|
|
365
|
-
"error": str(e),
|
|
366
|
-
"running": False,
|
|
367
|
-
"command": command,
|
|
368
|
-
"tab_name": tab_name
|
|
369
|
-
}
|
|
300
|
+
return {"status": "error", "error": str(e), "running": False, "command": command, "tab_name": tab_name}
|
|
370
301
|
|
|
371
302
|
def get_status_report(self) -> Dict[str, Any]:
|
|
372
303
|
"""Get status report for this layout including Windows Terminal and commands."""
|
|
@@ -379,12 +310,7 @@ Get-Process | ForEach-Object {{
|
|
|
379
310
|
return {
|
|
380
311
|
"wt_session": wt_status,
|
|
381
312
|
"commands": commands_status,
|
|
382
|
-
"summary": {
|
|
383
|
-
"total_commands": total_count,
|
|
384
|
-
"running_commands": running_count,
|
|
385
|
-
"stopped_commands": total_count - running_count,
|
|
386
|
-
"session_healthy": wt_status.get("session_exists", False)
|
|
387
|
-
}
|
|
313
|
+
"summary": {"total_commands": total_count, "running_commands": running_count, "stopped_commands": total_count - running_count, "session_healthy": wt_status.get("session_exists", False)},
|
|
388
314
|
}
|
|
389
315
|
|
|
390
316
|
def print_status_report(self) -> None:
|
|
@@ -439,13 +365,14 @@ def create_wt_layout(tab_config: Dict[str, tuple[str, str]], output_dir: Optiona
|
|
|
439
365
|
generator = WTLayoutGenerator()
|
|
440
366
|
return generator.create_wt_layout(tab_config, output_dir)
|
|
441
367
|
|
|
368
|
+
|
|
442
369
|
def run_wt_layout(tab_config: Dict[str, tuple[str, str]], session_name: Optional[str] = None) -> str:
|
|
443
370
|
"""Create and run a Windows Terminal layout."""
|
|
444
371
|
generator = WTLayoutGenerator()
|
|
445
372
|
script_path = generator.create_wt_layout(tab_config, session_name=session_name)
|
|
446
373
|
|
|
447
374
|
# Execute the script
|
|
448
|
-
cmd = f
|
|
375
|
+
cmd = f'powershell -ExecutionPolicy Bypass -File "{script_path}"'
|
|
449
376
|
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
|
|
450
377
|
|
|
451
378
|
if result.returncode == 0:
|
|
@@ -455,9 +382,10 @@ def run_wt_layout(tab_config: Dict[str, tuple[str, str]], session_name: Optional
|
|
|
455
382
|
logger.error(f"Failed to run Windows Terminal layout: {result.stderr}")
|
|
456
383
|
raise RuntimeError(f"Failed to run layout: {result.stderr}")
|
|
457
384
|
|
|
385
|
+
|
|
458
386
|
def run_command_in_wt_tab(command: str, tab_name: str, cwd: Optional[str]) -> str:
|
|
459
387
|
"""Create a command to run in a new Windows Terminal tab."""
|
|
460
|
-
cwd_part = f
|
|
388
|
+
cwd_part = f'-d "{cwd}"' if cwd else ""
|
|
461
389
|
|
|
462
390
|
return f"""
|
|
463
391
|
echo "Creating new Windows Terminal tab: {tab_name}"
|
|
@@ -467,10 +395,7 @@ wt new-tab --title "{tab_name}" {cwd_part} "{command}"
|
|
|
467
395
|
|
|
468
396
|
if __name__ == "__main__":
|
|
469
397
|
# Example usage
|
|
470
|
-
sample_tabs = {
|
|
471
|
-
"Frontend": ("~/code", "btm"),
|
|
472
|
-
"Monitor": ("~", "lf"),
|
|
473
|
-
}
|
|
398
|
+
sample_tabs = {"Frontend": ("~/code", "btm"), "Monitor": ("~", "lf")}
|
|
474
399
|
|
|
475
400
|
try:
|
|
476
401
|
# Create layout using the generator
|
|
@@ -488,9 +413,10 @@ if __name__ == "__main__":
|
|
|
488
413
|
|
|
489
414
|
# Show how to run the layout
|
|
490
415
|
print("\n▶️ To run this layout, execute:")
|
|
491
|
-
print(f
|
|
416
|
+
print(f' powershell -ExecutionPolicy Bypass -File "{script_path}"')
|
|
492
417
|
|
|
493
418
|
except Exception as e:
|
|
494
419
|
print(f"❌ Error: {e}")
|
|
495
420
|
import traceback
|
|
421
|
+
|
|
496
422
|
traceback.print_exc()
|