machineconfig 2.6__py3-none-any.whl → 2.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of machineconfig might be problematic. Click here for more details.

Files changed (118) hide show
  1. machineconfig/cluster/remote/remote_machine.py +0 -1
  2. machineconfig/cluster/sessions_managers/wt_local.py +1 -1
  3. machineconfig/cluster/sessions_managers/wt_local_manager.py +1 -1
  4. machineconfig/cluster/sessions_managers/wt_remote.py +1 -1
  5. machineconfig/cluster/sessions_managers/wt_remote_manager.py +1 -1
  6. machineconfig/cluster/sessions_managers/wt_utils/layout_generator.py +1 -1
  7. machineconfig/cluster/sessions_managers/wt_utils/process_monitor.py +1 -1
  8. machineconfig/cluster/sessions_managers/wt_utils/status_reporter.py +1 -1
  9. machineconfig/cluster/sessions_managers/zellij_local.py +1 -1
  10. machineconfig/cluster/sessions_managers/zellij_local_manager.py +1 -1
  11. machineconfig/cluster/sessions_managers/zellij_remote.py +1 -1
  12. machineconfig/cluster/sessions_managers/zellij_remote_manager.py +1 -1
  13. machineconfig/cluster/sessions_managers/zellij_utils/example_usage.py +1 -1
  14. machineconfig/cluster/sessions_managers/zellij_utils/layout_generator.py +1 -1
  15. machineconfig/cluster/sessions_managers/zellij_utils/process_monitor.py +1 -1
  16. machineconfig/cluster/sessions_managers/zellij_utils/status_reporter.py +1 -1
  17. machineconfig/jobs/__pycache__/__init__.cpython-313.pyc +0 -0
  18. machineconfig/jobs/python/vscode/sync_code.py +0 -1
  19. machineconfig/jobs/python_generic_installers/__pycache__/__init__.cpython-313.pyc +0 -0
  20. machineconfig/jobs/python_linux_installers/__pycache__/__init__.cpython-313.pyc +0 -0
  21. machineconfig/profile/create.py +8 -16
  22. machineconfig/profile/shell.py +140 -179
  23. machineconfig/scripts/__pycache__/__init__.cpython-313.pyc +0 -0
  24. machineconfig/scripts/linux/choose_wezterm_theme +1 -1
  25. machineconfig/scripts/linux/cloud_copy +1 -1
  26. machineconfig/scripts/linux/cloud_mount +1 -1
  27. machineconfig/scripts/linux/cloud_repo_sync +1 -1
  28. machineconfig/scripts/linux/cloud_sync +1 -1
  29. machineconfig/scripts/linux/croshell +2 -1
  30. machineconfig/scripts/linux/devops +1 -1
  31. machineconfig/scripts/linux/fire +1 -1
  32. machineconfig/scripts/linux/fire_agents +1 -1
  33. machineconfig/scripts/linux/ftpx +1 -1
  34. machineconfig/scripts/linux/gh_models +1 -1
  35. machineconfig/scripts/linux/kill_process +1 -1
  36. machineconfig/scripts/linux/mcinit +1 -1
  37. machineconfig/scripts/linux/mount_nfs +1 -1
  38. machineconfig/scripts/linux/mount_nw_drive +1 -11
  39. machineconfig/scripts/linux/repos +1 -1
  40. machineconfig/scripts/linux/scheduler +1 -1
  41. machineconfig/scripts/linux/start_slidev +1 -1
  42. machineconfig/scripts/linux/start_terminals +1 -1
  43. machineconfig/scripts/linux/wifi_conn +1 -1
  44. machineconfig/scripts/python/__pycache__/__init__.cpython-313.pyc +0 -0
  45. machineconfig/scripts/python/__pycache__/cloud_repo_sync.cpython-313.pyc +0 -0
  46. machineconfig/scripts/python/__pycache__/devops.cpython-313.pyc +0 -0
  47. machineconfig/scripts/python/__pycache__/devops_devapps_install.cpython-313.pyc +0 -0
  48. machineconfig/scripts/python/__pycache__/devops_update_repos.cpython-313.pyc +0 -0
  49. machineconfig/scripts/python/__pycache__/get_zellij_cmd.cpython-313.pyc +0 -0
  50. machineconfig/scripts/python/__pycache__/repos.cpython-313.pyc +0 -0
  51. machineconfig/scripts/python/__pycache__/repos_helper_record.cpython-313.pyc +0 -0
  52. machineconfig/scripts/python/ai/mcinit.py +16 -2
  53. machineconfig/scripts/python/ai/scripts/lint_and_type_check.sh +1 -1
  54. machineconfig/scripts/python/croshell.py +0 -1
  55. machineconfig/scripts/python/devops.py +1 -13
  56. machineconfig/scripts/python/devops_update_repos.py +39 -19
  57. machineconfig/scripts/python/fire_agents.py +1 -1
  58. machineconfig/scripts/python/fire_jobs.py +8 -3
  59. machineconfig/scripts/python/fire_jobs_layout_helper.py +1 -1
  60. machineconfig/scripts/python/helpers/__pycache__/__init__.cpython-313.pyc +0 -0
  61. machineconfig/scripts/python/helpers/__pycache__/repo_sync_helpers.cpython-313.pyc +0 -0
  62. machineconfig/scripts/python/repos.py +10 -227
  63. machineconfig/scripts/python/repos_helper_record.py +193 -0
  64. machineconfig/scripts/windows/choose_wezterm_theme.ps1 +1 -1
  65. machineconfig/scripts/windows/cloud_copy.ps1 +1 -1
  66. machineconfig/scripts/windows/cloud_mount.ps1 +1 -1
  67. machineconfig/scripts/windows/cloud_repo_sync.ps1 +1 -1
  68. machineconfig/scripts/windows/cloud_sync.ps1 +1 -1
  69. machineconfig/scripts/windows/croshell.ps1 +1 -1
  70. machineconfig/scripts/windows/devops.ps1 +1 -29
  71. machineconfig/scripts/windows/dotfile.ps1 +1 -1
  72. machineconfig/scripts/windows/fire.ps1 +1 -45
  73. machineconfig/scripts/windows/ftpx.ps1 +1 -1
  74. machineconfig/scripts/windows/gpt.ps1 +1 -23
  75. machineconfig/scripts/windows/kill_process.ps1 +1 -1
  76. machineconfig/scripts/windows/mcinit.ps1 +1 -1
  77. machineconfig/scripts/windows/mount_ssh.ps1 +1 -1
  78. machineconfig/scripts/windows/pomodoro.ps1 +1 -1
  79. machineconfig/scripts/windows/repos.ps1 +1 -1
  80. machineconfig/scripts/windows/scheduler.ps1 +1 -1
  81. machineconfig/scripts/windows/snapshot.ps1 +1 -1
  82. machineconfig/scripts/windows/start_slidev.ps1 +1 -1
  83. machineconfig/scripts/windows/start_terminals.ps1 +1 -1
  84. machineconfig/scripts/windows/wifi_conn.ps1 +1 -2
  85. machineconfig/settings/shells/pwsh/init.ps1 +0 -4
  86. machineconfig/setup_linux/web_shortcuts/croshell.sh +1 -1
  87. machineconfig/setup_linux/web_shortcuts/interactive.sh +7 -13
  88. machineconfig/setup_windows/web_shortcuts/interactive.ps1 +9 -18
  89. machineconfig/setup_windows/wt_and_pwsh/set_wt_settings.py +1 -66
  90. machineconfig/utils/links.py +1 -2
  91. machineconfig/utils/options.py +8 -5
  92. machineconfig/utils/procs.py +5 -1
  93. machineconfig/utils/scheduling.py +0 -1
  94. machineconfig/{cluster/sessions_managers → utils/schemas/layouts}/layout_types.py +0 -1
  95. machineconfig/utils/schemas/repos/repos_types.py +28 -0
  96. machineconfig/utils/source_of_truth.py +1 -4
  97. machineconfig/utils/ssh.py +1 -1
  98. {machineconfig-2.6.dist-info → machineconfig-2.7.dist-info}/METADATA +1 -1
  99. {machineconfig-2.6.dist-info → machineconfig-2.7.dist-info}/RECORD +103 -110
  100. {machineconfig-2.6.dist-info → machineconfig-2.7.dist-info}/entry_points.txt +1 -1
  101. machineconfig/jobs/python_custom_installers/__pycache__/__init__.cpython-313.pyc +0 -0
  102. machineconfig/profile/create_hardlinks.py +0 -140
  103. machineconfig/scripts/linux/checkout_versions +0 -2
  104. machineconfig/scripts/linux/cloud_manager +0 -2
  105. machineconfig/scripts/linux/url2md +0 -2
  106. machineconfig/scripts/python/__pycache__/croshell.cpython-313.pyc +0 -0
  107. machineconfig/scripts/windows/checkout_version.ps1 +0 -1
  108. machineconfig/scripts/windows/cloud_manager.ps1 +0 -1
  109. machineconfig/scripts/windows/neofetch.ps1 +0 -2
  110. machineconfig/scripts/windows/wsl_windows_transfer.ps1 +0 -1
  111. machineconfig/settings/__pycache__/__init__.cpython-313.pyc +0 -0
  112. machineconfig/settings/shells/ipy/profiles/default/__pycache__/__init__.cpython-313.pyc +0 -0
  113. machineconfig/settings/shells/ipy/profiles/default/startup/__pycache__/__init__.cpython-313.pyc +0 -0
  114. machineconfig/utils/ai/browser_user_wrapper.py +0 -66
  115. machineconfig/utils/ai/url2md.py +0 -85
  116. /machineconfig/setup_windows/wt_and_pwsh/{set_pwsh_theme.py → install_nerd_fonts.py} +0 -0
  117. {machineconfig-2.6.dist-info → machineconfig-2.7.dist-info}/WHEEL +0 -0
  118. {machineconfig-2.6.dist-info → machineconfig-2.7.dist-info}/top_level.txt +0 -0
@@ -142,7 +142,6 @@
142
142
  # # EXTRA-PLACEHOLDER-PRE
143
143
 
144
144
  # echo "~~~~~~~~~~~~~~~~SHELL START~~~~~~~~~~~~~~~"
145
- # {'~/scripts/devops -w update' if self.config.update_essential_repos else ''}
146
145
  # {f'cd {P(self.job_params.repo_path_rh).collapseuser().as_posix()}'}
147
146
  # {'git pull' if self.config.update_repo else ''}
148
147
  # {'pip install -e .' if self.config.install_repo else ''}
@@ -13,7 +13,7 @@ from typing import Dict, List, Optional, Any
13
13
  from pathlib import Path
14
14
  import logging
15
15
 
16
- from machineconfig.cluster.sessions_managers.layout_types import LayoutConfig, TabConfig
16
+ from machineconfig.utils.schemas.layouts.layout_types import LayoutConfig, TabConfig
17
17
 
18
18
  logging.basicConfig(level=logging.INFO)
19
19
  logger = logging.getLogger(__name__)
@@ -8,7 +8,7 @@ from pathlib import Path
8
8
  from typing import Optional, Dict, List, Any
9
9
  from machineconfig.utils.utils5 import Scheduler
10
10
  from machineconfig.cluster.sessions_managers.wt_local import WTLayoutGenerator
11
- from machineconfig.cluster.sessions_managers.layout_types import LayoutConfig
11
+ from machineconfig.utils.schemas.layouts.layout_types import LayoutConfig
12
12
 
13
13
  logging.basicConfig(level=logging.INFO)
14
14
  logger = logging.getLogger(__name__)
@@ -11,7 +11,7 @@ from machineconfig.cluster.sessions_managers.wt_utils.layout_generator import WT
11
11
  from machineconfig.cluster.sessions_managers.wt_utils.process_monitor import WTProcessMonitor
12
12
  from machineconfig.cluster.sessions_managers.wt_utils.session_manager import WTSessionManager
13
13
  from machineconfig.cluster.sessions_managers.wt_utils.status_reporter import WTStatusReporter
14
- from machineconfig.cluster.sessions_managers.layout_types import TabConfig
14
+ from machineconfig.utils.schemas.layouts.layout_types import TabConfig
15
15
 
16
16
  logging.basicConfig(level=logging.INFO)
17
17
  logger = logging.getLogger(__name__)
@@ -7,7 +7,7 @@ from typing import Optional, Any
7
7
  from machineconfig.utils.utils5 import Scheduler
8
8
  from machineconfig.cluster.sessions_managers.wt_local import run_command_in_wt_tab
9
9
  from machineconfig.cluster.sessions_managers.wt_remote import WTRemoteLayoutGenerator
10
- from machineconfig.cluster.sessions_managers.layout_types import TabConfig
10
+ from machineconfig.utils.schemas.layouts.layout_types import TabConfig
11
11
 
12
12
  TMP_SERIALIZATION_DIR = Path.home().joinpath("tmp_results", "session_manager", "wt", "remote_manager")
13
13
 
@@ -11,7 +11,7 @@ from typing import List, Tuple
11
11
  from pathlib import Path
12
12
  import logging
13
13
 
14
- from machineconfig.cluster.sessions_managers.layout_types import TabConfig
14
+ from machineconfig.utils.schemas.layouts.layout_types import TabConfig
15
15
 
16
16
 
17
17
  logger = logging.getLogger(__name__)
@@ -8,7 +8,7 @@ import json
8
8
  import logging
9
9
  import subprocess
10
10
  from typing import Dict, Any, Optional, List
11
- from machineconfig.cluster.sessions_managers.layout_types import TabConfig
11
+ from machineconfig.utils.schemas.layouts.layout_types import TabConfig
12
12
  from machineconfig.cluster.sessions_managers.wt_utils.remote_executor import WTRemoteExecutor
13
13
 
14
14
  logger = logging.getLogger(__name__)
@@ -7,7 +7,7 @@ import logging
7
7
  from typing import Dict, Any, List
8
8
  from machineconfig.cluster.sessions_managers.wt_utils.process_monitor import WTProcessMonitor
9
9
  from machineconfig.cluster.sessions_managers.wt_utils.session_manager import WTSessionManager
10
- from machineconfig.cluster.sessions_managers.layout_types import TabConfig
10
+ from machineconfig.utils.schemas.layouts.layout_types import TabConfig
11
11
 
12
12
  logger = logging.getLogger(__name__)
13
13
 
@@ -10,7 +10,7 @@ import logging
10
10
 
11
11
  from rich.console import Console
12
12
 
13
- from machineconfig.cluster.sessions_managers.layout_types import LayoutConfig, TabConfig
13
+ from machineconfig.utils.schemas.layouts.layout_types import LayoutConfig, TabConfig
14
14
 
15
15
  logging.basicConfig(level=logging.INFO)
16
16
  logger = logging.getLogger(__name__)
@@ -12,7 +12,7 @@ from rich.console import Console
12
12
 
13
13
  from machineconfig.utils.utils5 import Scheduler
14
14
  from machineconfig.cluster.sessions_managers.zellij_local import ZellijLayoutGenerator
15
- from machineconfig.cluster.sessions_managers.layout_types import LayoutConfig
15
+ from machineconfig.utils.schemas.layouts.layout_types import LayoutConfig
16
16
 
17
17
  logging.basicConfig(level=logging.INFO)
18
18
  logger = logging.getLogger(__name__)
@@ -13,7 +13,7 @@ from machineconfig.cluster.sessions_managers.zellij_utils.layout_generator impor
13
13
  from machineconfig.cluster.sessions_managers.zellij_utils.process_monitor import ProcessMonitor
14
14
  from machineconfig.cluster.sessions_managers.zellij_utils.session_manager import SessionManager
15
15
  from machineconfig.cluster.sessions_managers.zellij_utils.status_reporter import StatusReporter
16
- from machineconfig.cluster.sessions_managers.layout_types import LayoutConfig
16
+ from machineconfig.utils.schemas.layouts.layout_types import LayoutConfig
17
17
 
18
18
  logging.basicConfig(level=logging.INFO)
19
19
  logger = logging.getLogger(__name__)
@@ -6,7 +6,7 @@ from typing import Optional, Dict
6
6
  from machineconfig.utils.utils5 import Scheduler
7
7
  from machineconfig.cluster.sessions_managers.zellij_local import run_command_in_zellij_tab
8
8
  from machineconfig.cluster.sessions_managers.zellij_remote import ZellijRemoteLayoutGenerator
9
- from machineconfig.cluster.sessions_managers.layout_types import LayoutConfig
9
+ from machineconfig.utils.schemas.layouts.layout_types import LayoutConfig
10
10
  from machineconfig.logger import get_logger
11
11
 
12
12
 
@@ -4,7 +4,7 @@ Example usage of the modularized Zellij remote layout generator.
4
4
  """
5
5
 
6
6
  from machineconfig.cluster.sessions_managers.zellij_remote import ZellijRemoteLayoutGenerator
7
- from machineconfig.cluster.sessions_managers.layout_types import LayoutConfig
7
+ from machineconfig.utils.schemas.layouts.layout_types import LayoutConfig
8
8
 
9
9
 
10
10
  def example_usage():
@@ -11,7 +11,7 @@ from pathlib import Path
11
11
  import logging
12
12
 
13
13
  from rich.console import Console
14
- from machineconfig.cluster.sessions_managers.layout_types import LayoutConfig
14
+ from machineconfig.utils.schemas.layouts.layout_types import LayoutConfig
15
15
 
16
16
  logger = logging.getLogger(__name__)
17
17
  console = Console()
@@ -8,7 +8,7 @@ import shlex
8
8
  import logging
9
9
  from typing import Dict, Any
10
10
  from machineconfig.cluster.sessions_managers.zellij_utils.remote_executor import RemoteExecutor
11
- from machineconfig.cluster.sessions_managers.layout_types import LayoutConfig
11
+ from machineconfig.utils.schemas.layouts.layout_types import LayoutConfig
12
12
 
13
13
  logger = logging.getLogger(__name__)
14
14
 
@@ -7,7 +7,7 @@ import logging
7
7
  from typing import Dict, Any
8
8
  from machineconfig.cluster.sessions_managers.zellij_utils.process_monitor import ProcessMonitor
9
9
  from machineconfig.cluster.sessions_managers.zellij_utils.session_manager import SessionManager
10
- from machineconfig.cluster.sessions_managers.layout_types import LayoutConfig
10
+ from machineconfig.utils.schemas.layouts.layout_types import LayoutConfig
11
11
 
12
12
  logger = logging.getLogger(__name__)
13
13
 
@@ -27,7 +27,6 @@ def sync_remote(machine_name: str):
27
27
  """)
28
28
  raise ValueError(error_msg)
29
29
 
30
- # this is template: code = """ssh -o "HostName=zgeby8zhe6ipftpad.alexsaffar.com" -o "User=alex" -o "ProxyCommand=cloudflared access ssh --hostname %h" -o "Port=443" -o "RequestTTY=yes" -o "RemoteCommand=bash ~/scripts/z_ls --attach; bash" tpadCF"""
31
30
  code = f"""
32
31
  ssh -o "HostName={machine_config["HostName"]}" -o "User={machine_config["User"]}" -o "ProxyCommand=cloudflared access ssh --hostname %h" -o "Port={machine_config["Port"]}" -o "RequestTTY=yes" -o "RemoteCommand=devops --which update; bash" {machine_name}
33
32
  """
@@ -3,6 +3,7 @@ This script Takes away all config files from the computer, place them in one dir
3
3
  `dotfiles`, and create symlinks to those files from thier original locations.
4
4
 
5
5
  """
6
+ from rich.console import Console
6
7
 
7
8
  from machineconfig.utils.path_reduced import PathExtended as PathExtended
8
9
  from machineconfig.utils.links import symlink_func, symlink_copy
@@ -11,37 +12,28 @@ from machineconfig.utils.source_of_truth import LIBRARY_ROOT, REPO_ROOT
11
12
  from machineconfig.utils.utils2 import read_toml
12
13
  from machineconfig.profile.shell import create_default_shell_profile
13
14
 
14
- # import os
15
15
  import platform
16
16
  import os
17
17
  import ctypes
18
18
  import subprocess
19
- from rich.console import Console
20
19
  from typing import Optional, Any, TypedDict
21
20
 
22
21
  system = platform.system() # Linux or Windows
23
22
  ERROR_LIST: list[Any] = [] # append to this after every exception captured.
24
-
25
23
  SYSTEM = system.lower()
26
-
27
-
28
24
  def get_other_systems(current_system: str) -> list[str]:
29
25
  all_systems = ["linux", "windows", "darwin"]
30
26
  return [s for s in all_systems if s != current_system.lower()]
31
-
32
-
33
27
  OTHER_SYSTEMS = get_other_systems(SYSTEM)
34
-
35
-
36
28
  class SymlinkMapper(TypedDict):
37
29
  this: str
38
30
  to_this: str
39
31
  contents: Optional[bool]
40
32
 
41
33
 
42
- def main_symlinks(choice: Optional[str] = None):
34
+ def apply_mapper(choice: Optional[str] = None):
43
35
  symlink_mapper: dict[str, dict[str, SymlinkMapper]] = read_toml(LIBRARY_ROOT.joinpath("profile/mapper.toml"))
44
- overwrite = True
36
+ prioritize_to_this = True
45
37
  exclude: list[str] = [] # "wsl_linux", "wsl_windows"
46
38
 
47
39
  program_keys_raw: list[str] = list(symlink_mapper.keys())
@@ -63,7 +55,7 @@ def main_symlinks(choice: Optional[str] = None):
63
55
  # overwrite = display_options(msg="Overwrite existing source file?", options=["yes", "no"], default="yes") == "yes"
64
56
  from rich.prompt import Confirm
65
57
 
66
- overwrite = Confirm.ask("Overwrite existing source file?", default=True)
58
+ prioritize_to_this = Confirm.ask("Overwrite existing source file?", default=True)
67
59
  else:
68
60
  choice_selected = choice
69
61
 
@@ -102,17 +94,17 @@ def main_symlinks(choice: Optional[str] = None):
102
94
  if "contents" in file_map:
103
95
  try:
104
96
  for a_target in to_this.expanduser().search("*"):
105
- symlink_func(this=this.joinpath(a_target.name), to_this=a_target, prioritize_to_this=overwrite)
97
+ symlink_func(this=this.joinpath(a_target.name), to_this=a_target, prioritize_to_this=prioritize_to_this)
106
98
  except Exception as ex:
107
99
  print(f"❌ Config error: {program_key} | {file_key} | missing keys 'this ==> to_this'. {ex}")
108
100
  if "copy" in file_map:
109
101
  try:
110
- symlink_copy(this=this, to_this=to_this, prioritize_to_this=overwrite)
102
+ symlink_copy(this=this, to_this=to_this, prioritize_to_this=prioritize_to_this)
111
103
  except Exception as ex:
112
104
  print(f"❌ Config error: {program_key} | {file_key} | {ex}")
113
105
  else:
114
106
  try:
115
- symlink_func(this=this, to_this=to_this, prioritize_to_this=overwrite)
107
+ symlink_func(this=this, to_this=to_this, prioritize_to_this=prioritize_to_this)
116
108
  except Exception as ex:
117
109
  print(f"❌ Config error: {program_key} | {file_key} | missing keys 'this ==> to_this'. {ex}")
118
110
 
@@ -152,7 +144,7 @@ def main(choice: Optional[str] = None):
152
144
  console = Console()
153
145
  print("\n")
154
146
  console.rule("[bold blue]🔗 CREATING SYMLINKS 🔗")
155
- main_symlinks(choice=choice)
147
+ apply_mapper(choice=choice)
156
148
 
157
149
  print("\n")
158
150
  console.rule("[bold green]🐚 CREATING SHELL PROFILE 🐚")
@@ -1,13 +1,11 @@
1
1
  """shell"""
2
2
 
3
- from machineconfig.utils.utils2 import randstr
4
3
  from machineconfig.utils.path_reduced import PathExtended as PathExtended
5
- from machineconfig.utils.terminal import Terminal
6
- from machineconfig.utils.options import display_options
7
- from machineconfig.utils.source_of_truth import LIBRARY_ROOT, REPO_ROOT
4
+ from machineconfig.utils.source_of_truth import LIBRARY_ROOT
5
+
8
6
  import platform
9
7
  import os
10
- from typing import Literal, Optional
8
+ import subprocess
11
9
  from rich.console import Console
12
10
  from rich.panel import Panel
13
11
 
@@ -18,44 +16,17 @@ PATH = os.environ["PATH"].split(sep) # this is a list of paths in PATH variable
18
16
  console = Console()
19
17
  BOX_WIDTH = 100 # Define BOX_WIDTH or get it from a config
20
18
 
21
- # --------------------------------------- SHELL PROFILE --------------------------------------------------------
22
- # modification of shell profile by additing dirs to PATH
23
- # Shell profile is either in dotfiles and is synced (as in Windows), hence no need for update, or is updated on the fly (for Linux)
24
- # for windows it won't change the profile, if the profile was modified already e.g. due to syncing
25
-
26
-
27
- def create_default_shell_profile() -> None:
28
- profile_path = get_shell_profile_path()
29
- profile = profile_path.read_text(encoding="utf-8")
30
- if system == "Windows":
31
- source = f""". {str(PathExtended(LIBRARY_ROOT).joinpath("settings/shells/pwsh/init.ps1").collapseuser()).replace("~", "$HOME")}"""
32
- else:
33
- source = f"""source {str(PathExtended(LIBRARY_ROOT).joinpath("settings/shells/bash/init.sh").collapseuser()).replace("~", "$HOME")}"""
34
-
35
- if source in profile:
36
- console.print(Panel("🔄 PROFILE | Skipping init script sourcing - already present in profile", title="[bold blue]Profile[/bold blue]", border_style="blue"))
37
- else:
38
- console.print(Panel("📝 PROFILE | Adding init script sourcing to profile", title="[bold blue]Profile[/bold blue]", border_style="blue"))
39
- profile += "\n" + source + "\n"
40
- if system == "Linux":
41
- res = Terminal().run("cat /proc/version").op
42
- if "microsoft" in res.lower() or "wsl" in res.lower():
43
- profile += "\ncd ~"
44
- console.print("📌 WSL detected - adding 'cd ~' to profile to avoid Windows filesystem")
45
- profile_path.parent.mkdir(parents=True, exist_ok=True)
46
- profile_path.write_text(profile, encoding="utf-8")
47
- console.print(Panel("✅ Profile updated successfully", title="[bold blue]Profile[/bold blue]", border_style="blue"))
48
-
49
19
 
50
20
  def get_shell_profile_path() -> PathExtended:
51
21
  if system == "Windows":
52
- obj = Terminal().run("$PROFILE", shell="pwsh")
53
- res = obj.op2path()
54
- if isinstance(res, PathExtended):
55
- profile_path = res
22
+ result = subprocess.run(["pwsh", "-Command", "$PROFILE"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=False)
23
+ if result.returncode == 0 and result.stdout.strip():
24
+ profile_path = PathExtended(result.stdout.strip())
56
25
  else:
57
- obj.print(capture=False)
58
- raise ValueError(f"""Could not get profile path for Windows. Got {res}""")
26
+ print(f"Command failed with return code {result.returncode}")
27
+ print(f"stdout: {result.stdout}")
28
+ print(f"stderr: {result.stderr}")
29
+ raise ValueError(f"""Could not get profile path for Windows. Got stdout: {result.stdout}, stderr: {result.stderr}""")
59
30
  elif system == "Linux":
60
31
  profile_path = PathExtended("~/.bashrc").expanduser()
61
32
  else:
@@ -64,151 +35,141 @@ def get_shell_profile_path() -> PathExtended:
64
35
  return profile_path
65
36
 
66
37
 
67
- def append_temporarily(dirs: list[str], kind: Literal["append", "prefix", "replace"]) -> str:
68
- dirs_ = []
69
- for path in dirs:
70
- path_rel = PathExtended(path).collapseuser(strict=False)
71
- if path_rel.as_posix() in PATH or str(path_rel) in PATH or str(path_rel.expanduser()) in PATH or path_rel.expanduser().as_posix() in PATH:
72
- print(f"Path passed `{path}` is already in PATH, skipping the appending.")
73
- else:
74
- dirs_.append(path_rel.as_posix() if system == "Linux" else str(path_rel))
75
- dirs = dirs_
76
- if len(dirs) == 0:
77
- return ""
78
-
38
+ def create_default_shell_profile() -> None:
39
+ shell_profile_path = get_shell_profile_path()
40
+ shell_profile = shell_profile_path.read_text(encoding="utf-8")
79
41
  if system == "Windows":
80
- """Source: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.2"""
81
- if kind == "append":
82
- command = rf'$env:Path += ";{sep.join(dirs)}"' # Append to the Path variable in the current window:
83
- elif kind == "prefix":
84
- command = rf'$env:Path = "{sep.join(dirs)};" + $env:Path' # Prefix the Path variable in the current window:
85
- elif kind == "replace":
86
- command = rf'$env:Path = "{sep.join(dirs)}"' # Replace the Path variable in the current window (use with caution!):
87
- else:
88
- raise KeyError
89
- return command # if run is False else tm.run(command, shell="powershell")
90
- elif system in ["Linux", "Darwin"]:
91
- result = f'export PATH="{sep.join(dirs)}:$PATH"'
92
- else:
93
- raise ValueError
94
- return result
95
-
96
-
97
- def main_env_path(choice: Optional[str], profile_path: Optional[str]) -> None:
98
- from machineconfig.utils.utils2 import read_toml
99
-
100
- env_path = read_toml(LIBRARY_ROOT.joinpath("profile/env_path.toml"))
101
- # env_path = LIBRARY_ROOT.joinpath("profile/env_path.toml").readit()
102
- dirs = env_path[f"path_{system.lower()}"]["extension"]
103
-
104
- console.print(Panel("🔍 ENVIRONMENT | Current PATH variables:", title="[bold blue]Environment[/bold blue]", border_style="blue"))
105
-
106
- if choice is None:
107
- tmp = display_options(msg="Which directory to add?", options=dirs + ["all", "none(EXIT)"], default="none(EXIT)")
108
- assert isinstance(tmp, str), f"Choice must be a string or a list of strings, not {type(choice)}"
109
- choice = tmp
110
- if str(choice) != "all":
111
- dirs = [choice]
112
- if choice == "none(EXIT)":
113
- return
114
-
115
- console.print(f"\n📌 Adding directories to PATH: {dirs}")
116
- addition = append_temporarily(dirs=dirs, kind="append")
117
- profile_path_obj = PathExtended(profile_path) if isinstance(profile_path, str) else get_shell_profile_path()
118
- profile_path_obj.copy(name=profile_path_obj.name + ".orig_" + randstr())
119
- console.print(f"💾 Created backup of profile: {profile_path_obj.name}.orig_*")
120
- # Inline deprecated modify_text: if file missing, seed with search text before modification
121
- current = profile_path_obj.read_text(encoding="utf-8") if profile_path_obj.exists() else addition
122
- updated = current if addition in current else current + "\n" + addition
123
- profile_path_obj.write_text(updated, encoding="utf-8")
124
- console.print(Panel("✅ PATH variables added to profile successfully", title="[bold blue]Environment[/bold blue]", border_style="blue"))
125
-
126
-
127
- def main_add_sources_to_shell_profile(profile_path: Optional[str], choice: Optional[str]) -> None:
128
- # sources: list[str] = LIBRARY_ROOT.joinpath("profile/sources.toml").readit()[system.lower()]['files']
129
- from machineconfig.utils.utils2 import read_toml
130
-
131
- sources: list[str] = read_toml(LIBRARY_ROOT.joinpath("profile/sources.toml"))[system.lower()]["files"]
132
-
133
- console.print(Panel("🔄 Adding sources to shell profile", title="[bold blue]Sources[/bold blue]", border_style="blue"))
134
-
135
- if choice is None:
136
- choice_obj = display_options(msg="Which patch to add?", options=sources + ["all", "none(EXIT)"], default="none(EXIT)", multi=True)
137
- if isinstance(choice_obj, str):
138
- if choice_obj == "all":
139
- choice = choice_obj
140
- elif choice_obj == "none(EXIT)":
141
- return
142
- else:
143
- sources = [choice_obj]
144
- else: # isinstance(choice_obj, list):
145
- sources = choice_obj
146
- elif choice == "none(EXIT)":
147
- return
148
-
149
- if isinstance(profile_path, str):
150
- profile_path_obj = PathExtended(profile_path)
42
+ source = f""". {str(PathExtended(LIBRARY_ROOT).joinpath("settings/shells/pwsh/init.ps1").collapseuser()).replace("~", "$HOME")}"""
151
43
  else:
152
- profile_path_obj = get_shell_profile_path()
153
- profile = profile_path_obj.read_text(encoding="utf-8")
154
-
155
- for a_file in sources:
156
- tmp = a_file.replace("REPO_ROOT", REPO_ROOT.as_posix()).replace("LIBRARY_ROOT", LIBRARY_ROOT.as_posix())
157
- file = PathExtended(tmp).collapseuser() # this makes the shell profile interuseable across machines.
158
- file = file.as_posix() if system == "Linux" else str(file)
159
- if file not in profile:
160
- if system == "Windows":
161
- profile += f"\n. {file}"
162
- console.print(f"➕ Added PowerShell source: {file}")
163
- elif system == "Linux":
164
- profile += f"\nsource {file}"
165
- console.print(f"➕ Added Bash source: {file}")
166
- else:
167
- raise ValueError(f"Not implemented for this system {system}")
168
- else:
169
- console.print(f"⏭️ Source already present: {file}")
170
-
171
- profile_path_obj.write_text(profile, encoding="utf-8")
172
- console.print(Panel("✅ Shell profile updated with sources", title="[bold blue]Sources[/bold blue]", border_style="blue"))
173
-
174
-
175
- def main_add_patches_to_shell_profile(profile_path: Optional[str], choice: Optional[str]) -> None:
176
- patches: list[str] = [item.as_posix() for item in PathExtended(LIBRARY_ROOT).joinpath(f"profile/patches/{system.lower()}").search()]
177
-
178
- console.print(Panel("🩹 Adding patches to shell profile", title="[bold blue]Patches[/bold blue]", border_style="blue"))
179
-
180
- if choice is None:
181
- choice_chosen = display_options(msg="Which patch to add?", options=list(patches) + ["all", "none(EXIT)"], default="none(EXIT)", multi=False)
182
- assert isinstance(choice_chosen, str), f"Choice must be a string or a list of strings, not {type(choice)}"
183
- choice = choice_chosen
184
- if choice == "none(EXIT)":
185
- return None
186
- elif str(choice) == "all":
187
- console.print("📌 Adding all patches to profile")
44
+ source = f"""source {str(PathExtended(LIBRARY_ROOT).joinpath("settings/shells/bash/init.sh").collapseuser()).replace("~", "$HOME")}"""
45
+ if source in shell_profile:
46
+ console.print(Panel("🔄 PROFILE | Skipping init script sourcing - already present in profile", title="[bold blue]Profile[/bold blue]", border_style="blue"))
188
47
  else:
189
- patches = [choice]
190
- console.print(f"📌 Adding selected patch: {choice}")
191
-
192
- profile_path_obj = PathExtended(profile_path) if isinstance(profile_path, str) else get_shell_profile_path()
193
- profile = profile_path_obj.read_text(encoding="utf-8")
194
-
195
- for patch_path in patches:
196
- patch_path_obj = PathExtended(patch_path)
197
- patch = patch_path_obj.read_text(encoding="utf-8")
198
- if patch in profile:
199
- console.print(f"⏭️ Patch already present: {patch_path_obj.name}")
200
- else:
201
- profile += "\n" + patch
202
- console.print(f"➕ Added patch: {patch_path_obj.name}")
48
+ console.print(Panel("📝 PROFILE | Adding init script sourcing to profile", title="[bold blue]Profile[/bold blue]", border_style="blue"))
49
+ shell_profile += "\n" + source + "\n"
50
+ if system == "Linux":
51
+ result = subprocess.run(["cat", "/proc/version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=False)
52
+ if result.returncode == 0 and result.stdout:
53
+ version_info = result.stdout.lower()
54
+ if "microsoft" in version_info or "wsl" in version_info:
55
+ shell_profile += "\ncd ~"
56
+ console.print("📌 WSL detected - adding 'cd ~' to profile to avoid Windows filesystem")
57
+ shell_profile_path.parent.mkdir(parents=True, exist_ok=True)
58
+ shell_profile_path.write_text(shell_profile, encoding="utf-8")
59
+ console.print(Panel("✅ Profile updated successfully", title="[bold blue]Profile[/bold blue]", border_style="blue"))
203
60
 
204
- if system == "Linux":
205
- res = Terminal().run("cat /proc/version").op
206
- if "microsoft" in res.lower() or "wsl" in res.lower():
207
- profile += "\ncd ~" # this is to make sure that the current dir is not in the windows file system, which is terribly slow and its a bad idea to be there anyway.
208
- console.print("📌 WSL detected - adding 'cd ~' to profile to avoid Windows filesystem")
209
61
 
210
- profile_path_obj.write_text(profile, encoding="utf-8")
211
- console.print(Panel("✅ Shell profile updated with patches", title="[bold blue]Patches[/bold blue]", border_style="blue"))
62
+ # def append_temporarily(dirs: list[str], kind: Literal["append", "prefix", "replace"]) -> str:
63
+ # dirs_ = []
64
+ # for path in dirs:
65
+ # path_rel = PathExtended(path).collapseuser(strict=False)
66
+ # if path_rel.as_posix() in PATH or str(path_rel) in PATH or str(path_rel.expanduser()) in PATH or path_rel.expanduser().as_posix() in PATH:
67
+ # print(f"Path passed `{path}` is already in PATH, skipping the appending.")
68
+ # else:
69
+ # dirs_.append(path_rel.as_posix() if system == "Linux" else str(path_rel))
70
+ # dirs = dirs_
71
+ # if len(dirs) == 0:
72
+ # return ""
73
+
74
+ # if system == "Windows":
75
+ # """Source: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.2"""
76
+ # if kind == "append":
77
+ # command = rf'$env:Path += ";{sep.join(dirs)}"' # Append to the Path variable in the current window:
78
+ # elif kind == "prefix":
79
+ # command = rf'$env:Path = "{sep.join(dirs)};" + $env:Path' # Prefix the Path variable in the current window:
80
+ # elif kind == "replace":
81
+ # command = rf'$env:Path = "{sep.join(dirs)}"' # Replace the Path variable in the current window (use with caution!):
82
+ # else:
83
+ # raise KeyError
84
+ # return command # if run is False else tm.run(command, shell="powershell")
85
+ # elif system in ["Linux", "Darwin"]:
86
+ # result = f'export PATH="{sep.join(dirs)}:$PATH"'
87
+ # else:
88
+ # raise ValueError
89
+ # return result
90
+
91
+
92
+ # def main_add_sources_to_shell_profile(profile_path: Optional[str], choice: Optional[str]) -> None:
93
+ # sources: list[str] = read_toml(LIBRARY_ROOT.joinpath("profile/sources.toml"))[system.lower()]["files"]
94
+ # console.print(Panel("🔄 Adding sources to shell profile", title="[bold blue]Sources[/bold blue]", border_style="blue"))
95
+
96
+ # if choice is None:
97
+ # choice_obj = display_options(msg="Which patch to add?", options=sources + ["all", "none(EXIT)"], default="none(EXIT)", multi=True)
98
+ # if isinstance(choice_obj, str):
99
+ # if choice_obj == "all":
100
+ # choice = choice_obj
101
+ # elif choice_obj == "none(EXIT)":
102
+ # return
103
+ # else:
104
+ # sources = [choice_obj]
105
+ # else: # isinstance(choice_obj, list):
106
+ # sources = choice_obj
107
+ # elif choice == "none(EXIT)":
108
+ # return
109
+
110
+ # if isinstance(profile_path, str):
111
+ # profile_path_obj = PathExtended(profile_path)
112
+ # else:
113
+ # profile_path_obj = get_shell_profile_path()
114
+ # profile = profile_path_obj.read_text(encoding="utf-8")
115
+
116
+ # for a_file in sources:
117
+ # tmp = a_file.replace("REPO_ROOT", REPO_ROOT.as_posix()).replace("LIBRARY_ROOT", LIBRARY_ROOT.as_posix())
118
+ # file = PathExtended(tmp).collapseuser() # this makes the shell profile interuseable across machines.
119
+ # file = file.as_posix() if system == "Linux" else str(file)
120
+ # if file not in profile:
121
+ # if system == "Windows":
122
+ # profile += f"\n. {file}"
123
+ # console.print(f"➕ Added PowerShell source: {file}")
124
+ # elif system == "Linux":
125
+ # profile += f"\nsource {file}"
126
+ # console.print(f"➕ Added Bash source: {file}")
127
+ # else:
128
+ # raise ValueError(f"Not implemented for this system {system}")
129
+ # else:
130
+ # console.print(f"⏭️ Source already present: {file}")
131
+
132
+ # profile_path_obj.write_text(profile, encoding="utf-8")
133
+ # console.print(Panel("✅ Shell profile updated with sources", title="[bold blue]Sources[/bold blue]", border_style="blue"))
134
+
135
+
136
+ # def main_add_patches_to_shell_profile(profile_path: Optional[str], choice: Optional[str]) -> None:
137
+ # patches: list[str] = [item.as_posix() for item in PathExtended(LIBRARY_ROOT).joinpath(f"profile/patches/{system.lower()}").search()]
138
+
139
+ # console.print(Panel("🩹 Adding patches to shell profile", title="[bold blue]Patches[/bold blue]", border_style="blue"))
140
+
141
+ # if choice is None:
142
+ # choice_chosen = display_options(msg="Which patch to add?", options=list(patches) + ["all", "none(EXIT)"], default="none(EXIT)", multi=False)
143
+ # assert isinstance(choice_chosen, str), f"Choice must be a string or a list of strings, not {type(choice)}"
144
+ # choice = choice_chosen
145
+ # if choice == "none(EXIT)":
146
+ # return None
147
+ # elif str(choice) == "all":
148
+ # console.print("📌 Adding all patches to profile")
149
+ # else:
150
+ # patches = [choice]
151
+ # console.print(f"📌 Adding selected patch: {choice}")
152
+
153
+ # profile_path_obj = PathExtended(profile_path) if isinstance(profile_path, str) else get_shell_profile_path()
154
+ # profile = profile_path_obj.read_text(encoding="utf-8")
155
+
156
+ # for patch_path in patches:
157
+ # patch_path_obj = PathExtended(patch_path)
158
+ # patch = patch_path_obj.read_text(encoding="utf-8")
159
+ # if patch in profile:
160
+ # console.print(f"⏭️ Patch already present: {patch_path_obj.name}")
161
+ # else:
162
+ # profile += "\n" + patch
163
+ # console.print(f"➕ Added patch: {patch_path_obj.name}")
164
+
165
+ # if system == "Linux":
166
+ # res = Terminal().run("cat /proc/version").op
167
+ # if "microsoft" in res.lower() or "wsl" in res.lower():
168
+ # profile += "\ncd ~" # this is to make sure that the current dir is not in the windows file system, which is terribly slow and its a bad idea to be there anyway.
169
+ # console.print("📌 WSL detected - adding 'cd ~' to profile to avoid Windows filesystem")
170
+
171
+ # profile_path_obj.write_text(profile, encoding="utf-8")
172
+ # console.print(Panel("✅ Shell profile updated with patches", title="[bold blue]Patches[/bold blue]", border_style="blue"))
212
173
 
213
174
 
214
175
  if __name__ == "__main__":
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env bash
2
- uv run --python 3.13 --with machineconfig python -m fire machineconfig.scripts.python.choose_wezterm_theme main
2
+ uv run --python 3.13 --no-dev --project $HOME/code/machineconfig choose_wezterm_theme
3
3
  source ~/.bashrc # reload the profile
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env bash
2
- uv run --python 3.13 --with machineconfig python -m machineconfig.scripts.python.cloud_copy "$@"
2
+ uv run --python 3.13 --no-dev --project $HOME/code/machineconfig cloud_copy "$@"
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env bash
2
- uv run --python 3.13 --with machineconfig python -m machineconfig.scripts.python.cloud_mount "$@"
2
+ uv run --python 3.13 --no-dev --project $HOME/code/machineconfig cloud_mount "$@"