machineconfig 2.1__py3-none-any.whl → 2.3__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 (127) hide show
  1. machineconfig/cluster/sessions_managers/enhanced_command_runner.py +0 -2
  2. machineconfig/cluster/sessions_managers/layout_types.py +29 -0
  3. machineconfig/cluster/sessions_managers/wt_local.py +68 -62
  4. machineconfig/cluster/sessions_managers/wt_local_manager.py +51 -22
  5. machineconfig/cluster/sessions_managers/wt_remote.py +30 -108
  6. machineconfig/cluster/sessions_managers/wt_remote_manager.py +14 -11
  7. machineconfig/cluster/sessions_managers/wt_utils/layout_generator.py +33 -37
  8. machineconfig/cluster/sessions_managers/wt_utils/process_monitor.py +22 -17
  9. machineconfig/cluster/sessions_managers/wt_utils/session_manager.py +59 -10
  10. machineconfig/cluster/sessions_managers/wt_utils/status_reporter.py +16 -14
  11. machineconfig/cluster/sessions_managers/zellij_local.py +75 -57
  12. machineconfig/cluster/sessions_managers/zellij_local_manager.py +51 -23
  13. machineconfig/cluster/sessions_managers/zellij_remote.py +47 -27
  14. machineconfig/cluster/sessions_managers/zellij_remote_manager.py +13 -12
  15. machineconfig/cluster/sessions_managers/zellij_utils/example_usage.py +14 -10
  16. machineconfig/cluster/sessions_managers/zellij_utils/layout_generator.py +31 -15
  17. machineconfig/cluster/sessions_managers/zellij_utils/process_monitor.py +47 -21
  18. machineconfig/cluster/sessions_managers/zellij_utils/session_manager.py +1 -1
  19. machineconfig/cluster/sessions_managers/zellij_utils/status_reporter.py +8 -7
  20. machineconfig/cluster/templates/utils.py +0 -35
  21. machineconfig/jobs/python/check_installations.py +1 -1
  22. machineconfig/jobs/python_custom_installers/dev/code.py +0 -13
  23. machineconfig/jobs/python_generic_installers/config.json +1 -1
  24. machineconfig/profile/create.py +13 -4
  25. machineconfig/profile/create_hardlinks.py +3 -1
  26. machineconfig/profile/shell.py +8 -7
  27. machineconfig/scripts/__init__.py +0 -2
  28. machineconfig/scripts/linux/devops +6 -4
  29. machineconfig/scripts/python/ai/generate_files.py +14 -15
  30. machineconfig/scripts/python/ai/mcinit.py +8 -5
  31. machineconfig/scripts/python/archive/tmate_conn.py +5 -5
  32. machineconfig/scripts/python/archive/tmate_start.py +7 -7
  33. machineconfig/scripts/python/choose_wezterm_theme.py +35 -32
  34. machineconfig/scripts/python/cloud_copy.py +22 -13
  35. machineconfig/scripts/python/cloud_mount.py +35 -23
  36. machineconfig/scripts/python/cloud_repo_sync.py +38 -25
  37. machineconfig/scripts/python/cloud_sync.py +4 -4
  38. machineconfig/scripts/python/croshell.py +37 -28
  39. machineconfig/scripts/python/devops.py +46 -27
  40. machineconfig/scripts/python/devops_add_identity.py +15 -25
  41. machineconfig/scripts/python/devops_add_ssh_key.py +7 -7
  42. machineconfig/scripts/python/devops_backup_retrieve.py +17 -15
  43. machineconfig/scripts/python/devops_devapps_install.py +26 -20
  44. machineconfig/scripts/python/devops_update_repos.py +142 -57
  45. machineconfig/scripts/python/dotfile.py +16 -14
  46. machineconfig/scripts/python/fire_agents.py +30 -23
  47. machineconfig/scripts/python/fire_jobs.py +86 -98
  48. machineconfig/scripts/python/fire_jobs_args_helper.py +84 -0
  49. machineconfig/scripts/python/fire_jobs_layout_helper.py +66 -0
  50. machineconfig/scripts/python/ftpx.py +24 -14
  51. machineconfig/scripts/python/get_zellij_cmd.py +8 -7
  52. machineconfig/scripts/python/helpers/cloud_helpers.py +33 -28
  53. machineconfig/scripts/python/helpers/helpers2.py +25 -14
  54. machineconfig/scripts/python/helpers/helpers4.py +44 -31
  55. machineconfig/scripts/python/helpers/helpers5.py +1 -1
  56. machineconfig/scripts/python/helpers/repo_sync_helpers.py +31 -9
  57. machineconfig/scripts/python/mount_nfs.py +8 -15
  58. machineconfig/scripts/python/mount_nw_drive.py +10 -5
  59. machineconfig/scripts/python/mount_ssh.py +8 -6
  60. machineconfig/scripts/python/repos.py +215 -57
  61. machineconfig/scripts/python/snapshot.py +0 -1
  62. machineconfig/scripts/python/start_slidev.py +10 -5
  63. machineconfig/scripts/python/start_terminals.py +22 -16
  64. machineconfig/scripts/python/viewer_template.py +0 -1
  65. machineconfig/scripts/python/wifi_conn.py +49 -76
  66. machineconfig/scripts/python/wsl_windows_transfer.py +8 -6
  67. machineconfig/settings/lf/linux/lfrc +1 -0
  68. machineconfig/setup_linux/web_shortcuts/croshell.sh +5 -0
  69. machineconfig/setup_linux/web_shortcuts/interactive.sh +1 -1
  70. machineconfig/setup_linux/web_shortcuts/ssh.sh +0 -4
  71. machineconfig/setup_windows/wt_and_pwsh/set_pwsh_theme.py +3 -12
  72. machineconfig/setup_windows/wt_and_pwsh/set_wt_settings.py +1 -1
  73. machineconfig/utils/code.py +2 -3
  74. machineconfig/utils/installer.py +2 -2
  75. machineconfig/utils/installer_utils/installer_abc.py +2 -4
  76. machineconfig/utils/installer_utils/installer_class.py +6 -4
  77. machineconfig/utils/links.py +103 -33
  78. machineconfig/utils/notifications.py +52 -38
  79. machineconfig/utils/options.py +14 -21
  80. machineconfig/utils/path.py +12 -12
  81. machineconfig/utils/path_reduced.py +239 -200
  82. machineconfig/utils/procs.py +1 -1
  83. machineconfig/utils/source_of_truth.py +27 -0
  84. machineconfig/utils/ssh.py +9 -19
  85. machineconfig/utils/terminal.py +4 -2
  86. machineconfig/utils/upgrade_packages.py +91 -0
  87. machineconfig/utils/utils2.py +1 -2
  88. machineconfig/utils/utils5.py +23 -11
  89. machineconfig/utils/ve.py +4 -1
  90. {machineconfig-2.1.dist-info → machineconfig-2.3.dist-info}/METADATA +13 -13
  91. {machineconfig-2.1.dist-info → machineconfig-2.3.dist-info}/RECORD +105 -121
  92. machineconfig-2.3.dist-info/entry_points.txt +2 -0
  93. machineconfig/cluster/sessions_managers/archive/create_zellij_template.py +0 -59
  94. machineconfig/cluster/sessions_managers/archive/session_managers.py +0 -183
  95. machineconfig/cluster/sessions_managers/demo_rich_zellij.py +0 -0
  96. machineconfig/jobs/__pycache__/__init__.cpython-313.pyc +0 -0
  97. machineconfig/jobs/python_custom_installers/__pycache__/__init__.cpython-313.pyc +0 -0
  98. machineconfig/jobs/python_generic_installers/__pycache__/__init__.cpython-313.pyc +0 -0
  99. machineconfig/jobs/python_linux_installers/__pycache__/__init__.cpython-313.pyc +0 -0
  100. machineconfig/scripts/__pycache__/__init__.cpython-313.pyc +0 -0
  101. machineconfig/scripts/python/__pycache__/__init__.cpython-313.pyc +0 -0
  102. machineconfig/scripts/python/__pycache__/croshell.cpython-313.pyc +0 -0
  103. machineconfig/scripts/python/__pycache__/devops.cpython-313.pyc +0 -0
  104. machineconfig/scripts/python/__pycache__/devops_devapps_install.cpython-313.pyc +0 -0
  105. machineconfig/scripts/python/__pycache__/devops_update_repos.cpython-313.pyc +0 -0
  106. machineconfig/scripts/python/__pycache__/fire_jobs.cpython-313.pyc +0 -0
  107. machineconfig/scripts/python/ai/__pycache__/__init__.cpython-313.pyc +0 -0
  108. machineconfig/scripts/python/ai/__pycache__/generate_files.cpython-313.pyc +0 -0
  109. machineconfig/scripts/python/ai/__pycache__/mcinit.cpython-313.pyc +0 -0
  110. machineconfig/scripts/python/helpers/__pycache__/__init__.cpython-313.pyc +0 -0
  111. machineconfig/scripts/python/helpers/__pycache__/helpers4.cpython-313.pyc +0 -0
  112. machineconfig/setup_linux/web_shortcuts/all.sh +0 -48
  113. machineconfig/setup_linux/web_shortcuts/update_system.sh +0 -48
  114. machineconfig/utils/utils.py +0 -97
  115. /machineconfig/cluster/{cloud_manager.py → remote/cloud_manager.py} +0 -0
  116. /machineconfig/cluster/{data_transfer.py → remote/data_transfer.py} +0 -0
  117. /machineconfig/cluster/{distribute.py → remote/distribute.py} +0 -0
  118. /machineconfig/cluster/{file_manager.py → remote/file_manager.py} +0 -0
  119. /machineconfig/cluster/{job_params.py → remote/job_params.py} +0 -0
  120. /machineconfig/cluster/{loader_runner.py → remote/loader_runner.py} +0 -0
  121. /machineconfig/cluster/{remote_machine.py → remote/remote_machine.py} +0 -0
  122. /machineconfig/cluster/{script_execution.py → remote/script_execution.py} +0 -0
  123. /machineconfig/cluster/{script_notify_upon_completion.py → remote/script_notify_upon_completion.py} +0 -0
  124. /machineconfig/{cluster/sessions_managers/archive/__init__.py → scripts/python/fire_jobs_streamlit_helper.py} +0 -0
  125. /machineconfig/setup_linux/web_shortcuts/{tmp.sh → android.sh} +0 -0
  126. {machineconfig-2.1.dist-info → machineconfig-2.3.dist-info}/WHEEL +0 -0
  127. {machineconfig-2.1.dist-info → machineconfig-2.3.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,3 @@
1
-
2
1
  #!/usr/bin/env python3
3
2
  """Script to generate a markdown table with checkboxes for all Python files in the repo."""
4
3
 
@@ -9,19 +8,19 @@ def get_python_files(repo_root: Path) -> list[str]:
9
8
  """Get all Python files relative to repo root."""
10
9
  # Get all .py files recursively
11
10
  py_files = list(repo_root.glob("**/*.py"))
12
-
11
+
13
12
  # Filter out files in .venv and __pycache__ directories
14
13
  filtered_files = []
15
14
  for file_path in py_files:
16
15
  relative_path = file_path.relative_to(repo_root)
17
16
  path_parts = relative_path.parts
18
-
17
+
19
18
  # Skip files in .venv or __pycache__ directories
20
19
  if any(part in {".venv", "__pycache__"} for part in path_parts):
21
20
  continue
22
-
21
+
23
22
  filtered_files.append(str(relative_path))
24
-
23
+
25
24
  return sorted(filtered_files)
26
25
 
27
26
 
@@ -29,12 +28,12 @@ def generate_markdown_table(files: list[str]) -> str:
29
28
  """Generate markdown table with checkboxes."""
30
29
  header = "# Python Files Checklist\n\n"
31
30
  table = "| Index | File Path | Status |\n|-------|-----------|--------|\n"
32
-
31
+
33
32
  for index, file_path in enumerate(files, start=1):
34
33
  # Remove leading ./ if present
35
- clean_path = file_path.lstrip('./')
34
+ clean_path = file_path.lstrip("./")
36
35
  table += f"| {index} | {clean_path} | - [ ] |\n"
37
-
36
+
38
37
  return header + table
39
38
 
40
39
 
@@ -44,27 +43,28 @@ def main() -> None:
44
43
  if not repo_root.joinpath("pyproject.toml").exists():
45
44
  raise RuntimeError(f" {repo_root} Not a repo root")
46
45
  output_file = repo_root / ".ai" / "all_files_with_index.md"
47
-
46
+
48
47
  print(f"Repo root: {repo_root}")
49
48
  print(f"Output file: {output_file}")
50
-
49
+
51
50
  # Ensure output directory exists
52
51
  output_file.parent.mkdir(parents=True, exist_ok=True)
53
-
52
+
54
53
  # Get Python files
55
54
  python_files = get_python_files(repo_root)
56
55
  print(f"Found {len(python_files)} Python files")
57
-
56
+
58
57
  # Generate markdown
59
58
  markdown_content = generate_markdown_table(python_files)
60
59
  print(f"Generated markdown content length: {len(markdown_content)}")
61
-
60
+
62
61
  # Write to file
63
62
  output_file.write_text(markdown_content)
64
63
  print(f"Generated {output_file} with {len(python_files)} Python files")
65
-
64
+
66
65
  # Create 5 symlinks to repo_root at ~/code_copies/${repo_name}_copy_{i}
67
66
  import pathlib
67
+
68
68
  # import os
69
69
  repo_root = pathlib.Path.cwd().resolve()
70
70
  repo_name: str = pathlib.Path(repo_root).name
@@ -81,4 +81,3 @@ def main() -> None:
81
81
 
82
82
  if __name__ == "__main__":
83
83
  main()
84
-
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  from pathlib import Path
4
2
  from typing import Optional
5
3
 
@@ -9,8 +7,10 @@ uv add --upgrade-package pylint pyright mypy pyrefly ty --dev # linters and typ
9
7
  uv add --upgrade-package pytest --dev
10
8
  """
11
9
 
10
+
12
11
  def get_repo_root(path: Path) -> Optional[Path]:
13
12
  from git import Repo, InvalidGitRepositoryError
13
+
14
14
  try:
15
15
  repo = Repo(path, search_parent_directories=True)
16
16
  root = repo.working_tree_dir
@@ -20,12 +20,15 @@ def get_repo_root(path: Path) -> Optional[Path]:
20
20
  pass
21
21
  return None
22
22
 
23
+
23
24
  def add_ai_configs(repo_root: Path):
24
25
  import machineconfig as mc
26
+
25
27
  mc_root = Path(mc.__file__).parent
26
28
 
27
29
  repo_root_resolved = get_repo_root(repo_root)
28
- if repo_root_resolved is not None: repo_root = repo_root_resolved # this means you can run the command from any subdirectory of the repo.
30
+ if repo_root_resolved is not None:
31
+ repo_root = repo_root_resolved # this means you can run the command from any subdirectory of the repo.
29
32
 
30
33
  if repo_root.joinpath("pyproject.toml").exists() is False:
31
34
  uv_init = input(f"{repo_root} does not seem to be a python project (no pyproject.toml found), would you like to initialize one? (y/n) ")
@@ -35,6 +38,7 @@ uv init --python 3.13
35
38
  uv venv
36
39
  """
37
40
  import subprocess
41
+
38
42
  subprocess.run(command_to_run, shell=True, check=True)
39
43
  else:
40
44
  print("Terminating mcinit ...")
@@ -93,8 +97,7 @@ uv venv
93
97
  if dot_git_ignore_path.exists():
94
98
  dot_git_ignore_content = dot_git_ignore_path.read_text(encoding="utf-8")
95
99
  to_add: list[str] = []
96
- to_check_for: list[str] = [".links", "notebooks", ".ai", ".scripts",
97
- "GEMINI.md", "CLAUDE.md", ".cursor", ".github"]
100
+ to_check_for: list[str] = [".links", "notebooks", ".ai", ".scripts", "GEMINI.md", "CLAUDE.md", ".cursor", ".github"]
98
101
  for item in to_check_for:
99
102
  if item not in dot_git_ignore_content:
100
103
  to_add.append(item)
@@ -13,16 +13,16 @@ console = Console()
13
13
 
14
14
  def get_conn_string(sess_name: str) -> str:
15
15
  creds = configparser.ConfigParser()
16
- creds.read(Path.home().joinpath('dotfiles/creds/tmate/creds.ini'))
17
- sess_name = creds['sessions_names'][sess_name]
18
- user_name = creds['keys']['username']
16
+ creds.read(Path.home().joinpath("dotfiles/creds/tmate/creds.ini"))
17
+ sess_name = creds["sessions_names"][sess_name]
18
+ user_name = creds["keys"]["username"]
19
19
  return f"{user_name}/{sess_name}@sgp1.tmate.io"
20
20
 
21
21
 
22
22
  def main():
23
23
  console.print(Panel("šŸ”Œ Tmate Connection Manager", title="[bold]Welcome[/bold]"))
24
24
 
25
- parser = argparse.ArgumentParser(description='Tmate launcher')
25
+ parser = argparse.ArgumentParser(description="Tmate launcher")
26
26
  parser.add_argument("sess_name", help="session name", default=random.choices(list(string.digits + string.ascii_letters), k=20))
27
27
  args = parser.parse_args()
28
28
 
@@ -37,5 +37,5 @@ def main():
37
37
  console.print("āœ… Connection closed")
38
38
 
39
39
 
40
- if __name__ == '__main__':
40
+ if __name__ == "__main__":
41
41
  main()
@@ -1,5 +1,5 @@
1
- """Tmate
2
- """
1
+ """Tmate"""
2
+
3
3
  import argparse
4
4
  import configparser
5
5
  from pathlib import Path
@@ -17,10 +17,10 @@ def main():
17
17
 
18
18
  console.print("[bold yellow]Loading credentials...[/bold yellow]")
19
19
  creds = configparser.ConfigParser()
20
- creds.read(Path.home().joinpath('dotfiles/creds/tmate/creds.ini'))
20
+ creds.read(Path.home().joinpath("dotfiles/creds/tmate/creds.ini"))
21
21
  console.print("[green]Credentials loaded[/green]")
22
22
 
23
- parser = argparse.ArgumentParser(description='Tmate launcher')
23
+ parser = argparse.ArgumentParser(description="Tmate launcher")
24
24
  random_sess = random.choices(list(string.digits + string.ascii_letters), k=20)
25
25
  _ = random_sess
26
26
  parser.add_argument("sess_name", help="session name (new only with random string will be chosen if not passed)", default=None)
@@ -28,8 +28,8 @@ def main():
28
28
  args = parser.parse_args()
29
29
 
30
30
  console.print(f"šŸ” Looking up session configuration: {args.sess_name}")
31
- sess_name = creds['sessions_names'][args.sess_name]
32
- api_key = creds['keys']['api_key']
31
+ sess_name = creds["sessions_names"][args.sess_name]
32
+ api_key = creds["keys"]["api_key"]
33
33
 
34
34
  console.print(Panel(f"šŸš€ Starting tmate session: {sess_name}", title="[bold green]Session Info[/bold green]"))
35
35
 
@@ -40,5 +40,5 @@ def main():
40
40
  console.print("[green]Tmate session ended[/green]")
41
41
 
42
42
 
43
- if __name__ == '__main__':
43
+ if __name__ == "__main__":
44
44
  main()
@@ -2,7 +2,8 @@
2
2
  Choose a theme for Wezterm
3
3
  """
4
4
 
5
- from machineconfig.utils.utils import choose_one_option, PathExtended
5
+ from machineconfig.utils.options import choose_one_option
6
+ from machineconfig.utils.path_reduced import PathExtended
6
7
  from typing import Any
7
8
  import time
8
9
  from rich.panel import Panel
@@ -13,32 +14,32 @@ console = Console()
13
14
 
14
15
 
15
16
  schemes_list = [
16
- 'Pro',
17
- 'Spiderman',
18
- 'shades-of-purple',
19
- 'synthwave',
20
- 'Symfonic',
21
- 'PaulMillr',
22
- 'Neon',
23
- 'LiquidCarbonTransparentInverse',
24
- 'Laser',
25
- 'IR_Black',
26
- 'Hurtado',
27
- 'Homebrew',
28
- 'Hipster Green',
29
- 'Firefly Traditional',
30
- 'Elementary',
31
- 'deep',
32
- 'Dark Pastel',
33
- 'Bright Lights',
34
- 'Adventure',
35
- 'Nancy (terminal.sexy)',
36
- 'Bim (Gogh)',
37
- 'BlueDolphin',
38
- 'Borland',
39
- 'Grass (Gogh)',
40
- 'Greenscreen (light) (terminal.sexy)',
41
- 'Grayscale (dark) (terminal.sexy)',
17
+ "Pro",
18
+ "Spiderman",
19
+ "shades-of-purple",
20
+ "synthwave",
21
+ "Symfonic",
22
+ "PaulMillr",
23
+ "Neon",
24
+ "LiquidCarbonTransparentInverse",
25
+ "Laser",
26
+ "IR_Black",
27
+ "Hurtado",
28
+ "Homebrew",
29
+ "Hipster Green",
30
+ "Firefly Traditional",
31
+ "Elementary",
32
+ "deep",
33
+ "Dark Pastel",
34
+ "Bright Lights",
35
+ "Adventure",
36
+ "Nancy (terminal.sexy)",
37
+ "Bim (Gogh)",
38
+ "BlueDolphin",
39
+ "Borland",
40
+ "Grass (Gogh)",
41
+ "Greenscreen (light) (terminal.sexy)",
42
+ "Grayscale (dark) (terminal.sexy)",
42
43
  ]
43
44
 
44
45
 
@@ -54,10 +55,11 @@ def set_theme(theme: str):
54
55
  txt_lines = PathExtended("~/.config/wezterm/wezterm.lua").expanduser().read_text(encoding="utf-8").splitlines()
55
56
  res_lines = []
56
57
  for line in txt_lines:
57
- if 'config.color_scheme = ' in line:
58
+ if "config.color_scheme = " in line:
58
59
  res_lines.append(f"config.color_scheme = '{theme}'")
59
- else: res_lines.append(line)
60
- PathExtended("~/.config/wezterm/wezterm.lua").expanduser().write_text('\n'.join(res_lines), encoding="utf-8")
60
+ else:
61
+ res_lines.append(line)
62
+ PathExtended("~/.config/wezterm/wezterm.lua").expanduser().write_text("\n".join(res_lines), encoding="utf-8")
61
63
  time.sleep(0.1)
62
64
  print("šŸ’¾ Configuration saved")
63
65
 
@@ -70,6 +72,7 @@ def main():
70
72
  curses.wrapper(accessory)
71
73
  console.print(Panel("āœ… Theme selection completed", title_align="left", border_style="green"))
72
74
 
75
+
73
76
  def accessory(stdscr: Any):
74
77
  options = schemes_list
75
78
  current_option = 0
@@ -90,7 +93,7 @@ def accessory(stdscr: Any):
90
93
  stdscr.addstr(i, 0, f" {option}")
91
94
 
92
95
  # Display status line
93
- status_line = f"šŸ” Theme {current_option+1}/{len(options)} | ↑/↓: Navigate | Enter: Select"
96
+ status_line = f"šŸ” Theme {current_option + 1}/{len(options)} | ↑/↓: Navigate | Enter: Select"
94
97
  stdscr.addstr(page_size, 0, status_line)
95
98
 
96
99
  # Get key press
@@ -101,6 +104,6 @@ def accessory(stdscr: Any):
101
104
  current_option -= 1
102
105
  elif key == curses.KEY_DOWN and current_option < len(options) - 1:
103
106
  current_option += 1
104
- elif key == ord('\n'): # Enter key
107
+ elif key == ord("\n"): # Enter key
105
108
  break # Exit the loop
106
109
  set_theme(options[current_option])
@@ -18,6 +18,7 @@ from machineconfig.utils.utils2 import pprint
18
18
 
19
19
  console = Console()
20
20
 
21
+
21
22
  @retry(stop=stop_after_attempt(3), wait=wait_chain(wait_fixed(1), wait_fixed(4), wait_fixed(9)))
22
23
  def get_securely_shared_file(url: Optional[str] = None, folder: Optional[str] = None) -> None:
23
24
  console.print(Panel("šŸš€ Secure File Downloader", title="[bold blue]Downloader[/bold blue]", border_style="blue"))
@@ -63,7 +64,7 @@ def get_securely_shared_file(url: Optional[str] = None, folder: Optional[str] =
63
64
  def arg_parser() -> None:
64
65
  console.print(Panel("ā˜ļø Cloud Copy Utility", title="[bold blue]Cloud Copy[/bold blue]", border_style="blue", width=152))
65
66
 
66
- parser = argparse.ArgumentParser(description='šŸš€ Cloud CLI. It wraps rclone with sane defaults for optimum type time.')
67
+ parser = argparse.ArgumentParser(description="šŸš€ Cloud CLI. It wraps rclone with sane defaults for optimum type time.")
67
68
 
68
69
  # positional argument
69
70
  parser.add_argument("source", help="šŸ“‚ file/folder path to be taken from here.")
@@ -80,7 +81,7 @@ def arg_parser() -> None:
80
81
  parser.add_argument("--zip", "-z", help="šŸ“¦ unzip after receiving.", action="store_true", default=ArgsDefaults.zip_)
81
82
  parser.add_argument("--os_specific", "-o", help="šŸ’» choose path specific for this OS.", action="store_true", default=ArgsDefaults.os_specific)
82
83
 
83
- parser.add_argument("--config", "-c", help="āš™ļø path to cloud.json file.", default=None)
84
+ parser.add_argument("--config", "-c", help="āš™ļø path to cloud.json file.", default=None)
84
85
 
85
86
  args = parser.parse_args()
86
87
  args_dict = vars(args)
@@ -117,26 +118,34 @@ def arg_parser() -> None:
117
118
  if cloud in source:
118
119
  console.print(Panel(f"šŸ“„ DOWNLOADING FROM CLOUD\nā˜ļø Cloud: {cloud}\nšŸ“‚ Source: {source.replace(cloud + ':', '')}\nšŸŽÆ Target: {target}", title="[bold blue]Download[/bold blue]", border_style="blue", width=152))
119
120
 
120
- PathExtended(target).from_cloud(cloud=cloud, remotepath=source.replace(cloud + ":", ""),
121
- unzip=args_obj.zip, decrypt=args_obj.encrypt, pwd=args_obj.pwd,
122
- overwrite=args_obj.overwrite,
123
- rel2home=args_obj.rel2home, os_specific=args_obj.os_specific, root=args_obj.root, strict=False,
124
- )
121
+ PathExtended(target).from_cloud(
122
+ cloud=cloud,
123
+ remotepath=source.replace(cloud + ":", ""),
124
+ unzip=args_obj.zip,
125
+ decrypt=args_obj.encrypt,
126
+ pwd=args_obj.pwd,
127
+ overwrite=args_obj.overwrite,
128
+ rel2home=args_obj.rel2home,
129
+ os_specific=args_obj.os_specific,
130
+ root=args_obj.root,
131
+ strict=False,
132
+ )
125
133
  console.print(Panel("āœ… Download completed successfully", title="[bold green]Success[/bold green]", border_style="green", width=152))
126
134
 
127
135
  elif cloud in target:
128
136
  console.print(Panel(f"šŸ“¤ UPLOADING TO CLOUD\nā˜ļø Cloud: {cloud}\nšŸ“‚ Source: {source}\nšŸŽÆ Target: {target.replace(cloud + ':', '')}", title="[bold blue]Upload[/bold blue]", border_style="blue", width=152))
129
137
 
130
- res = PathExtended(source).to_cloud(cloud=cloud, remotepath=target.replace(cloud + ":", ""),
131
- zip=args_obj.zip, encrypt=args_obj.encrypt, pwd=args_obj.pwd,
132
- rel2home=args_obj.rel2home, root=args_obj.root, os_specific=args_obj.os_specific, strict=False,
133
- share=args_obj.share)
138
+ res = PathExtended(source).to_cloud(
139
+ cloud=cloud, remotepath=target.replace(cloud + ":", ""), zip=args_obj.zip, encrypt=args_obj.encrypt, pwd=args_obj.pwd, rel2home=args_obj.rel2home, root=args_obj.root, os_specific=args_obj.os_specific, strict=False, share=args_obj.share
140
+ )
134
141
  console.print(Panel("āœ… Upload completed successfully", title="[bold green]Success[/bold green]", border_style="green", width=152))
135
142
 
136
143
  if args_obj.share:
137
144
  fname = f".share_url_{cloud}"
138
- if PathExtended(source).is_dir(): share_url_path = PathExtended(source).joinpath(fname)
139
- else: share_url_path = PathExtended(source).with_suffix(fname)
145
+ if PathExtended(source).is_dir():
146
+ share_url_path = PathExtended(source).joinpath(fname)
147
+ else:
148
+ share_url_path = PathExtended(source).with_suffix(fname)
140
149
  share_url_path.write_text(res.as_url_str(), encoding="utf-8")
141
150
  console.print(Panel(f"šŸ”— SHARE URL GENERATED\nšŸ“ URL file: {share_url_path}\nšŸŒ {res.as_url_str()}", title="[bold blue]Share[/bold blue]", border_style="blue", width=152))
142
151
  else:
@@ -1,8 +1,7 @@
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
6
  from machineconfig.utils.path_reduced import PathExtended as PathExtended
8
7
 
@@ -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()