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.

Files changed (253) hide show
  1. machineconfig/cluster/cloud_manager.py +0 -3
  2. machineconfig/cluster/data_transfer.py +0 -1
  3. machineconfig/cluster/file_manager.py +0 -1
  4. machineconfig/cluster/job_params.py +0 -3
  5. machineconfig/cluster/loader_runner.py +0 -3
  6. machineconfig/cluster/remote_machine.py +0 -1
  7. machineconfig/cluster/script_notify_upon_completion.py +0 -1
  8. machineconfig/cluster/sessions_managers/archive/create_zellij_template.py +5 -6
  9. machineconfig/cluster/sessions_managers/archive/session_managers.py +0 -1
  10. machineconfig/cluster/sessions_managers/enhanced_command_runner.py +17 -57
  11. machineconfig/cluster/sessions_managers/wt_local.py +36 -110
  12. machineconfig/cluster/sessions_managers/wt_local_manager.py +42 -112
  13. machineconfig/cluster/sessions_managers/wt_remote.py +23 -30
  14. machineconfig/cluster/sessions_managers/wt_remote_manager.py +20 -62
  15. machineconfig/cluster/sessions_managers/wt_utils/layout_generator.py +10 -15
  16. machineconfig/cluster/sessions_managers/wt_utils/process_monitor.py +27 -127
  17. machineconfig/cluster/sessions_managers/wt_utils/remote_executor.py +10 -43
  18. machineconfig/cluster/sessions_managers/wt_utils/session_manager.py +22 -101
  19. machineconfig/cluster/sessions_managers/wt_utils/status_reporter.py +11 -39
  20. machineconfig/cluster/sessions_managers/zellij_local.py +49 -102
  21. machineconfig/cluster/sessions_managers/zellij_local_manager.py +34 -78
  22. machineconfig/cluster/sessions_managers/zellij_remote.py +17 -24
  23. machineconfig/cluster/sessions_managers/zellij_remote_manager.py +7 -13
  24. machineconfig/cluster/sessions_managers/zellij_utils/example_usage.py +4 -2
  25. machineconfig/cluster/sessions_managers/zellij_utils/layout_generator.py +6 -6
  26. machineconfig/cluster/sessions_managers/zellij_utils/process_monitor.py +18 -88
  27. machineconfig/cluster/sessions_managers/zellij_utils/remote_executor.py +2 -6
  28. machineconfig/cluster/sessions_managers/zellij_utils/session_manager.py +12 -40
  29. machineconfig/cluster/sessions_managers/zellij_utils/status_reporter.py +3 -2
  30. machineconfig/cluster/templates/cli_click.py +0 -1
  31. machineconfig/cluster/templates/cli_gooey.py +0 -2
  32. machineconfig/cluster/templates/cli_trogon.py +0 -1
  33. machineconfig/cluster/templates/run_cloud.py +0 -1
  34. machineconfig/cluster/templates/run_cluster.py +0 -1
  35. machineconfig/cluster/templates/run_remote.py +0 -1
  36. machineconfig/cluster/templates/utils.py +27 -46
  37. machineconfig/jobs/__pycache__/__init__.cpython-313.pyc +0 -0
  38. machineconfig/jobs/linux/msc/cli_agents.sh +16 -0
  39. machineconfig/jobs/python/check_installations.py +2 -1
  40. machineconfig/jobs/python/create_bootable_media.py +0 -2
  41. machineconfig/jobs/python/python_ve_symlink.py +9 -11
  42. machineconfig/jobs/python/tasks.py +0 -1
  43. machineconfig/jobs/python/vscode/api.py +5 -5
  44. machineconfig/jobs/python/vscode/link_ve.py +13 -14
  45. machineconfig/jobs/python/vscode/select_interpreter.py +21 -22
  46. machineconfig/jobs/python/vscode/sync_code.py +9 -13
  47. machineconfig/jobs/python_custom_installers/archive/ngrok.py +13 -13
  48. machineconfig/jobs/python_custom_installers/dev/aider.py +7 -15
  49. machineconfig/jobs/python_custom_installers/dev/alacritty.py +9 -18
  50. machineconfig/jobs/python_custom_installers/dev/brave.py +10 -19
  51. machineconfig/jobs/python_custom_installers/dev/bypass_paywall.py +8 -15
  52. machineconfig/jobs/python_custom_installers/dev/code.py +12 -32
  53. machineconfig/jobs/python_custom_installers/dev/cursor.py +3 -14
  54. machineconfig/jobs/python_custom_installers/dev/docker_desktop.py +8 -7
  55. machineconfig/jobs/python_custom_installers/dev/espanso.py +15 -19
  56. machineconfig/jobs/python_custom_installers/dev/goes.py +5 -12
  57. machineconfig/jobs/python_custom_installers/dev/lvim.py +9 -17
  58. machineconfig/jobs/python_custom_installers/dev/nerdfont.py +12 -19
  59. machineconfig/jobs/python_custom_installers/dev/redis.py +12 -20
  60. machineconfig/jobs/python_custom_installers/dev/wezterm.py +12 -19
  61. machineconfig/jobs/python_custom_installers/dev/winget.py +5 -23
  62. machineconfig/jobs/python_custom_installers/docker.py +12 -21
  63. machineconfig/jobs/python_custom_installers/gh.py +11 -19
  64. machineconfig/jobs/python_custom_installers/hx.py +32 -16
  65. machineconfig/jobs/python_custom_installers/warp-cli.py +12 -20
  66. machineconfig/jobs/python_generic_installers/__pycache__/__init__.cpython-313.pyc +0 -0
  67. machineconfig/jobs/python_generic_installers/config.json +1 -1
  68. machineconfig/jobs/python_linux_installers/__pycache__/__init__.cpython-313.pyc +0 -0
  69. machineconfig/jobs/windows/archive/archive_pygraphviz.ps1 +1 -1
  70. machineconfig/jobs/windows/msc/cli_agents.bat +0 -0
  71. machineconfig/jobs/windows/msc/cli_agents.ps1 +0 -0
  72. machineconfig/jobs/windows/start_terminal.ps1 +1 -1
  73. machineconfig/profile/create.py +38 -26
  74. machineconfig/profile/create_hardlinks.py +29 -20
  75. machineconfig/profile/shell.py +56 -32
  76. machineconfig/scripts/__init__.py +0 -2
  77. machineconfig/scripts/__pycache__/__init__.cpython-313.pyc +0 -0
  78. machineconfig/scripts/cloud/init.sh +2 -2
  79. machineconfig/scripts/linux/checkout_versions +1 -1
  80. machineconfig/scripts/linux/choose_wezterm_theme +1 -1
  81. machineconfig/scripts/linux/cloud_copy +1 -1
  82. machineconfig/scripts/linux/cloud_manager +1 -1
  83. machineconfig/scripts/linux/cloud_mount +1 -1
  84. machineconfig/scripts/linux/cloud_repo_sync +1 -1
  85. machineconfig/scripts/linux/cloud_sync +1 -1
  86. machineconfig/scripts/linux/croshell +1 -1
  87. machineconfig/scripts/linux/devops +7 -7
  88. machineconfig/scripts/linux/fire +1 -1
  89. machineconfig/scripts/linux/fire_agents +3 -2
  90. machineconfig/scripts/linux/ftpx +1 -1
  91. machineconfig/scripts/linux/gh_models +1 -1
  92. machineconfig/scripts/linux/kill_process +1 -1
  93. machineconfig/scripts/linux/mcinit +1 -1
  94. machineconfig/scripts/linux/repos +1 -1
  95. machineconfig/scripts/linux/scheduler +1 -1
  96. machineconfig/scripts/linux/start_slidev +1 -1
  97. machineconfig/scripts/linux/start_terminals +1 -1
  98. machineconfig/scripts/linux/url2md +1 -1
  99. machineconfig/scripts/linux/warp-cli.sh +122 -0
  100. machineconfig/scripts/linux/wifi_conn +1 -1
  101. machineconfig/scripts/python/__pycache__/__init__.cpython-313.pyc +0 -0
  102. machineconfig/scripts/python/__pycache__/devops.cpython-313.pyc +0 -0
  103. machineconfig/scripts/python/__pycache__/devops_devapps_install.cpython-313.pyc +0 -0
  104. machineconfig/scripts/python/__pycache__/devops_update_repos.cpython-313.pyc +0 -0
  105. machineconfig/scripts/python/__pycache__/fire_agents.cpython-313.pyc +0 -0
  106. machineconfig/scripts/python/ai/__init__.py +0 -0
  107. machineconfig/scripts/python/ai/generate_files.py +83 -0
  108. machineconfig/scripts/python/ai/instructions/python/dev.instructions.md +2 -2
  109. machineconfig/scripts/python/ai/mcinit.py +14 -7
  110. machineconfig/scripts/python/ai/scripts/lint_and_type_check.sh +10 -5
  111. machineconfig/scripts/python/archive/tmate_conn.py +5 -5
  112. machineconfig/scripts/python/archive/tmate_start.py +7 -7
  113. machineconfig/scripts/python/choose_wezterm_theme.py +35 -32
  114. machineconfig/scripts/python/cloud_copy.py +23 -14
  115. machineconfig/scripts/python/cloud_mount.py +36 -24
  116. machineconfig/scripts/python/cloud_repo_sync.py +40 -27
  117. machineconfig/scripts/python/cloud_sync.py +4 -4
  118. machineconfig/scripts/python/croshell.py +40 -29
  119. machineconfig/scripts/python/devops.py +45 -27
  120. machineconfig/scripts/python/devops_add_identity.py +15 -25
  121. machineconfig/scripts/python/devops_add_ssh_key.py +8 -8
  122. machineconfig/scripts/python/devops_backup_retrieve.py +18 -16
  123. machineconfig/scripts/python/devops_devapps_install.py +25 -20
  124. machineconfig/scripts/python/devops_update_repos.py +232 -59
  125. machineconfig/scripts/python/dotfile.py +17 -15
  126. machineconfig/scripts/python/fire_agents.py +48 -22
  127. machineconfig/scripts/python/fire_jobs.py +93 -58
  128. machineconfig/scripts/python/ftpx.py +26 -15
  129. machineconfig/scripts/python/get_zellij_cmd.py +8 -7
  130. machineconfig/scripts/python/helpers/cloud_helpers.py +33 -28
  131. machineconfig/scripts/python/helpers/helpers2.py +27 -16
  132. machineconfig/scripts/python/helpers/helpers4.py +45 -32
  133. machineconfig/scripts/python/helpers/helpers5.py +1 -1
  134. machineconfig/scripts/python/helpers/repo_sync_helpers.py +32 -10
  135. machineconfig/scripts/python/mount_nfs.py +9 -16
  136. machineconfig/scripts/python/mount_nw_drive.py +10 -5
  137. machineconfig/scripts/python/mount_ssh.py +9 -7
  138. machineconfig/scripts/python/repos.py +216 -58
  139. machineconfig/scripts/python/snapshot.py +0 -1
  140. machineconfig/scripts/python/start_slidev.py +11 -6
  141. machineconfig/scripts/python/start_terminals.py +22 -16
  142. machineconfig/scripts/python/viewer_template.py +0 -1
  143. machineconfig/scripts/python/wifi_conn.py +49 -75
  144. machineconfig/scripts/python/wsl_windows_transfer.py +9 -7
  145. machineconfig/scripts/windows/checkout_version.ps1 +1 -3
  146. machineconfig/scripts/windows/choose_wezterm_theme.ps1 +1 -3
  147. machineconfig/scripts/windows/cloud_copy.ps1 +2 -6
  148. machineconfig/scripts/windows/cloud_manager.ps1 +1 -1
  149. machineconfig/scripts/windows/cloud_repo_sync.ps1 +1 -2
  150. machineconfig/scripts/windows/cloud_sync.ps1 +2 -2
  151. machineconfig/scripts/windows/croshell.ps1 +2 -2
  152. machineconfig/scripts/windows/devops.ps1 +1 -4
  153. machineconfig/scripts/windows/dotfile.ps1 +1 -3
  154. machineconfig/scripts/windows/fire.ps1 +1 -1
  155. machineconfig/scripts/windows/ftpx.ps1 +2 -2
  156. machineconfig/scripts/windows/gpt.ps1 +1 -1
  157. machineconfig/scripts/windows/kill_process.ps1 +1 -2
  158. machineconfig/scripts/windows/mcinit.ps1 +1 -1
  159. machineconfig/scripts/windows/mount_nfs.ps1 +1 -1
  160. machineconfig/scripts/windows/mount_ssh.ps1 +1 -1
  161. machineconfig/scripts/windows/pomodoro.ps1 +1 -1
  162. machineconfig/scripts/windows/py2exe.ps1 +1 -3
  163. machineconfig/scripts/windows/repos.ps1 +1 -1
  164. machineconfig/scripts/windows/scheduler.ps1 +1 -1
  165. machineconfig/scripts/windows/snapshot.ps1 +2 -2
  166. machineconfig/scripts/windows/start_slidev.ps1 +1 -1
  167. machineconfig/scripts/windows/start_terminals.ps1 +1 -1
  168. machineconfig/scripts/windows/wifi_conn.ps1 +1 -1
  169. machineconfig/scripts/windows/wsl_windows_transfer.ps1 +1 -3
  170. machineconfig/settings/lf/linux/lfrc +2 -1
  171. machineconfig/settings/linters/.ruff_cache/.gitignore +2 -0
  172. machineconfig/settings/linters/.ruff_cache/CACHEDIR.TAG +1 -0
  173. machineconfig/settings/lvim/windows/archive/config_additional.lua +1 -1
  174. machineconfig/settings/svim/linux/init.toml +1 -1
  175. machineconfig/settings/svim/windows/init.toml +1 -1
  176. machineconfig/setup_linux/web_shortcuts/croshell.sh +3 -52
  177. machineconfig/setup_linux/web_shortcuts/interactive.sh +6 -6
  178. machineconfig/setup_linux/web_shortcuts/ssh.sh +0 -4
  179. machineconfig/setup_windows/web_shortcuts/all.ps1 +2 -2
  180. machineconfig/setup_windows/web_shortcuts/ascii_art.ps1 +1 -1
  181. machineconfig/setup_windows/web_shortcuts/croshell.ps1 +1 -1
  182. machineconfig/setup_windows/web_shortcuts/interactive.ps1 +5 -5
  183. machineconfig/setup_windows/wt_and_pwsh/install_fonts.ps1 +51 -15
  184. machineconfig/setup_windows/wt_and_pwsh/set_pwsh_theme.py +58 -13
  185. machineconfig/setup_windows/wt_and_pwsh/set_wt_settings.py +45 -37
  186. machineconfig/utils/ai/generate_file_checklist.py +8 -10
  187. machineconfig/utils/ai/url2md.py +4 -2
  188. machineconfig/utils/cloud/onedrive/setup_oauth.py +1 -0
  189. machineconfig/utils/cloud/onedrive/transaction.py +63 -98
  190. machineconfig/utils/code.py +62 -41
  191. machineconfig/utils/installer.py +29 -35
  192. machineconfig/utils/installer_utils/installer_abc.py +11 -11
  193. machineconfig/utils/installer_utils/installer_class.py +155 -74
  194. machineconfig/utils/links.py +112 -31
  195. machineconfig/utils/notifications.py +211 -0
  196. machineconfig/utils/options.py +41 -42
  197. machineconfig/utils/path.py +13 -6
  198. machineconfig/utils/path_reduced.py +614 -311
  199. machineconfig/utils/procs.py +48 -42
  200. machineconfig/utils/scheduling.py +0 -1
  201. machineconfig/utils/source_of_truth.py +27 -0
  202. machineconfig/utils/ssh.py +146 -85
  203. machineconfig/utils/terminal.py +84 -37
  204. machineconfig/utils/upgrade_packages.py +91 -0
  205. machineconfig/utils/utils2.py +39 -50
  206. machineconfig/utils/utils5.py +195 -116
  207. machineconfig/utils/ve.py +13 -5
  208. {machineconfig-2.0.dist-info → machineconfig-2.2.dist-info}/METADATA +14 -13
  209. {machineconfig-2.0.dist-info → machineconfig-2.2.dist-info}/RECORD +212 -237
  210. machineconfig/jobs/__pycache__/__init__.cpython-311.pyc +0 -0
  211. machineconfig/jobs/python/__pycache__/__init__.cpython-311.pyc +0 -0
  212. machineconfig/jobs/python/__pycache__/python_ve_symlink.cpython-311.pyc +0 -0
  213. machineconfig/jobs/python/archive/python_tools.txt +0 -12
  214. machineconfig/jobs/python/vscode/__pycache__/select_interpreter.cpython-311.pyc +0 -0
  215. machineconfig/jobs/python_custom_installers/__pycache__/__init__.cpython-311.pyc +0 -0
  216. machineconfig/jobs/python_generic_installers/__pycache__/__init__.cpython-311.pyc +0 -0
  217. machineconfig/jobs/python_generic_installers/update.py +0 -3
  218. machineconfig/jobs/python_linux_installers/__pycache__/__init__.cpython-311.pyc +0 -0
  219. machineconfig/profile/__pycache__/__init__.cpython-311.pyc +0 -0
  220. machineconfig/profile/__pycache__/create.cpython-311.pyc +0 -0
  221. machineconfig/profile/__pycache__/shell.cpython-311.pyc +0 -0
  222. machineconfig/scripts/__pycache__/__init__.cpython-311.pyc +0 -0
  223. machineconfig/scripts/linux/activate_ve +0 -87
  224. machineconfig/scripts/python/__pycache__/__init__.cpython-311.pyc +0 -0
  225. machineconfig/scripts/python/__pycache__/cloud_copy.cpython-311.pyc +0 -0
  226. machineconfig/scripts/python/__pycache__/cloud_mount.cpython-311.pyc +0 -0
  227. machineconfig/scripts/python/__pycache__/cloud_sync.cpython-311.pyc +0 -0
  228. machineconfig/scripts/python/__pycache__/croshell.cpython-311.pyc +0 -0
  229. machineconfig/scripts/python/__pycache__/devops.cpython-311.pyc +0 -0
  230. machineconfig/scripts/python/__pycache__/devops_backup_retrieve.cpython-311.pyc +0 -0
  231. machineconfig/scripts/python/__pycache__/devops_devapps_install.cpython-311.pyc +0 -0
  232. machineconfig/scripts/python/__pycache__/devops_update_repos.cpython-311.pyc +0 -0
  233. machineconfig/scripts/python/__pycache__/fire_agents.cpython-311.pyc +0 -0
  234. machineconfig/scripts/python/__pycache__/fire_jobs.cpython-311.pyc +0 -0
  235. machineconfig/scripts/python/__pycache__/fire_jobs.cpython-313.pyc +0 -0
  236. machineconfig/scripts/python/__pycache__/get_zellij_cmd.cpython-311.pyc +0 -0
  237. machineconfig/scripts/python/__pycache__/repos.cpython-311.pyc +0 -0
  238. machineconfig/scripts/python/ai/__pycache__/init.cpython-311.pyc +0 -0
  239. machineconfig/scripts/python/ai/__pycache__/mcinit.cpython-311.pyc +0 -0
  240. machineconfig/scripts/python/helpers/__pycache__/__init__.cpython-311.pyc +0 -0
  241. machineconfig/scripts/python/helpers/__pycache__/__init__.cpython-313.pyc +0 -0
  242. machineconfig/scripts/python/helpers/__pycache__/cloud_helpers.cpython-311.pyc +0 -0
  243. machineconfig/scripts/python/helpers/__pycache__/helpers2.cpython-311.pyc +0 -0
  244. machineconfig/scripts/python/helpers/__pycache__/helpers4.cpython-311.pyc +0 -0
  245. machineconfig/scripts/python/helpers/__pycache__/helpers4.cpython-313.pyc +0 -0
  246. machineconfig/scripts/python/helpers/__pycache__/repo_sync_helpers.cpython-311.pyc +0 -0
  247. machineconfig/scripts/windows/activate_ve.ps1 +0 -54
  248. machineconfig/setup_linux/web_shortcuts/all.sh +0 -48
  249. machineconfig/setup_linux/web_shortcuts/update_system.sh +0 -48
  250. machineconfig/utils/utils.py +0 -95
  251. /machineconfig/setup_linux/web_shortcuts/{tmp.sh → android.sh} +0 -0
  252. {machineconfig-2.0.dist-info → machineconfig-2.2.dist-info}/WHEEL +0 -0
  253. {machineconfig-2.0.dist-info → machineconfig-2.2.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,9 @@
1
- """Cloud mount script
2
- """
3
-
1
+ """Cloud mount script"""
4
2
 
5
- from machineconfig.utils.utils import PROGRAM_PATH, choose_one_option
3
+ from machineconfig.utils.source_of_truth import PROGRAM_PATH
4
+ from machineconfig.utils.options import choose_one_option
6
5
  from machineconfig.utils.utils2 import read_ini
7
- from machineconfig.utils.path_reduced import P as PathExtended
6
+ from machineconfig.utils.path_reduced import PathExtended as PathExtended
8
7
 
9
8
  import platform
10
9
  import argparse
@@ -19,9 +18,12 @@ DEFAULT_MOUNT = "~/data/rclone"
19
18
 
20
19
 
21
20
  def get_rclone_config():
22
- if platform.system() == "Windows": config = read_ini(PathExtended.home().joinpath("AppData/Roaming/rclone/rclone.conf"))
23
- elif platform.system() in ["Linux", "Darwin"]: config = read_ini(PathExtended.home().joinpath(".config/rclone/rclone.conf"))
24
- else: raise ValueError("unsupported platform")
21
+ if platform.system() == "Windows":
22
+ config = read_ini(PathExtended.home().joinpath("AppData/Roaming/rclone/rclone.conf"))
23
+ elif platform.system() in ["Linux", "Darwin"]:
24
+ config = read_ini(PathExtended.home().joinpath(".config/rclone/rclone.conf"))
25
+ else:
26
+ raise ValueError("unsupported platform")
25
27
  return config
26
28
 
27
29
 
@@ -30,18 +32,22 @@ def get_mprocs_mount_txt(cloud: str, rclone_cmd: str, cloud_brand: str): # clou
30
32
  if platform.system() == "Windows":
31
33
  sub_text_path = PathExtended.tmpfile(suffix=".ps1")
32
34
  sub_text_path.parent.mkdir(parents=True, exist_ok=True)
33
- sub_text_path.write_text(f"""
35
+ sub_text_path.write_text(
36
+ f"""
34
37
  echo "{header}"
35
38
  iex 'rclone about {cloud}:'
36
39
  echo 'See {DEFAULT_MOUNT}/{cloud} for the mounted cloud'
37
40
 
38
41
  echo ''
39
- """, encoding="utf-8")
42
+ """,
43
+ encoding="utf-8",
44
+ )
40
45
  txt = f"""
41
46
  cd ~
42
47
  mprocs "powershell {sub_text_path}" "{rclone_cmd}" "btm" "timeout 2 & cd {DEFAULT_MOUNT} & lf" "timeout 2 & cd {DEFAULT_MOUNT} & pwsh" "pwsh" --names "info,service,monitor,explorer,main,terminal"
43
48
  """
44
- else: txt = f"""
49
+ else:
50
+ txt = f"""
45
51
  mprocs "echo 'see {DEFAULT_MOUNT}/{cloud} for the mounted cloud'; rclone about {cloud}:" "{rclone_cmd}" "btm" "cd {DEFAULT_MOUNT}; lf" "bash" "bash" --names "about,service,monitor,explorer,main,shell"
46
52
  """
47
53
  return txt
@@ -55,8 +61,10 @@ def mount(cloud: Optional[str], network: Optional[str], destination: Optional[st
55
61
  config = get_rclone_config()
56
62
  if cloud is None:
57
63
  res = choose_one_option(msg="which cloud", options=config.sections(), header="CLOUD MOUNT", default=None)
58
- if type(res) is str: cloud = res
59
- else: raise ValueError("no cloud selected")
64
+ if type(res) is str:
65
+ cloud = res
66
+ else:
67
+ raise ValueError("no cloud selected")
60
68
  print(f"🌩️ Selected cloud: {cloud}")
61
69
 
62
70
  if network is None:
@@ -74,30 +82,33 @@ def mount(cloud: Optional[str], network: Optional[str], destination: Optional[st
74
82
  elif platform.system() in ["Linux", "Darwin"]:
75
83
  system_name = "Linux" if platform.system() == "Linux" else "macOS"
76
84
  print(f"🐧 Creating mount directory on {system_name}...")
77
- try: mount_loc.mkdir(parents=True, exist_ok=True)
85
+ try:
86
+ mount_loc.mkdir(parents=True, exist_ok=True)
78
87
  except (FileExistsError, OSError) as err:
79
88
  # We need a umount command here.
80
89
  warning_line = "⚠️ WARNING: Mount directory issue"
81
90
  err_line = f"{err}"
82
91
  console.print(Panel(f"{warning_line}\n{err_line}", title="Warning", border_style="yellow"))
83
92
  pass
84
- else: raise ValueError("unsupported platform")
93
+ else:
94
+ raise ValueError("unsupported platform")
85
95
 
86
96
  elif network and platform.system() == "Windows":
87
97
  mount_loc = "X: --network-mode"
88
98
  print(f"🔌 Setting up network mount at {mount_loc}")
89
- else: raise ValueError("network mount only supported on windows")
99
+ else:
100
+ raise ValueError("network mount only supported on windows")
90
101
 
91
102
  mount_cmd = f"rclone mount {cloud}: {mount_loc} --vfs-cache-mode full --file-perms=0777"
92
103
  console.print(Panel(f"🚀 Preparing mount command:\n{mount_cmd}", border_style="blue"))
93
104
 
94
105
  # txt = get_mprocs_mount_txt(cloud, mount_cmd)
95
106
  if platform.system() == "Windows":
96
-
97
107
  txt = f"""
98
108
  wt --window 0 --profile "Windows PowerShell" --startingDirectory "$HOME/data/rclone" `; split-pane --horizontal --profile "Command Prompt" --size 0.2 powershell -Command "{mount_cmd}" `; split-pane --vertical --profile "Windows PowerShell" --size 0.2 powershell -NoExit -Command "rclone about {cloud}:" `; move-focus up
99
109
  """
100
- elif platform.system() in ["Linux", "Darwin"]: txt = f"""
110
+ elif platform.system() in ["Linux", "Darwin"]:
111
+ txt = f"""
101
112
 
102
113
  ZJ_SESSIONS=$(zellij list-sessions)
103
114
 
@@ -130,7 +141,8 @@ zellij run --direction up -- btm --default_widget_type net --expanded
130
141
  zellij run --in-place --cwd $HOME/data/rclone/{cloud} -- bash
131
142
  zellij action move-focus up
132
143
  """
133
- else: raise ValueError("unsupported platform")
144
+ else:
145
+ raise ValueError("unsupported platform")
134
146
  # print(f"running command: \n{txt}")
135
147
  PROGRAM_PATH.write_text(txt, encoding="utf-8")
136
148
  # draw success box dynamically
@@ -144,13 +156,13 @@ def main():
144
156
  main_title = "☁️ RCLONE CLOUD MOUNT"
145
157
  console.print(Panel(main_title, title_align="left", border_style="blue"))
146
158
 
147
- parser = argparse.ArgumentParser(description='mount cloud')
148
- parser.add_argument('cloud', nargs='?', type=str, default=None, help='cloud to mount')
149
- parser.add_argument('destination', nargs='?', type=str, default=None, help='destination to mount')
150
- parser.add_argument('--network', type=str, default=None, help='mount network drive')
159
+ parser = argparse.ArgumentParser(description="mount cloud")
160
+ parser.add_argument("cloud", nargs="?", type=str, default=None, help="cloud to mount")
161
+ parser.add_argument("destination", nargs="?", type=str, default=None, help="destination to mount")
162
+ parser.add_argument("--network", type=str, default=None, help="mount network drive")
151
163
  args = parser.parse_args()
152
164
  mount(cloud=args.cloud, network=args.network, destination=args.destination)
153
165
 
154
166
 
155
- if __name__ == '__main__':
167
+ if __name__ == "__main__":
156
168
  main()
@@ -1,43 +1,43 @@
1
1
  """utils"""
2
2
 
3
+ from pathlib import Path
3
4
  import git
4
- from machineconfig.utils.path_reduced import P as PathExtended
5
+ from machineconfig.utils.path_reduced import PathExtended as PathExtended
5
6
  from machineconfig.utils.terminal import Terminal
6
7
  from machineconfig.utils.utils2 import randstr, read_ini
7
8
 
8
9
  from machineconfig.scripts.python.helpers.repo_sync_helpers import fetch_dotfiles
9
- from machineconfig.utils.utils import CONFIG_PATH, DEFAULTS_PATH, PROGRAM_PATH, choose_one_option
10
+ from machineconfig.utils.source_of_truth import CONFIG_PATH, DEFAULTS_PATH, PROGRAM_PATH
11
+ from machineconfig.utils.options import choose_one_option
10
12
  from machineconfig.utils.code import get_shell_file_executing_python_script, write_shell_script_to_file
11
13
  import platform
12
14
  import argparse
13
15
  from typing import Optional, Literal
14
16
  from rich.console import Console
15
17
  from rich.panel import Panel
16
- # from rich.text import Text
17
18
 
18
19
  console = Console()
19
20
 
20
21
  _ = fetch_dotfiles
21
22
 
22
23
 
23
- def main(cloud: Optional[str] = None, path: Optional[str] = None, message: Optional[str] = None,
24
- action: Literal["ask", "pushLocalMerge", "overwriteLocal", "InspectRepos", "RemoveLocalRclone"] = "ask",
25
- pwd: Optional[str] = None):
24
+ def main(cloud: Optional[str] = None, path: Optional[str] = None, message: Optional[str] = None, action: Literal["ask", "pushLocalMerge", "overwriteLocal", "InspectRepos", "RemoveLocalRclone"] = "ask", pwd: Optional[str] = None):
26
25
  if cloud is None:
27
26
  try:
28
- cloud_resolved = read_ini(DEFAULTS_PATH)['general']['rclone_config_name']
27
+ cloud_resolved = read_ini(DEFAULTS_PATH)["general"]["rclone_config_name"]
29
28
  console.print(Panel(f"⚠️ Using default cloud: `{cloud_resolved}` from {DEFAULTS_PATH}", title="Default Cloud", border_style="yellow"))
30
29
  except FileNotFoundError:
31
30
  console.print(Panel(f"❌ ERROR: No cloud profile found\nLocation: {DEFAULTS_PATH}\nPlease set one up or provide one via the --cloud flag.", title="Error", border_style="red"))
32
31
  return ""
33
- else: cloud_resolved = cloud
32
+ else:
33
+ cloud_resolved = cloud
34
34
 
35
35
  # repo_root = PathExtended(args.repo).expanduser().absolute()
36
36
  repo_local_root = PathExtended.cwd() if path is None else PathExtended(path).expanduser().absolute()
37
37
  repo_local_obj = git.Repo(repo_local_root, search_parent_directories=True)
38
38
  repo_local_root = PathExtended(repo_local_obj.working_dir) # cwd might have been in a sub directory of repo_root, so its better to redefine it.
39
- CONFIG_PATH.joinpath("remote").mkdir(parents=True, exist_ok=True)
40
- repo_remote_root = CONFIG_PATH.joinpath("remote", repo_local_root.rel2home()) # .delete(sure=True)
39
+ PathExtended(CONFIG_PATH).joinpath("remote").mkdir(parents=True, exist_ok=True)
40
+ repo_remote_root = PathExtended(CONFIG_PATH).joinpath("remote", repo_local_root.rel2home()) # .delete(sure=True)
41
41
 
42
42
  try:
43
43
  console.print(Panel("📥 DOWNLOADING REMOTE REPOSITORY", title_align="left", border_style="blue"))
@@ -80,6 +80,7 @@ git pull originEnc master
80
80
  console.print(Panel("✅ Pull succeeded!\n🧹 Removing originEnc remote and local copy\n📤 Pushing merged repository to cloud storage", title="Success", border_style="green"))
81
81
  repo_remote_root.delete(sure=True)
82
82
  from git.remote import Remote
83
+
83
84
  Remote.remove(repo_local_obj, "originEnc")
84
85
  repo_local_root.to_cloud(cloud=cloud_resolved, zip=True, encrypt=True, rel2home=True, pwd=pwd, os_specific=False)
85
86
  return "success"
@@ -87,20 +88,21 @@ git pull originEnc master
87
88
  console.print(Panel(f"⚠️ MERGE FAILED\n💾 Keeping local copy of remote at:\n📂 {repo_remote_root}", title="Merge Failed", border_style="red"))
88
89
 
89
90
  # ================================================================================
90
- option1 = 'Delete remote copy and push local:'
91
+ option1 = "Delete remote copy and push local:"
91
92
  program_1_py = f"""
92
93
  from machineconfig.scripts.python.helpers.repo_sync_helpers import delete_remote_repo_copy_and_push_local as func
93
94
  func(remote_repo=r'{str(repo_remote_root)}', local_repo=r'{str(repo_local_root)}', cloud=r'{cloud_resolved}')
94
95
  """
95
- shell_file_1 = get_shell_file_executing_python_script(python_script=program_1_py, ve_name="ve")
96
+ shell_file_1 = get_shell_file_executing_python_script(python_script=program_1_py, ve_path=str(Path.home().joinpath("code", "machineconfig", ".venv")))
96
97
  # ================================================================================
97
98
 
98
- option2 = 'Delete local repo and replace it with remote copy:'
99
+ option2 = "Delete local repo and replace it with remote copy:"
99
100
  program_2 = f"""
100
101
  rm -rfd {repo_local_root}
101
102
  mv {repo_remote_root} {repo_local_root}
102
103
  """
103
- if platform.system() in ["Linux", "Darwin"]: program_2 += """
104
+ if platform.system() in ["Linux", "Darwin"]:
105
+ program_2 += """
104
106
  sudo chmod 600 $HOME/.ssh/*
105
107
  sudo chmod 700 $HOME/.ssh
106
108
  sudo chmod +x $HOME/dotfiles/scripts/linux -R
@@ -109,15 +111,15 @@ sudo chmod +x $HOME/dotfiles/scripts/linux -R
109
111
  shell_file_2 = write_shell_script_to_file(shell_script=program_2)
110
112
 
111
113
  # ================================================================================
112
- option3 = 'Inspect repos:'
114
+ option3 = "Inspect repos:"
113
115
  program_3_py = f"""
114
116
  from machineconfig.scripts.python.helper.repo_sync_helpers import inspect_repos as func
115
117
  func(repo_local_root=r'{str(repo_local_root)}', repo_remote_root=r'{str(repo_remote_root)}')
116
118
  """
117
- shell_file_3 = get_shell_file_executing_python_script(python_script=program_3_py, ve_name="ve")
119
+ shell_file_3 = get_shell_file_executing_python_script(python_script=program_3_py, ve_path=str(Path.home().joinpath("code", "machineconfig", ".venv")))
118
120
  # ================================================================================
119
121
 
120
- option4 = 'Remove problematic rclone file from repo and replace with remote:'
122
+ option4 = "Remove problematic rclone file from repo and replace with remote:"
121
123
  program_4 = f"""
122
124
  rm $HOME/dotfiles/creds/rclone/rclone.conf
123
125
  cp $HOME/.config/machineconfig/remote/dotfiles/creds/rclone/rclone.conf $HOME/dotfiles/creds/rclone
@@ -139,26 +141,36 @@ git commit -am "finished merging"
139
141
  match action:
140
142
  case "ask":
141
143
  choice = choose_one_option(options=[option1, option2, option3, option4], fzf=False)
142
- if choice == option1: program_content = shell_file_1.read_text(encoding="utf-8")
143
- elif choice == option2: program_content = program_2
144
- elif choice == option3: program_content = shell_file_3.read_text(encoding="utf-8")
145
- elif choice == option4: program_content = program_4
146
- else: raise NotImplementedError(f"Choice {choice} not implemented.")
147
- case "pushLocalMerge": program_content = shell_file_1.read_text(encoding="utf-8")
148
- case "overwriteLocal": program_content = program_2
149
- case "InspectRepos": program_content = shell_file_3.read_text(encoding="utf-8")
150
- case "RemoveLocalRclone": program_content = program_4
144
+ if choice == option1:
145
+ program_content = shell_file_1.read_text(encoding="utf-8")
146
+ elif choice == option2:
147
+ program_content = program_2
148
+ elif choice == option3:
149
+ program_content = shell_file_3.read_text(encoding="utf-8")
150
+ elif choice == option4:
151
+ program_content = program_4
152
+ else:
153
+ raise NotImplementedError(f"Choice {choice} not implemented.")
154
+ case "pushLocalMerge":
155
+ program_content = shell_file_1.read_text(encoding="utf-8")
156
+ case "overwriteLocal":
157
+ program_content = program_2
158
+ case "InspectRepos":
159
+ program_content = shell_file_3.read_text(encoding="utf-8")
160
+ case "RemoveLocalRclone":
161
+ program_content = program_4
151
162
  case _:
152
163
  raise ValueError(f"Unknown action: {action}")
153
164
  PROGRAM_PATH.write_text(program_content, encoding="utf-8")
154
165
  return program_content
155
166
 
167
+
156
168
  def args_parser():
157
169
  console.print(Panel("🔄 Repository Synchronization Utility", title_align="left", border_style="blue"))
158
170
 
159
171
  parser = argparse.ArgumentParser(description="Secure Repo CLI.")
160
172
  # parser.add_argument("cmd", help="command to run", choices=["pull", "push"])
161
- parser.add_argument("path", nargs='?', type=str, help="Repository path, defaults to cwd.", default=None)
173
+ parser.add_argument("path", nargs="?", type=str, help="Repository path, defaults to cwd.", default=None)
162
174
  # parser.add_argument("--share", help="Repository path, defaults to cwd.", action="store_true", default=False)
163
175
  parser.add_argument("--cloud", "-c", help="rclone cloud profile name.", default=None)
164
176
  parser.add_argument("--message", "-m", help="Commit Message", default=f"new message {randstr()}")
@@ -170,5 +182,6 @@ def args_parser():
170
182
  args = parser.parse_args()
171
183
  main(cloud=args.cloud, path=args.path, message=args.message, action=args.action)
172
184
 
185
+
173
186
  if __name__ == "__main__":
174
187
  args_parser()
@@ -5,7 +5,7 @@ TODO: use typer or typed-argument-parser to parse args
5
5
  from machineconfig.scripts.python.helpers.helpers2 import parse_cloud_source_target
6
6
  from machineconfig.scripts.python.helpers.cloud_helpers import Args
7
7
  from machineconfig.scripts.python.cloud_mount import get_mprocs_mount_txt
8
- from machineconfig.utils.utils import PROGRAM_PATH
8
+ from machineconfig.utils.source_of_truth import PROGRAM_PATH
9
9
  import argparse
10
10
  from rich.console import Console
11
11
  from rich.panel import Panel
@@ -57,9 +57,9 @@ def args_parser():
57
57
  target_line = f"Target: {target}"
58
58
  console.print(Panel(f"{source_line}\n{arrow_line}\n{target_line}", title=title, border_style="blue"))
59
59
  if delete:
60
- rclone_cmd = f"rclone sync -P \"{source}\" \"{target}\" --delete-during --transfers={transfers}"
60
+ rclone_cmd = f'rclone sync -P "{source}" "{target}" --delete-during --transfers={transfers}'
61
61
  else:
62
- rclone_cmd = f"rclone sync -P \"{source}\" \"{target}\" --transfers={transfers}"
62
+ rclone_cmd = f'rclone sync -P "{source}" "{target}" --transfers={transfers}'
63
63
 
64
64
  rclone_cmd += f" --progress --transfers={transfers} --verbose"
65
65
  # rclone_cmd += f" --vfs-cache-mode full"
@@ -78,5 +78,5 @@ def args_parser():
78
78
  PROGRAM_PATH.write_text(txt, encoding="utf-8")
79
79
 
80
80
 
81
- if __name__ == '__main__':
81
+ if __name__ == "__main__":
82
82
  args_parser()
@@ -1,16 +1,19 @@
1
+ #!/usr/bin/env -S uv run --project
2
+
1
3
  """
2
4
  croshell
3
5
  """
4
6
 
5
7
  import argparse
6
- from machineconfig.utils.path_reduced import P as PathExtended
8
+ from machineconfig.utils.path_reduced import PathExtended as PathExtended
7
9
  from machineconfig.utils.utils2 import randstr
8
- from machineconfig.utils.utils import PROGRAM_PATH, display_options
9
- from machineconfig.utils.ve import get_ve_path_and_ipython_profile, get_ve_activate_line
10
+ from machineconfig.utils.source_of_truth import PROGRAM_PATH
11
+ from machineconfig.utils.options import display_options
12
+ from machineconfig.utils.ve import get_ve_activate_line
10
13
  from typing import Optional
11
14
  from rich.console import Console
12
15
  from rich.panel import Panel
13
- from rich.text import Text # Added import for rich.text
16
+ from rich.text import Text # Added import for rich.text
14
17
  # from machineconfig.utils.utils2 import pprint
15
18
 
16
19
  console = Console()
@@ -59,14 +62,16 @@ except Exception as e:
59
62
  """
60
63
 
61
64
 
62
- def get_read_pyfile_pycode(path: PathExtended, as_module: bool, cmd: str=""):
63
- if as_module: pycode = fr"""
65
+ def get_read_pyfile_pycode(path: PathExtended, as_module: bool, cmd: str = ""):
66
+ if as_module:
67
+ pycode = rf"""
64
68
  import sys
65
69
  sys.path.append(r'{path.parent}')
66
70
  from {path.stem} import *
67
71
  {cmd}
68
72
  """
69
- else: pycode = f"""
73
+ else:
74
+ pycode = f"""
70
75
  __file__ = PathExtended(r'{path}')
71
76
  {path.read_text(encoding="utf-8")}
72
77
  """
@@ -76,7 +81,7 @@ __file__ = PathExtended(r'{path}')
76
81
  def build_parser():
77
82
  parser = argparse.ArgumentParser(description="Generic Parser to launch crocodile shell.")
78
83
  # A FLAG:
79
- parser.add_argument("--module", '-m', help="flag to run the file as a module as opposed to main.", action="store_true", default=False) # default is running as main, unless indicated by --module flag.
84
+ parser.add_argument("--module", "-m", help="flag to run the file as a module as opposed to main.", action="store_true", default=False) # default is running as main, unless indicated by --module flag.
80
85
  parser.add_argument("--newWindow", "-w", help="flag for running in new window.", action="store_true", default=False)
81
86
  parser.add_argument("--nonInteratctive", "-N", help="flag for a non-interactive session.", action="store_true", default=False)
82
87
  parser.add_argument("--python", "-p", help="flag to use python over IPython.", action="store_true", default=False)
@@ -98,8 +103,8 @@ def build_parser():
98
103
 
99
104
  # ==================================================================================
100
105
  # flags processing
101
- interactivity = '' if args.nonInteratctive else '-i'
102
- interpreter = 'python' if args.python else 'ipython'
106
+ interactivity = "" if args.nonInteratctive else "-i"
107
+ interpreter = "python" if args.python else "ipython"
103
108
  ipython_profile: Optional[str] = args.profile
104
109
  file = PathExtended.cwd() # initialization value, could be modified according to args.
105
110
 
@@ -107,15 +112,16 @@ def build_parser():
107
112
  text = "🖥️ Executing command from CLI argument"
108
113
  console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
109
114
  import textwrap
115
+
110
116
  program = textwrap.dedent(args.cmd)
111
117
 
112
118
  elif args.fzf:
113
119
  text = "🔍 Searching for Python files..."
114
120
  console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
115
121
  options = [str(item) for item in PathExtended.cwd().search("*.py", r=True)]
116
- file = display_options(msg="Choose a python file to run", options=options, fzf=True, multi=False, )
122
+ file = display_options(msg="Choose a python file to run", options=options, fzf=True, multi=False)
117
123
  assert isinstance(file, str)
118
- program = PathExtended(file).read_text(encoding='utf-8')
124
+ program = PathExtended(file).read_text(encoding="utf-8")
119
125
  text = f"📄 Selected file: {PathExtended(file).name}"
120
126
  console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
121
127
 
@@ -128,16 +134,16 @@ def build_parser():
128
134
 
129
135
  elif args.read != "":
130
136
  if args.streamlit_viewer:
131
- # text = "📊 STARTING STREAMLIT VIEWER"
132
- # console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
133
- # from machineconfig.scripts.python.viewer import run
134
- # py_file_path = run(data_path=args.read, data=None, get_figure=None)
135
- # final_program = f"""
136
- # #!/bin/bash
137
- # . $HOME/scripts/activate_ve 've'
138
- # streamlit run {py_file_path}
139
- # """
140
- # PROGRAM_PATH.write_text(data=final_program, encoding="utf-8")
137
+ # text = "📊 STARTING STREAMLIT VIEWER"
138
+ # console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
139
+ # from machineconfig.scripts.python.viewer import run
140
+ # py_file_path = run(data_path=args.read, data=None, get_figure=None)
141
+ # final_program = f"""
142
+ # #!/bin/bash
143
+ # . $HOME/scripts/activate_ve '.venv'
144
+ # streamlit run {py_file_path}
145
+ # """
146
+ # PROGRAM_PATH.write_text(data=final_program, encoding="utf-8")
141
147
  return None
142
148
  file = PathExtended(str(args.read).lstrip()).expanduser().absolute()
143
149
  program = get_read_data_pycode(str(file))
@@ -156,24 +162,29 @@ def build_parser():
156
162
 
157
163
  #%%
158
164
  from crocodile.croshell import *
165
+ from pathlib import Path
159
166
  print_header()
160
167
  print_logo(logo="crocodile")
168
+ print(f"🐊 Crocodile Shell | Running @ {Path.cwd()}")
161
169
  """
162
170
 
163
171
  pyfile = PathExtended.tmp().joinpath(f"tmp_scripts/python/croshell/{randstr()}.py")
164
172
  pyfile.parent.mkdir(parents=True, exist_ok=True)
165
173
 
166
- if args.read != "": title = "Reading Data"
167
- elif args.file != "": title = "Running Python File"
168
- else: title = "Executed code"
174
+ if args.read != "":
175
+ title = "Reading Data"
176
+ elif args.file != "":
177
+ title = "Running Python File"
178
+ else:
179
+ title = "Executed code"
169
180
  total_program = preprogram + add_print_header_pycode(str(pyfile), title=title) + program
170
181
 
171
- pyfile.write_text(total_program, encoding='utf-8')
182
+ pyfile.write_text(total_program, encoding="utf-8")
172
183
 
173
- ve_root_from_file, ipython_profile = get_ve_path_and_ipython_profile(PathExtended(file))
184
+ # ve_root_from_file, ipython_profile = get_ve_path_and_ipython_profile(PathExtended(file))
174
185
  ipython_profile = ipython_profile if ipython_profile is not None else "default"
175
186
  # ve_activateion_line = get_ve_activate_line(ve_name=args.ve or ve_profile_suggested, a_path=str(PathExtended.cwd()))
176
- activate_ve_line = get_ve_activate_line(ve_root=args.ve or ve_root_from_file or "$HOME/venvs/ve")
187
+ activate_ve_line = get_ve_activate_line(ve_root="$HOME/code/machineconfig/.venv")
177
188
  final_program = f"""
178
189
  #!/bin/bash
179
190
 
@@ -200,7 +211,7 @@ print_logo(logo="crocodile")
200
211
  # (PROGRAM_PATH + ".py").write_text(str(pyfile), encoding='utf-8')
201
212
 
202
213
  # if platform.system() == "Windows":
203
- # return subprocess.run([f"powershell", "-Command", res], shell=True, capture_output=False, text=True, check=True)
214
+ # return subprocess.run([f"powershell", "-Command", res], shell=True, capture_output=False, text=True, check=True)
204
215
  # else: return subprocess.run([res], shell=True, capture_output=False, text=True, check=True)
205
216
 
206
217