machineconfig 1.94__py3-none-any.whl → 1.95__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 (120) hide show
  1. machineconfig/cluster/data_transfer.py +2 -1
  2. machineconfig/cluster/job_params.py +1 -1
  3. machineconfig/cluster/script_execution.py +1 -1
  4. machineconfig/jobs/__pycache__/__init__.cpython-311.pyc +0 -0
  5. machineconfig/jobs/linux/msc/lid.sh +2 -4
  6. machineconfig/jobs/linux/msc/network.sh +3 -6
  7. machineconfig/jobs/python/check_installations.py +6 -6
  8. machineconfig/jobs/python/checkout_version.py +4 -4
  9. machineconfig/jobs/python/python_cargo_build_share.py +2 -2
  10. machineconfig/jobs/python/python_ve_symlink.py +4 -4
  11. machineconfig/jobs/python/vscode/api.py +2 -2
  12. machineconfig/jobs/python/vscode/link_ve.py +4 -4
  13. machineconfig/jobs/python/vscode/select_interpreter.py +4 -4
  14. machineconfig/jobs/python/vscode/sync_code.py +6 -6
  15. machineconfig/jobs/python_custom_installers/archive/ngrok.py +4 -4
  16. machineconfig/jobs/python_custom_installers/dev/aider.py +4 -4
  17. machineconfig/jobs/python_custom_installers/dev/alacritty.py +4 -4
  18. machineconfig/jobs/python_custom_installers/dev/brave.py +4 -4
  19. machineconfig/jobs/python_custom_installers/dev/bypass_paywall.py +4 -4
  20. machineconfig/jobs/python_custom_installers/dev/code.py +4 -4
  21. machineconfig/jobs/python_custom_installers/dev/docker.py +4 -4
  22. machineconfig/jobs/python_custom_installers/dev/docker_desktop.py +4 -4
  23. machineconfig/jobs/python_custom_installers/dev/espanso.py +8 -8
  24. machineconfig/jobs/python_custom_installers/dev/goes.py +4 -4
  25. machineconfig/jobs/python_custom_installers/dev/lvim.py +4 -4
  26. machineconfig/jobs/python_custom_installers/dev/nerdfont.py +4 -4
  27. machineconfig/jobs/python_custom_installers/dev/redis.py +4 -4
  28. machineconfig/jobs/python_custom_installers/dev/warp-cli.py +4 -4
  29. machineconfig/jobs/python_custom_installers/dev/wezterm.py +4 -4
  30. machineconfig/jobs/python_custom_installers/gh.py +6 -6
  31. machineconfig/jobs/python_custom_installers/hx.py +28 -58
  32. machineconfig/jobs/python_custom_installers/scripts/linux/brave.sh +4 -8
  33. machineconfig/jobs/python_custom_installers/scripts/linux/docker.sh +5 -10
  34. machineconfig/jobs/python_custom_installers/scripts/linux/docker_start.sh +3 -6
  35. machineconfig/jobs/python_custom_installers/scripts/linux/edge.sh +3 -6
  36. machineconfig/jobs/python_custom_installers/scripts/linux/nerdfont.sh +5 -10
  37. machineconfig/jobs/python_custom_installers/scripts/linux/pgsql.sh +4 -8
  38. machineconfig/jobs/python_custom_installers/scripts/linux/redis.sh +5 -10
  39. machineconfig/jobs/python_custom_installers/scripts/linux/timescaledb.sh +6 -12
  40. machineconfig/jobs/python_custom_installers/scripts/linux/vscode.sh +9 -8
  41. machineconfig/jobs/python_custom_installers/scripts/linux/warp-cli.sh +5 -10
  42. machineconfig/jobs/python_custom_installers/scripts/linux/wezterm.sh +3 -6
  43. machineconfig/jobs/python_generic_installers/__pycache__/__init__.cpython-311.pyc +0 -0
  44. machineconfig/jobs/python_linux_installers/__pycache__/__init__.cpython-311.pyc +0 -0
  45. machineconfig/profile/shell.py +26 -47
  46. machineconfig/scripts/__pycache__/__init__.cpython-311.pyc +0 -0
  47. machineconfig/scripts/cloud/init.sh +9 -18
  48. machineconfig/scripts/linux/fire +5 -24
  49. machineconfig/scripts/linux/share_cloud.sh +6 -12
  50. machineconfig/scripts/python/__pycache__/__init__.cpython-311.pyc +0 -0
  51. machineconfig/scripts/python/__pycache__/cloud_copy.cpython-311.pyc +0 -0
  52. machineconfig/scripts/python/__pycache__/cloud_mount.cpython-311.pyc +0 -0
  53. machineconfig/scripts/python/__pycache__/cloud_repo_sync.cpython-311.pyc +0 -0
  54. machineconfig/scripts/python/__pycache__/cloud_sync.cpython-311.pyc +0 -0
  55. machineconfig/scripts/python/__pycache__/croshell.cpython-311.pyc +0 -0
  56. machineconfig/scripts/python/__pycache__/devops.cpython-311.pyc +0 -0
  57. machineconfig/scripts/python/__pycache__/devops_devapps_install.cpython-311.pyc +0 -0
  58. machineconfig/scripts/python/__pycache__/devops_update_repos.cpython-311.pyc +0 -0
  59. machineconfig/scripts/python/__pycache__/fire_jobs.cpython-311.pyc +0 -0
  60. machineconfig/scripts/python/__pycache__/get_zellij_cmd.cpython-311.pyc +0 -0
  61. machineconfig/scripts/python/__pycache__/repos.cpython-311.pyc +0 -0
  62. machineconfig/scripts/python/archive/im2text.py +30 -30
  63. machineconfig/scripts/python/archive/tmate_conn.py +10 -13
  64. machineconfig/scripts/python/archive/tmate_start.py +12 -16
  65. machineconfig/scripts/python/choose_wezterm_theme.py +9 -18
  66. machineconfig/scripts/python/cloud_copy.py +38 -93
  67. machineconfig/scripts/python/cloud_manager.py +61 -53
  68. machineconfig/scripts/python/cloud_mount.py +23 -34
  69. machineconfig/scripts/python/cloud_repo_sync.py +20 -69
  70. machineconfig/scripts/python/cloud_sync.py +35 -45
  71. machineconfig/scripts/python/croshell.py +48 -73
  72. machineconfig/scripts/python/devops.py +50 -104
  73. machineconfig/scripts/python/devops_add_identity.py +41 -101
  74. machineconfig/scripts/python/devops_add_ssh_key.py +33 -140
  75. machineconfig/scripts/python/devops_backup_retrieve.py +23 -112
  76. machineconfig/scripts/python/devops_devapps_install.py +0 -4
  77. machineconfig/scripts/python/devops_update_repos.py +1 -1
  78. machineconfig/scripts/python/fire_jobs.py +73 -25
  79. machineconfig/scripts/python/helpers/__pycache__/__init__.cpython-311.pyc +0 -0
  80. machineconfig/scripts/python/helpers/__pycache__/cloud_helpers.cpython-311.pyc +0 -0
  81. machineconfig/scripts/python/helpers/__pycache__/helpers2.cpython-311.pyc +0 -0
  82. machineconfig/scripts/python/helpers/__pycache__/helpers4.cpython-311.pyc +0 -0
  83. machineconfig/scripts/python/helpers/__pycache__/repo_sync_helpers.cpython-311.pyc +0 -0
  84. machineconfig/scripts/python/helpers/cloud_helpers.py +37 -34
  85. machineconfig/scripts/python/helpers/helpers2.py +17 -31
  86. machineconfig/scripts/python/helpers/repo_sync_helpers.py +19 -54
  87. machineconfig/scripts/python/pomodoro.py +1 -1
  88. machineconfig/scripts/python/repos.py +49 -34
  89. machineconfig/scripts/python/wifi_conn.py +5 -3
  90. machineconfig/scripts/windows/fire.ps1 +27 -15
  91. machineconfig/settings/__pycache__/__init__.cpython-311.pyc +0 -0
  92. machineconfig/settings/shells/ipy/profiles/default/__pycache__/__init__.cpython-311.pyc +0 -0
  93. machineconfig/settings/shells/ipy/profiles/default/startup/__pycache__/__init__.cpython-311.pyc +0 -0
  94. machineconfig/settings/shells/ipy/profiles/default/startup/__pycache__/playext.cpython-311.pyc +0 -0
  95. machineconfig/setup_linux/nix/cli_installation.sh +9 -18
  96. machineconfig/setup_linux/others/openssh-server_add_pub_key.sh +3 -6
  97. machineconfig/setup_linux/web_shortcuts/all.sh +5 -10
  98. machineconfig/setup_linux/web_shortcuts/ascii_art.sh +7 -14
  99. machineconfig/setup_linux/web_shortcuts/croshell.sh +6 -12
  100. machineconfig/setup_linux/web_shortcuts/interactive.sh +34 -68
  101. machineconfig/setup_linux/web_shortcuts/ssh.sh +8 -16
  102. machineconfig/setup_linux/web_shortcuts/update_system.sh +7 -14
  103. machineconfig/setup_windows/wt_and_pwsh/set_wt_settings.py +16 -12
  104. machineconfig/utils/ai/browser_user_wrapper.py +60 -45
  105. machineconfig/utils/ai/generate_file_checklist.py +4 -7
  106. machineconfig/utils/ai/url2md.py +13 -5
  107. machineconfig/utils/{utils_code.py → code.py} +4 -10
  108. machineconfig/utils/installer.py +4 -10
  109. machineconfig/utils/{utils_links.py → links.py} +9 -20
  110. machineconfig/utils/{utils_options.py → options.py} +10 -20
  111. machineconfig/utils/{utils_path.py → path.py} +28 -80
  112. machineconfig/utils/procs.py +26 -30
  113. machineconfig/utils/scheduling.py +11 -11
  114. machineconfig/utils/utils.py +12 -19
  115. machineconfig/utils/ve.py +5 -21
  116. machineconfig/utils/ve_utils/ve2.py +15 -2
  117. {machineconfig-1.94.dist-info → machineconfig-1.95.dist-info}/METADATA +4 -2
  118. {machineconfig-1.94.dist-info → machineconfig-1.95.dist-info}/RECORD +120 -118
  119. {machineconfig-1.94.dist-info → machineconfig-1.95.dist-info}/WHEEL +1 -1
  120. {machineconfig-1.94.dist-info → machineconfig-1.95.dist-info}/top_level.txt +0 -0
@@ -6,10 +6,16 @@ from crocodile.meta import Terminal
6
6
  from crocodile.core import randstr
7
7
 
8
8
  from machineconfig.scripts.python.helpers.repo_sync_helpers import fetch_dotfiles
9
- from machineconfig.utils.utils import CONFIG_PATH, DEFAULTS_PATH, PROGRAM_PATH, get_shell_file_executing_python_script, write_shell_script_to_file, choose_one_option
9
+ from machineconfig.utils.utils import CONFIG_PATH, DEFAULTS_PATH, PROGRAM_PATH, choose_one_option
10
+ from machineconfig.utils.code import get_shell_file_executing_python_script, write_shell_script_to_file
10
11
  import platform
11
12
  import argparse
12
13
  from typing import Optional, Literal
14
+ from rich.console import Console
15
+ from rich.panel import Panel
16
+ from rich.text import Text
17
+
18
+ console = Console()
13
19
 
14
20
  _ = fetch_dotfiles
15
21
 
@@ -20,20 +26,9 @@ def main(cloud: Optional[str] = None, path: Optional[str] = None, message: Optio
20
26
  if cloud is None:
21
27
  try:
22
28
  cloud_resolved = Read.ini(DEFAULTS_PATH)['general']['rclone_config_name']
23
- print(f"""
24
- ╭{'─' * 70}╮
25
- │ ⚠️ Using default cloud: `{cloud_resolved}` from {DEFAULTS_PATH} │
26
- ╰{'─' * 70}╯
27
- """)
29
+ console.print(Panel(f"⚠️ Using default cloud: `{cloud_resolved}` from {DEFAULTS_PATH}", title="Default Cloud", border_style="yellow"))
28
30
  except FileNotFoundError:
29
- print(f"""
30
- ╔{'═' * 70}╗
31
- ║ ❌ ERROR: No cloud profile found ║
32
- ╠{'═' * 70}╣
33
- ║ Location: {DEFAULTS_PATH}
34
- ║ Please set one up or provide one via the --cloud flag. ║
35
- ╚{'═' * 70}╝
36
- """)
31
+ 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"))
37
32
  return ""
38
33
  else: cloud_resolved = cloud
39
34
 
@@ -45,48 +40,28 @@ def main(cloud: Optional[str] = None, path: Optional[str] = None, message: Optio
45
40
  repo_remote_root = CONFIG_PATH.joinpath("remote", repo_local_root.rel2home()) # .delete(sure=True)
46
41
 
47
42
  try:
48
- print(f"""
49
- ╔{'═' * 70}╗
50
- ║ 📥 DOWNLOADING REMOTE REPOSITORY ║
51
- ╚{'═' * 70}╝
52
- """)
43
+ console.print(Panel("📥 DOWNLOADING REMOTE REPOSITORY", title_align="left", border_style="blue"))
53
44
  remote_path = repo_local_root.get_remote_path(rel2home=True, os_specific=False, root="myhome") + ".zip.enc"
54
45
  repo_remote_root.from_cloud(remotepath=remote_path, cloud=cloud_resolved, unzip=True, decrypt=True, rel2home=True, os_specific=False, pwd=pwd)
55
46
  except AssertionError:
56
- print(f"""
57
- ╔{'═' * 70}╗
58
- ║ 🆕 Remote repository doesn't exist ║
59
- ║ 📤 Creating new remote and exiting... ║
60
- ╚{'═' * 70}╝
61
- """)
47
+ console.print(Panel("🆕 Remote repository doesn't exist\n📤 Creating new remote and exiting...", title_align="left", border_style="green"))
62
48
  repo_local_root.to_cloud(cloud=cloud_resolved, zip=True, encrypt=True, rel2home=True, pwd=pwd, os_specific=False)
63
49
  return ""
64
50
 
65
51
  repo_remote_obj = git.Repo(repo_remote_root)
66
52
  if repo_remote_obj.is_dirty():
67
- print(f"""
68
- ╔{'═' * 70}╗
69
- ║ ⚠️ WARNING: REMOTE REPOSITORY IS DIRTY ║
70
- ╠{'═' * 70}╣
71
- ║ Location: {repo_remote_root}
72
- ║ Please commit or stash changes before proceeding. ║
73
- ╚{'═' * 70}╝
74
- """)
53
+ console.print(Panel(f"⚠️ WARNING: REMOTE REPOSITORY IS DIRTY\nLocation: {repo_remote_root}\nPlease commit or stash changes before proceeding.", title="Warning", border_style="yellow"))
75
54
 
76
55
  script = f"""
77
56
  echo ""
78
- echo "╔{'═' * 70}╗"
79
- echo "║ 💾 COMMITTING LOCAL CHANGES ║"
80
- echo "╚{'═' * 70}╝"
57
+ echo 'echo -e "\\033[1;34m═════ COMMITTING LOCAL CHANGES ═════\\033[0m"'
81
58
  cd {repo_local_root}
82
59
  git status
83
60
  git add .
84
61
  git commit -am "{message}"
85
62
  echo ""
86
63
  echo ""
87
- echo "╔{'═' * 70}╗"
88
- echo "║ 🔄 PULLING LATEST FROM REMOTE ║"
89
- echo "╚{'═' * 70}╝"
64
+ echo 'echo -e "\\033[1;34m═════ PULLING LATEST FROM REMOTE ═════\\033[0m"'
90
65
  cd {repo_local_root}
91
66
  echo '-> Trying to removing originEnc remote from local repo if it exists.'
92
67
  # git remote remove originEnc
@@ -102,32 +77,18 @@ git pull originEnc master
102
77
  res = Terminal().run(f". {shell_path}", shell="powershell").capture().print()
103
78
 
104
79
  if res.is_successful(strict_err=True, strict_returcode=True):
105
- print(f"""
106
- ╔{'═' * 70}╗
107
- ║ ✅ Pull succeeded! ║
108
- ╠{'═' * 70}╣
109
- ║ 🧹 Removing originEnc remote and local copy ║
110
- ║ 📤 Pushing merged repository to cloud storage ║
111
- ╚{'═' * 70}╝
112
- """)
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"))
113
81
  repo_remote_root.delete(sure=True)
114
82
  from git.remote import Remote
115
83
  Remote.remove(repo_local_obj, "originEnc")
116
84
  repo_local_root.to_cloud(cloud=cloud_resolved, zip=True, encrypt=True, rel2home=True, pwd=pwd, os_specific=False)
117
85
  else:
118
- print(f"""
119
- ╔{'═' * 70}╗
120
- ║ ⚠️ MERGE FAILED ║
121
- ╠{'═' * 70}╣
122
- ║ 💾 Keeping local copy of remote at: ║
123
- ║ 📂 {repo_remote_root}
124
- ╚{'═' * 70}╝
125
- """)
86
+ console.print(Panel(f"⚠️ MERGE FAILED\n💾 Keeping local copy of remote at:\n📂 {repo_remote_root}", title="Merge Failed", border_style="red"))
126
87
 
127
88
  # ================================================================================
128
89
  option1 = 'Delete remote copy and push local:'
129
90
  program_1_py = f"""
130
- from machineconfig.scripts.python.cloud_repo_sync import delete_remote_repo_copy_and_push_local as func
91
+ from machineconfig.scripts.python.helpers.repo_sync_helpers import delete_remote_repo_copy_and_push_local as func
131
92
  func(remote_repo=r'{repo_remote_root.to_str()}', local_repo=r'{repo_local_root.to_str()}', cloud=r'{cloud_resolved}')
132
93
  """
133
94
  shell_file_1 = get_shell_file_executing_python_script(python_script=program_1_py, ve_name="ve")
@@ -149,7 +110,7 @@ sudo chmod +x $HOME/dotfiles/scripts/linux -R
149
110
  # ================================================================================
150
111
  option3 = 'Inspect repos:'
151
112
  program_3_py = f"""
152
- from machineconfig.scripts.python.cloud_repo_sync import inspect_repos as func
113
+ from machineconfig.scripts.python.helper.repo_sync_helpers import inspect_repos as func
153
114
  func(repo_local_root=r'{repo_local_root.to_str()}', repo_remote_root=r'{repo_remote_root.to_str()}')
154
115
  """
155
116
  shell_file_3 = get_shell_file_executing_python_script(python_script=program_3_py, ve_name="ve")
@@ -166,13 +127,7 @@ git commit -am "finished merging"
166
127
  shell_file_4 = write_shell_script_to_file(shell_script=program_4)
167
128
  # ================================================================================
168
129
 
169
- print(f"""
170
- ╔{'═' * 70}╗
171
- ║ 🔄 RESOLVE MERGE CONFLICT ║
172
- ╠{'═' * 70}╣
173
- ║ Choose an option to resolve the conflict: ║
174
- ╚{'═' * 70}╝
175
- """)
130
+ console.print(Panel("🔄 RESOLVE MERGE CONFLICT\nChoose an option to resolve the conflict:", title_align="left", border_style="blue"))
176
131
 
177
132
  print(f"• 1️⃣ {option1:75} 👉 {shell_file_1}")
178
133
  print(f"• 2️⃣ {option2:75} 👉 {shell_file_2}")
@@ -196,11 +151,7 @@ git commit -am "finished merging"
196
151
  return program_content
197
152
 
198
153
  def args_parser():
199
- print(f"""
200
- ╔{'═' * 70}╗
201
- ║ 🔄 Repository Synchronization Utility ║
202
- ╚{'═' * 70}╝
203
- """)
154
+ console.print(Panel("🔄 Repository Synchronization Utility", title_align="left", border_style="blue"))
204
155
 
205
156
  parser = argparse.ArgumentParser(description="Secure Repo CLI.")
206
157
  # parser.add_argument("cmd", help="command to run", choices=["pull", "push"])
@@ -7,39 +7,35 @@ from machineconfig.scripts.python.helpers.cloud_helpers import Args
7
7
  from machineconfig.scripts.python.cloud_mount import get_mprocs_mount_txt
8
8
  from machineconfig.utils.utils import PROGRAM_PATH
9
9
  import argparse
10
+ from rich.console import Console
11
+ from rich.panel import Panel
12
+
13
+ console = Console()
10
14
 
11
15
 
12
16
  def args_parser():
13
- print(f"""
14
- ╔{'═' * 70}╗
15
- ║ ☁️ Cloud Sync Utility ║
16
- ╚{'═' * 70}╝
17
- """)
18
-
17
+ title = "☁️ Cloud Sync Utility"
18
+ console.print(Panel(title, title_align="left", border_style="blue"))
19
19
  parser = argparse.ArgumentParser(description="""A wrapper for rclone sync and rclone bisync, with some extra features.""")
20
-
21
20
  parser.add_argument("source", help="source", default=None)
22
21
  parser.add_argument("target", help="target", default=None)
23
-
24
22
  parser.add_argument("--transfers", "-t", help="Number of threads in syncing.", default=10) # default is False
25
23
  parser.add_argument("--root", "-R", help="Remote root.", default="myhome") # default is False
26
-
27
24
  parser.add_argument("--key", "-k", help="Key for encryption", default=None)
28
25
  parser.add_argument("--pwd", "-P", help="Password for encryption", default=None)
29
26
  parser.add_argument("--encrypt", "-e", help="Decrypt after receiving.", action="store_true") # default is False
30
27
  parser.add_argument("--zip", "-z", help="unzip after receiving.", action="store_true") # default is False
31
-
32
28
  parser.add_argument("--bisync", "-b", help="Bidirectional sync.", action="store_true") # default is False
33
29
  parser.add_argument("--delete", "-D", help="Delete files in remote that are not in local.", action="store_true") # default is False
34
30
  parser.add_argument("--verbose", "-v", help="Verbosity of mprocs to show details of syncing.", action="store_true") # default is False
35
31
 
36
32
  args = parser.parse_args()
37
33
  args_dict = vars(args)
38
- source: str=args_dict.pop("source")
39
- target: str=args_dict.pop("target")
40
- verbose: bool=args_dict.pop("verbose")
41
- delete: bool=args_dict.pop("delete")
42
- bisync: bool=args_dict.pop("bisync")
34
+ source: str = args_dict.pop("source")
35
+ target: str = args_dict.pop("target")
36
+ verbose: bool = args_dict.pop("verbose")
37
+ delete: bool = args_dict.pop("delete")
38
+ bisync: bool = args_dict.pop("bisync")
43
39
  transfers: int = args_dict.pop("transfers")
44
40
  args_obj = Args(**args_dict)
45
41
 
@@ -49,42 +45,36 @@ def args_parser():
49
45
  cloud, source, target = parse_cloud_source_target(args=args_obj, source=source, target=target)
50
46
  # map short flags to long flags (-u -> --upload), for easier use in the script
51
47
  if bisync:
52
- print(f"""
53
- ╔{'═' * 70}
54
- 🔄 BI-DIRECTIONAL SYNC ║
55
- {'═' * 70}╣
56
- ║ Source: {source}
57
- ║ Target: {target}
58
- ╚{'═' * 70}╝
59
- """)
48
+ title = "🔄 BI-DIRECTIONAL SYNC"
49
+ source_line = f"Source: {source}"
50
+ target_line = f"Target: {target}"
51
+ console.print(Panel(f"{source_line}\n{target_line}", title=title, border_style="blue"))
60
52
  rclone_cmd = f"""rclone bisync '{source}' '{target}' --resync"""
61
53
  else:
62
- print(f"""
63
- ╔{'═' * 70}
64
- 📤 ONE-WAY SYNC ║
65
- ╠{'═' * 70}
66
- Source: {source}
67
- ↓ ║
68
- Target: {target}
69
- ╚{'═' * 70}╝
70
- """)
71
- rclone_cmd = f"""rclone sync '{source}' '{target}' """
54
+ title = "📤 ONE-WAY SYNC"
55
+ source_line = f"Source: {source}"
56
+ arrow_line = "↓"
57
+ target_line = f"Target: {target}"
58
+ console.print(Panel(f"{source_line}\n{arrow_line}\n{target_line}", title=title, border_style="blue"))
59
+ if delete:
60
+ rclone_cmd = f"rclone sync -P \"{source}\" \"{target}\" --delete-during --transfers={transfers}"
61
+ else:
62
+ rclone_cmd = f"rclone sync -P \"{source}\" \"{target}\" --transfers={transfers}"
72
63
 
73
64
  rclone_cmd += f" --progress --transfers={transfers} --verbose"
74
65
  # rclone_cmd += f" --vfs-cache-mode full"
75
- if delete: rclone_cmd += " --delete-during"
66
+ if delete:
67
+ rclone_cmd += " --delete-during"
68
+
69
+ if verbose:
70
+ txt = get_mprocs_mount_txt(cloud=cloud, rclone_cmd=rclone_cmd, cloud_brand="Unknown")
71
+ else:
72
+ txt = f"""{rclone_cmd}"""
73
+
74
+ title = "🚀 EXECUTING COMMAND"
75
+ cmd_line = f"{rclone_cmd[:65]}..."
76
+ console.print(Panel(f"{title}\n{cmd_line}", title="[bold blue]Command[/bold blue]", expand=False))
76
77
 
77
- if verbose: txt = get_mprocs_mount_txt(cloud=cloud, rclone_cmd=rclone_cmd, cloud_brand="Unknown")
78
- else: txt = f"""{rclone_cmd}"""
79
-
80
- print(f"""
81
- ╔{'═' * 70}╗
82
- ║ 🚀 EXECUTING COMMAND ║
83
- ╠{'═' * 70}╣
84
- ║ {rclone_cmd[:65]}... ║
85
- ╚{'═' * 70}╝
86
- """)
87
-
88
78
  PROGRAM_PATH.write_text(txt)
89
79
 
90
80
 
@@ -8,6 +8,11 @@ from crocodile.core_modules.core_1 import randstr
8
8
  from machineconfig.utils.utils import PROGRAM_PATH, display_options
9
9
  from machineconfig.utils.ve_utils.ve1 import get_ve_name_and_ipython_profile, get_ve_activate_line
10
10
  from typing import Optional
11
+ from rich.console import Console
12
+ from rich.panel import Panel
13
+ from rich.text import Text # Added import for rich.text
14
+
15
+ console = Console()
11
16
 
12
17
 
13
18
  def add_print_header_pycode(path: str, title: str):
@@ -28,35 +33,27 @@ except Exception: print(pycode)
28
33
 
29
34
 
30
35
  def get_read_data_pycode(path: str):
31
- pycode = f"""
32
- p = P(r\'{path}\').absolute()
36
+ # We need to be careful here since we're generating Python code as a string
37
+ # that will use f-strings itself
38
+ return f"""
39
+ from rich.panel import Panel
40
+ from rich.text import Text
41
+ from rich.console import Console
42
+ console = Console()
43
+ p = P(r'{path}').absolute()
33
44
  try:
34
45
  dat = p.readit()
35
- if isinstance(dat, dict):
36
- print(f'''
37
- ╔{'═' * 70}╗
38
- ║ 📄 File Data: {{p.name}}
39
- ╚{'═' * 70}╝
40
- ''')
46
+ if isinstance(dat, dict):
47
+ panel_title = f"📄 File Data: {{p.name}}"
48
+ console.print(Panel(Text(str(dat), justify="left"), title=panel_title, expand=False))
41
49
  Struct(dat).print(as_config=True, title=p.name)
42
- else:
43
- print(f'''
44
- ╔{'═' * 70}╗
45
- ║ 📄 Successfully read the file: {{p.name}}
46
- ╚{'═' * 70}╝
47
- ''')
50
+ else:
51
+ panel_title = f"📄 Successfully read the file: {{p.name}}"
52
+ console.print(Panel(Text(str(dat), justify="left"), title=panel_title, expand=False))
48
53
  except Exception as e:
49
- print(f'''
50
- ╔{'═' * 70}╗
51
- ║ ❌ ERROR READING FILE ║
52
- ╠{'═' * 70}╣
53
- ║ File: {{p.name}}
54
- ║ Error: {{e}}
55
- ╚{'═' * 70}╝
56
- ''')
57
-
54
+ error_message = f'''❌ ERROR READING FILE\nFile: {{p.name}}\nError: {{e}}'''
55
+ console.print(Panel(Text(error_message, justify="left"), title="Error", expand=False, border_style="red"))
58
56
  """
59
- return pycode
60
57
 
61
58
 
62
59
  def get_read_pyfile_pycode(path: P, as_module: bool, cmd: str=""):
@@ -104,47 +101,32 @@ def build_parser():
104
101
  file = P.cwd() # initialization value, could be modified according to args.
105
102
 
106
103
  if args.cmd != "":
107
- print(f"""
108
- ╭{'─' * 70}╮
109
- │ 🖥️ Executing command from CLI argument │
110
- ╰{'─' * 70}╯
111
- """)
104
+ text = "🖥️ Executing command from CLI argument"
105
+ console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
112
106
  import textwrap
113
107
  program = textwrap.dedent(args.cmd)
114
108
 
115
109
  elif args.fzf:
116
- print(f"""
117
- ╭{'─' * 70}╮
118
- │ 🔍 Searching for Python files... │
119
- ╰{'─' * 70}╯
120
- """)
110
+ text = "🔍 Searching for Python files..."
111
+ console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
121
112
  options = P.cwd().search("*.py", r=True).apply(str).list
122
113
  file = display_options(msg="Choose a python file to run", options=options, fzf=True, multi=False, )
123
114
  assert isinstance(file, str)
124
115
  program = P(file).read_text(encoding='utf-8')
125
- print(f"""
126
- ╭{'─' * 70}╮
127
- │ 📄 Selected file: {P(file).name} │
128
- ╰{'─' * 70}╯
129
- """)
116
+ text = f"📄 Selected file: {P(file).name}"
117
+ console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
130
118
 
131
119
  elif args.file != "":
132
120
  file = P(args.file.lstrip()).expanduser().absolute()
133
121
  program = get_read_pyfile_pycode(file, as_module=args.module, cmd=args.cmd)
134
- print(f"""
135
- {'' * 70}
136
- 📄 Loading file: {file.name} │
137
- │ 🔄 Mode: {'Module' if args.module else 'Script'} │
138
- ╰{'─' * 70}╯
139
- """)
122
+ text1 = f"📄 Loading file: {file.name}"
123
+ text2 = f"🔄 Mode: {'Module' if args.module else 'Script'}"
124
+ console.print(Panel(f"{text1}\n{text2}", title="[bold blue]Info[/bold blue]"))
140
125
 
141
126
  elif args.read != "":
142
127
  if args.streamlit_viewer:
143
- print(f"""
144
- ╔{'═' * 70}╗
145
- ║ 📊 STARTING STREAMLIT VIEWER ║
146
- ╚{'═' * 70}╝
147
- """)
128
+ text = "📊 STARTING STREAMLIT VIEWER"
129
+ console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
148
130
  from machineconfig.scripts.python.viewer import run
149
131
  py_file_path = run(data_path=args.read, data=None, get_figure=None)
150
132
  final_program = f"""
@@ -156,21 +138,17 @@ streamlit run {py_file_path}
156
138
  return None
157
139
  file = P(str(args.read).lstrip()).expanduser().absolute()
158
140
  program = get_read_data_pycode(str(file))
159
- print(f"""
160
- ╭{'─' * 70}╮
161
- │ 📄 Reading data from: {file.name} │
162
- ╰{'─' * 70}╯
163
- """)
164
-
165
- else: # just run croshell.py interactively
141
+ text = f"📄 Reading data from: {file.name}"
142
+ console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
143
+
144
+ else: # if nothing is specified, then run in interactive mode.
145
+ text = "⌨️ Entering interactive mode"
146
+ console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
147
+ # from machineconfig.scripts.python.croshell import InteractiveShell
148
+ # InteractiveShell().run()
149
+ # return None
166
150
  program = ""
167
151
 
168
- # from IPython import start_ipython
169
- # start_ipython(argv=program.split(' ')[1:])
170
- # return
171
- # Clear-Host;
172
- # # --autocall 1 in order to enable shell-like behaviour: e.g.: P x is interpretred as P(x)
173
-
174
152
  preprogram = """
175
153
 
176
154
  #%%
@@ -208,16 +186,13 @@ print_logo(logo="crocodile")
208
186
  fire_line += f" {str(pyfile)}"
209
187
 
210
188
  final_program += fire_line
211
-
212
- print(f"""
213
- ╔{'═' * 70}
214
- 🚀 LAUNCHING SCRIPT {PROGRAM_PATH}
215
- ╠{'═' * 70}
216
- 📄 Script: {pyfile}
217
- ║ 🔥 Command: {fire_line}
218
- ╚{'═' * 70}╝
219
- """)
220
-
189
+
190
+ title = "🚀 LAUNCHING SCRIPT"
191
+ text1 = f"📄 Script: {pyfile}"
192
+ text2 = f"🔥 Command: {fire_line}"
193
+ launch_message = f"{title} {PROGRAM_PATH}\n{text1}\n{text2}"
194
+ console.print(Panel(Text(launch_message, justify="left"), expand=False, border_style="blue"))
195
+
221
196
  PROGRAM_PATH.write_text(data=final_program)
222
197
  # (PROGRAM_PATH + ".py").write_text(str(pyfile), encoding='utf-8')
223
198