machineconfig 2.0__py3-none-any.whl → 2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of machineconfig might be problematic. Click here for more details.
- machineconfig/cluster/cloud_manager.py +0 -3
- machineconfig/cluster/data_transfer.py +0 -1
- machineconfig/cluster/file_manager.py +0 -1
- machineconfig/cluster/job_params.py +0 -3
- machineconfig/cluster/loader_runner.py +0 -3
- machineconfig/cluster/remote_machine.py +0 -1
- machineconfig/cluster/script_notify_upon_completion.py +0 -1
- machineconfig/cluster/sessions_managers/archive/create_zellij_template.py +5 -6
- machineconfig/cluster/sessions_managers/archive/session_managers.py +0 -1
- machineconfig/cluster/sessions_managers/enhanced_command_runner.py +17 -57
- machineconfig/cluster/sessions_managers/wt_local.py +36 -110
- machineconfig/cluster/sessions_managers/wt_local_manager.py +42 -112
- machineconfig/cluster/sessions_managers/wt_remote.py +23 -30
- machineconfig/cluster/sessions_managers/wt_remote_manager.py +20 -62
- machineconfig/cluster/sessions_managers/wt_utils/layout_generator.py +10 -15
- machineconfig/cluster/sessions_managers/wt_utils/process_monitor.py +27 -127
- machineconfig/cluster/sessions_managers/wt_utils/remote_executor.py +10 -43
- machineconfig/cluster/sessions_managers/wt_utils/session_manager.py +22 -101
- machineconfig/cluster/sessions_managers/wt_utils/status_reporter.py +11 -39
- machineconfig/cluster/sessions_managers/zellij_local.py +49 -102
- machineconfig/cluster/sessions_managers/zellij_local_manager.py +34 -78
- machineconfig/cluster/sessions_managers/zellij_remote.py +17 -24
- machineconfig/cluster/sessions_managers/zellij_remote_manager.py +7 -13
- machineconfig/cluster/sessions_managers/zellij_utils/example_usage.py +4 -2
- machineconfig/cluster/sessions_managers/zellij_utils/layout_generator.py +6 -6
- machineconfig/cluster/sessions_managers/zellij_utils/process_monitor.py +18 -88
- machineconfig/cluster/sessions_managers/zellij_utils/remote_executor.py +2 -6
- machineconfig/cluster/sessions_managers/zellij_utils/session_manager.py +12 -40
- machineconfig/cluster/sessions_managers/zellij_utils/status_reporter.py +3 -2
- machineconfig/cluster/templates/cli_click.py +0 -1
- machineconfig/cluster/templates/cli_gooey.py +0 -2
- machineconfig/cluster/templates/cli_trogon.py +0 -1
- machineconfig/cluster/templates/run_cloud.py +0 -1
- machineconfig/cluster/templates/run_cluster.py +0 -1
- machineconfig/cluster/templates/run_remote.py +0 -1
- machineconfig/cluster/templates/utils.py +27 -46
- machineconfig/jobs/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/jobs/linux/msc/cli_agents.sh +16 -0
- machineconfig/jobs/python/check_installations.py +2 -1
- machineconfig/jobs/python/create_bootable_media.py +0 -2
- machineconfig/jobs/python/python_ve_symlink.py +9 -11
- machineconfig/jobs/python/tasks.py +0 -1
- machineconfig/jobs/python/vscode/api.py +5 -5
- machineconfig/jobs/python/vscode/link_ve.py +13 -14
- machineconfig/jobs/python/vscode/select_interpreter.py +21 -22
- machineconfig/jobs/python/vscode/sync_code.py +9 -13
- machineconfig/jobs/python_custom_installers/archive/ngrok.py +13 -13
- machineconfig/jobs/python_custom_installers/dev/aider.py +7 -15
- machineconfig/jobs/python_custom_installers/dev/alacritty.py +9 -18
- machineconfig/jobs/python_custom_installers/dev/brave.py +10 -19
- machineconfig/jobs/python_custom_installers/dev/bypass_paywall.py +8 -15
- machineconfig/jobs/python_custom_installers/dev/code.py +12 -32
- machineconfig/jobs/python_custom_installers/dev/cursor.py +3 -14
- machineconfig/jobs/python_custom_installers/dev/docker_desktop.py +8 -7
- machineconfig/jobs/python_custom_installers/dev/espanso.py +15 -19
- machineconfig/jobs/python_custom_installers/dev/goes.py +5 -12
- machineconfig/jobs/python_custom_installers/dev/lvim.py +9 -17
- machineconfig/jobs/python_custom_installers/dev/nerdfont.py +12 -19
- machineconfig/jobs/python_custom_installers/dev/redis.py +12 -20
- machineconfig/jobs/python_custom_installers/dev/wezterm.py +12 -19
- machineconfig/jobs/python_custom_installers/dev/winget.py +5 -23
- machineconfig/jobs/python_custom_installers/docker.py +12 -21
- machineconfig/jobs/python_custom_installers/gh.py +11 -19
- machineconfig/jobs/python_custom_installers/hx.py +32 -16
- machineconfig/jobs/python_custom_installers/warp-cli.py +12 -20
- machineconfig/jobs/python_generic_installers/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/jobs/python_generic_installers/config.json +1 -1
- machineconfig/jobs/python_linux_installers/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/jobs/windows/archive/archive_pygraphviz.ps1 +1 -1
- machineconfig/jobs/windows/msc/cli_agents.bat +0 -0
- machineconfig/jobs/windows/msc/cli_agents.ps1 +0 -0
- machineconfig/jobs/windows/start_terminal.ps1 +1 -1
- machineconfig/profile/create.py +38 -26
- machineconfig/profile/create_hardlinks.py +29 -20
- machineconfig/profile/shell.py +56 -32
- machineconfig/scripts/__init__.py +0 -2
- machineconfig/scripts/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/scripts/cloud/init.sh +2 -2
- machineconfig/scripts/linux/checkout_versions +1 -1
- machineconfig/scripts/linux/choose_wezterm_theme +1 -1
- machineconfig/scripts/linux/cloud_copy +1 -1
- machineconfig/scripts/linux/cloud_manager +1 -1
- machineconfig/scripts/linux/cloud_mount +1 -1
- machineconfig/scripts/linux/cloud_repo_sync +1 -1
- machineconfig/scripts/linux/cloud_sync +1 -1
- machineconfig/scripts/linux/croshell +1 -1
- machineconfig/scripts/linux/devops +7 -7
- machineconfig/scripts/linux/fire +1 -1
- machineconfig/scripts/linux/fire_agents +3 -2
- machineconfig/scripts/linux/ftpx +1 -1
- machineconfig/scripts/linux/gh_models +1 -1
- machineconfig/scripts/linux/kill_process +1 -1
- machineconfig/scripts/linux/mcinit +1 -1
- machineconfig/scripts/linux/repos +1 -1
- machineconfig/scripts/linux/scheduler +1 -1
- machineconfig/scripts/linux/start_slidev +1 -1
- machineconfig/scripts/linux/start_terminals +1 -1
- machineconfig/scripts/linux/url2md +1 -1
- machineconfig/scripts/linux/warp-cli.sh +122 -0
- machineconfig/scripts/linux/wifi_conn +1 -1
- machineconfig/scripts/python/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops_devapps_install.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops_update_repos.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/fire_agents.cpython-313.pyc +0 -0
- machineconfig/scripts/python/ai/__init__.py +0 -0
- machineconfig/scripts/python/ai/generate_files.py +83 -0
- machineconfig/scripts/python/ai/instructions/python/dev.instructions.md +2 -2
- machineconfig/scripts/python/ai/mcinit.py +14 -7
- machineconfig/scripts/python/ai/scripts/lint_and_type_check.sh +10 -5
- machineconfig/scripts/python/archive/tmate_conn.py +5 -5
- machineconfig/scripts/python/archive/tmate_start.py +7 -7
- machineconfig/scripts/python/choose_wezterm_theme.py +35 -32
- machineconfig/scripts/python/cloud_copy.py +23 -14
- machineconfig/scripts/python/cloud_mount.py +36 -24
- machineconfig/scripts/python/cloud_repo_sync.py +40 -27
- machineconfig/scripts/python/cloud_sync.py +4 -4
- machineconfig/scripts/python/croshell.py +40 -29
- machineconfig/scripts/python/devops.py +45 -27
- machineconfig/scripts/python/devops_add_identity.py +15 -25
- machineconfig/scripts/python/devops_add_ssh_key.py +8 -8
- machineconfig/scripts/python/devops_backup_retrieve.py +18 -16
- machineconfig/scripts/python/devops_devapps_install.py +25 -20
- machineconfig/scripts/python/devops_update_repos.py +232 -59
- machineconfig/scripts/python/dotfile.py +17 -15
- machineconfig/scripts/python/fire_agents.py +48 -22
- machineconfig/scripts/python/fire_jobs.py +93 -58
- machineconfig/scripts/python/ftpx.py +26 -15
- machineconfig/scripts/python/get_zellij_cmd.py +8 -7
- machineconfig/scripts/python/helpers/cloud_helpers.py +33 -28
- machineconfig/scripts/python/helpers/helpers2.py +27 -16
- machineconfig/scripts/python/helpers/helpers4.py +45 -32
- machineconfig/scripts/python/helpers/helpers5.py +1 -1
- machineconfig/scripts/python/helpers/repo_sync_helpers.py +32 -10
- machineconfig/scripts/python/mount_nfs.py +9 -16
- machineconfig/scripts/python/mount_nw_drive.py +10 -5
- machineconfig/scripts/python/mount_ssh.py +9 -7
- machineconfig/scripts/python/repos.py +216 -58
- machineconfig/scripts/python/snapshot.py +0 -1
- machineconfig/scripts/python/start_slidev.py +11 -6
- machineconfig/scripts/python/start_terminals.py +22 -16
- machineconfig/scripts/python/viewer_template.py +0 -1
- machineconfig/scripts/python/wifi_conn.py +49 -75
- machineconfig/scripts/python/wsl_windows_transfer.py +9 -7
- machineconfig/scripts/windows/checkout_version.ps1 +1 -3
- machineconfig/scripts/windows/choose_wezterm_theme.ps1 +1 -3
- machineconfig/scripts/windows/cloud_copy.ps1 +2 -6
- machineconfig/scripts/windows/cloud_manager.ps1 +1 -1
- machineconfig/scripts/windows/cloud_repo_sync.ps1 +1 -2
- machineconfig/scripts/windows/cloud_sync.ps1 +2 -2
- machineconfig/scripts/windows/croshell.ps1 +2 -2
- machineconfig/scripts/windows/devops.ps1 +1 -4
- machineconfig/scripts/windows/dotfile.ps1 +1 -3
- machineconfig/scripts/windows/fire.ps1 +1 -1
- machineconfig/scripts/windows/ftpx.ps1 +2 -2
- machineconfig/scripts/windows/gpt.ps1 +1 -1
- machineconfig/scripts/windows/kill_process.ps1 +1 -2
- machineconfig/scripts/windows/mcinit.ps1 +1 -1
- machineconfig/scripts/windows/mount_nfs.ps1 +1 -1
- machineconfig/scripts/windows/mount_ssh.ps1 +1 -1
- machineconfig/scripts/windows/pomodoro.ps1 +1 -1
- machineconfig/scripts/windows/py2exe.ps1 +1 -3
- machineconfig/scripts/windows/repos.ps1 +1 -1
- machineconfig/scripts/windows/scheduler.ps1 +1 -1
- machineconfig/scripts/windows/snapshot.ps1 +2 -2
- machineconfig/scripts/windows/start_slidev.ps1 +1 -1
- machineconfig/scripts/windows/start_terminals.ps1 +1 -1
- machineconfig/scripts/windows/wifi_conn.ps1 +1 -1
- machineconfig/scripts/windows/wsl_windows_transfer.ps1 +1 -3
- machineconfig/settings/lf/linux/lfrc +2 -1
- machineconfig/settings/linters/.ruff_cache/.gitignore +2 -0
- machineconfig/settings/linters/.ruff_cache/CACHEDIR.TAG +1 -0
- machineconfig/settings/lvim/windows/archive/config_additional.lua +1 -1
- machineconfig/settings/svim/linux/init.toml +1 -1
- machineconfig/settings/svim/windows/init.toml +1 -1
- machineconfig/setup_linux/web_shortcuts/croshell.sh +3 -52
- machineconfig/setup_linux/web_shortcuts/interactive.sh +6 -6
- machineconfig/setup_linux/web_shortcuts/ssh.sh +0 -4
- machineconfig/setup_windows/web_shortcuts/all.ps1 +2 -2
- machineconfig/setup_windows/web_shortcuts/ascii_art.ps1 +1 -1
- machineconfig/setup_windows/web_shortcuts/croshell.ps1 +1 -1
- machineconfig/setup_windows/web_shortcuts/interactive.ps1 +5 -5
- machineconfig/setup_windows/wt_and_pwsh/install_fonts.ps1 +51 -15
- machineconfig/setup_windows/wt_and_pwsh/set_pwsh_theme.py +58 -13
- machineconfig/setup_windows/wt_and_pwsh/set_wt_settings.py +45 -37
- machineconfig/utils/ai/generate_file_checklist.py +8 -10
- machineconfig/utils/ai/url2md.py +4 -2
- machineconfig/utils/cloud/onedrive/setup_oauth.py +1 -0
- machineconfig/utils/cloud/onedrive/transaction.py +63 -98
- machineconfig/utils/code.py +62 -41
- machineconfig/utils/installer.py +29 -35
- machineconfig/utils/installer_utils/installer_abc.py +11 -11
- machineconfig/utils/installer_utils/installer_class.py +155 -74
- machineconfig/utils/links.py +112 -31
- machineconfig/utils/notifications.py +211 -0
- machineconfig/utils/options.py +41 -42
- machineconfig/utils/path.py +13 -6
- machineconfig/utils/path_reduced.py +614 -311
- machineconfig/utils/procs.py +48 -42
- machineconfig/utils/scheduling.py +0 -1
- machineconfig/utils/source_of_truth.py +27 -0
- machineconfig/utils/ssh.py +146 -85
- machineconfig/utils/terminal.py +84 -37
- machineconfig/utils/upgrade_packages.py +91 -0
- machineconfig/utils/utils2.py +39 -50
- machineconfig/utils/utils5.py +195 -116
- machineconfig/utils/ve.py +13 -5
- {machineconfig-2.0.dist-info → machineconfig-2.2.dist-info}/METADATA +14 -13
- {machineconfig-2.0.dist-info → machineconfig-2.2.dist-info}/RECORD +212 -237
- machineconfig/jobs/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/jobs/python/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/jobs/python/__pycache__/python_ve_symlink.cpython-311.pyc +0 -0
- machineconfig/jobs/python/archive/python_tools.txt +0 -12
- machineconfig/jobs/python/vscode/__pycache__/select_interpreter.cpython-311.pyc +0 -0
- machineconfig/jobs/python_custom_installers/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/jobs/python_generic_installers/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/jobs/python_generic_installers/update.py +0 -3
- machineconfig/jobs/python_linux_installers/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/profile/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/profile/__pycache__/create.cpython-311.pyc +0 -0
- machineconfig/profile/__pycache__/shell.cpython-311.pyc +0 -0
- machineconfig/scripts/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/scripts/linux/activate_ve +0 -87
- machineconfig/scripts/python/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/cloud_copy.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/cloud_mount.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/cloud_sync.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/croshell.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops_backup_retrieve.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops_devapps_install.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops_update_repos.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/fire_agents.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/fire_jobs.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/fire_jobs.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/get_zellij_cmd.cpython-311.pyc +0 -0
- machineconfig/scripts/python/__pycache__/repos.cpython-311.pyc +0 -0
- machineconfig/scripts/python/ai/__pycache__/init.cpython-311.pyc +0 -0
- machineconfig/scripts/python/ai/__pycache__/mcinit.cpython-311.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/__init__.cpython-311.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/cloud_helpers.cpython-311.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/helpers2.cpython-311.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/helpers4.cpython-311.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/helpers4.cpython-313.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/repo_sync_helpers.cpython-311.pyc +0 -0
- machineconfig/scripts/windows/activate_ve.ps1 +0 -54
- machineconfig/setup_linux/web_shortcuts/all.sh +0 -48
- machineconfig/setup_linux/web_shortcuts/update_system.sh +0 -48
- machineconfig/utils/utils.py +0 -95
- /machineconfig/setup_linux/web_shortcuts/{tmp.sh → android.sh} +0 -0
- {machineconfig-2.0.dist-info → machineconfig-2.2.dist-info}/WHEEL +0 -0
- {machineconfig-2.0.dist-info → machineconfig-2.2.dist-info}/top_level.txt +0 -0
|
@@ -7,14 +7,15 @@ fire
|
|
|
7
7
|
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
from machineconfig.scripts.python.helpers.helpers4 import search_for_files_of_interest
|
|
12
11
|
from machineconfig.scripts.python.helpers.helpers4 import convert_kwargs_to_fire_kwargs_str
|
|
13
12
|
from machineconfig.scripts.python.helpers.helpers4 import parse_pyfile
|
|
14
13
|
from machineconfig.scripts.python.helpers.helpers4 import get_import_module_code
|
|
15
14
|
from machineconfig.utils.ve import get_repo_root, get_ve_activate_line, get_ve_path_and_ipython_profile
|
|
16
|
-
from machineconfig.utils.
|
|
17
|
-
from machineconfig.utils.
|
|
15
|
+
from machineconfig.utils.options import display_options, choose_one_option
|
|
16
|
+
from machineconfig.utils.path import match_file_name, sanitize_path
|
|
17
|
+
from machineconfig.utils.source_of_truth import PROGRAM_PATH
|
|
18
|
+
from machineconfig.utils.path_reduced import PathExtended as PathExtended
|
|
18
19
|
from machineconfig.utils.io_save import save_toml
|
|
19
20
|
from machineconfig.utils.utils2 import randstr, read_toml
|
|
20
21
|
import platform
|
|
@@ -28,27 +29,27 @@ str2obj = {"True": True, "False": False, "None": None}
|
|
|
28
29
|
|
|
29
30
|
def main() -> None:
|
|
30
31
|
parser = argparse.ArgumentParser()
|
|
31
|
-
parser.add_argument("path",
|
|
32
|
-
parser.add_argument("function", nargs=
|
|
33
|
-
parser.add_argument("--ve",
|
|
34
|
-
parser.add_argument("--cmd",
|
|
35
|
-
parser.add_argument("--interactive",
|
|
36
|
-
parser.add_argument("--debug",
|
|
32
|
+
parser.add_argument("path", nargs="?", type=str, help="The directory containing the jobs", default=".")
|
|
33
|
+
parser.add_argument("function", nargs="?", type=str, help="Fuction to run", default=None)
|
|
34
|
+
parser.add_argument("--ve", "-v", type=str, help="virtual enviroment name", default="")
|
|
35
|
+
parser.add_argument("--cmd", "-B", action="store_true", help="Create a cmd fire command to launch the the job asynchronously.")
|
|
36
|
+
parser.add_argument("--interactive", "-i", action="store_true", help="Whether to run the job interactively using IPython")
|
|
37
|
+
parser.add_argument("--debug", "-d", action="store_true", help="debug")
|
|
37
38
|
parser.add_argument("--choose_function", "-c", action="store_true", help="debug")
|
|
38
|
-
parser.add_argument("--loop",
|
|
39
|
-
parser.add_argument("--jupyter",
|
|
39
|
+
parser.add_argument("--loop", "-l", action="store_true", help="infinite recusion (runs again after completion/interruption)")
|
|
40
|
+
parser.add_argument("--jupyter", "-j", action="store_true", help="open in a jupyter notebook")
|
|
40
41
|
parser.add_argument("--submit_to_cloud", "-C", action="store_true", help="submit to cloud compute")
|
|
41
|
-
parser.add_argument("--remote",
|
|
42
|
-
parser.add_argument("--module",
|
|
43
|
-
parser.add_argument("--streamlit",
|
|
44
|
-
parser.add_argument("--environment",
|
|
45
|
-
parser.add_argument("--holdDirectory",
|
|
46
|
-
parser.add_argument("--PathExport",
|
|
47
|
-
parser.add_argument("--git_pull",
|
|
48
|
-
parser.add_argument("--optimized",
|
|
49
|
-
parser.add_argument("--Nprocess",
|
|
50
|
-
parser.add_argument("--zellij_tab",
|
|
51
|
-
parser.add_argument("--watch",
|
|
42
|
+
parser.add_argument("--remote", "-r", action="store_true", help="launch on a remote machine")
|
|
43
|
+
parser.add_argument("--module", "-m", action="store_true", help="launch the main file")
|
|
44
|
+
parser.add_argument("--streamlit", "-S", action="store_true", help="run as streamlit app")
|
|
45
|
+
parser.add_argument("--environment", "-E", type=str, help="Choose ip, localhost, hostname or arbitrary url", default="")
|
|
46
|
+
parser.add_argument("--holdDirectory", "-D", action="store_true", help="hold current directory and avoid cd'ing to the script directory")
|
|
47
|
+
parser.add_argument("--PathExport", "-P", action="store_true", help="augment the PYTHONPATH with repo root.")
|
|
48
|
+
parser.add_argument("--git_pull", "-g", action="store_true", help="Start by pulling the git repo")
|
|
49
|
+
parser.add_argument("--optimized", "-O", action="store_true", help="Run the optimized version of the function")
|
|
50
|
+
parser.add_argument("--Nprocess", "-p", type=int, help="Number of processes to use", default=1)
|
|
51
|
+
parser.add_argument("--zellij_tab", "-z", type=str, dest="zellij_tab", help="open in a new zellij tab")
|
|
52
|
+
parser.add_argument("--watch", "-w", action="store_true", help="watch the file for changes")
|
|
52
53
|
parser.add_argument("--kw", nargs="*", default=None, help="keyword arguments to pass to the function in the form of k1 v1 k2 v2 ... (meaning k1=v1, k2=v2, etc)")
|
|
53
54
|
try:
|
|
54
55
|
args = parser.parse_args()
|
|
@@ -60,7 +61,8 @@ def main() -> None:
|
|
|
60
61
|
# print(f"Passed path sanitied to {path_obj}")
|
|
61
62
|
if not path_obj.exists():
|
|
62
63
|
path_obj = match_file_name(sub_string=args.path, search_root=PathExtended.cwd())
|
|
63
|
-
else:
|
|
64
|
+
else:
|
|
65
|
+
pass
|
|
64
66
|
if path_obj.is_dir():
|
|
65
67
|
print(f"🔍 Searching recursively for Python, PowerShell and Shell scripts in directory `{path_obj}`")
|
|
66
68
|
files = search_for_files_of_interest(path_obj)
|
|
@@ -73,8 +75,9 @@ def main() -> None:
|
|
|
73
75
|
print(f"💾 Selected file: {choice_file}.\nRepo root: {repo_root}")
|
|
74
76
|
|
|
75
77
|
ve_root_from_file, ipy_profile = get_ve_path_and_ipython_profile(choice_file)
|
|
76
|
-
if ipy_profile is None:
|
|
77
|
-
|
|
78
|
+
if ipy_profile is None:
|
|
79
|
+
ipy_profile = "default"
|
|
80
|
+
activate_ve_line = get_ve_activate_line(ve_root=args.ve or ve_root_from_file or "$HOME/code/machineconfig/.venv")
|
|
78
81
|
|
|
79
82
|
# Convert args.kw to dictionary
|
|
80
83
|
if choice_file.suffix == ".py":
|
|
@@ -99,19 +102,23 @@ def main() -> None:
|
|
|
99
102
|
choice_function_tmp = display_options(msg="Choose a function to run", options=options, fzf=True, multi=False)
|
|
100
103
|
assert isinstance(choice_function_tmp, str), f"choice_function must be a string. Got {type(choice_function_tmp)}"
|
|
101
104
|
choice_index = options.index(choice_function_tmp)
|
|
102
|
-
choice_function = choice_function_tmp.split(
|
|
105
|
+
choice_function = choice_function_tmp.split(" -- ")[0]
|
|
103
106
|
choice_function_args = func_args[choice_index]
|
|
104
107
|
|
|
105
|
-
if choice_function == "RUN AS MAIN":
|
|
108
|
+
if choice_function == "RUN AS MAIN":
|
|
109
|
+
choice_function = None
|
|
106
110
|
if len(choice_function_args) > 0 and len(kwargs) == 0:
|
|
107
111
|
for item in choice_function_args:
|
|
108
112
|
kwargs[item.name] = input(f"Please enter a value for argument `{item.name}` (type = {item.type}) (default = {item.default}) : ") or item.default
|
|
109
113
|
elif choice_file.suffix == ".sh": # in this case, we choos lines.
|
|
110
114
|
options = []
|
|
111
115
|
for line in choice_file.read_text(encoding="utf-8").splitlines():
|
|
112
|
-
if line.startswith("#"):
|
|
113
|
-
|
|
114
|
-
if line
|
|
116
|
+
if line.startswith("#"):
|
|
117
|
+
continue
|
|
118
|
+
if line == "":
|
|
119
|
+
continue
|
|
120
|
+
if line.startswith("echo"):
|
|
121
|
+
continue
|
|
115
122
|
options.append(line)
|
|
116
123
|
chosen_lines = display_options(msg="Choose a line to run", options=options, fzf=True, multi=True)
|
|
117
124
|
choice_file = PathExtended.tmpfile(suffix=".sh")
|
|
@@ -124,9 +131,10 @@ def main() -> None:
|
|
|
124
131
|
if choice_file.suffix == ".py":
|
|
125
132
|
if args.streamlit:
|
|
126
133
|
import socket
|
|
134
|
+
|
|
127
135
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
128
136
|
try:
|
|
129
|
-
s.connect((
|
|
137
|
+
s.connect(("8.8.8.8", 1))
|
|
130
138
|
local_ip_v4 = s.getsockname()[0]
|
|
131
139
|
except Exception:
|
|
132
140
|
local_ip_v4 = socket.gethostbyname(socket.gethostname())
|
|
@@ -140,7 +148,8 @@ def main() -> None:
|
|
|
140
148
|
toml_path = toml_path_maybe
|
|
141
149
|
elif choice_file.parent.name == "pages":
|
|
142
150
|
toml_path_maybe = choice_file.parent.parent.joinpath(".streamlit/config.toml")
|
|
143
|
-
if toml_path_maybe.exists():
|
|
151
|
+
if toml_path_maybe.exists():
|
|
152
|
+
toml_path = toml_path_maybe
|
|
144
153
|
if toml_path is not None:
|
|
145
154
|
print(f"📄 Reading config.toml @ {toml_path}")
|
|
146
155
|
config = read_toml(toml_path)
|
|
@@ -152,10 +161,14 @@ def main() -> None:
|
|
|
152
161
|
secrets_template_path = PathExtended.home().joinpath(f"dotfiles/creds/streamlit/{PathExtended(repo_root).name}/{choice_file.name}/secrets.toml")
|
|
153
162
|
if args.environment != "" and not secrets_path.exists() and secrets_template_path.exists():
|
|
154
163
|
secrets_template = read_toml(secrets_template_path)
|
|
155
|
-
if args.environment == "ip":
|
|
156
|
-
|
|
157
|
-
elif args.environment == "
|
|
158
|
-
|
|
164
|
+
if args.environment == "ip":
|
|
165
|
+
host_url = f"http://{local_ip_v4}:{port}/oauth2callback"
|
|
166
|
+
elif args.environment == "localhost":
|
|
167
|
+
host_url = f"http://localhost:{port}/oauth2callback"
|
|
168
|
+
elif args.environment == "hostname":
|
|
169
|
+
host_url = f"http://{computer_name}:{port}/oauth2callback"
|
|
170
|
+
else:
|
|
171
|
+
host_url = f"http://{args.environment}:{port}/oauth2callback"
|
|
159
172
|
try:
|
|
160
173
|
secrets_template["auth"]["redirect_uri"] = host_url
|
|
161
174
|
secrets_template["auth"]["cookie_secret"] = randstr(35)
|
|
@@ -167,11 +180,14 @@ def main() -> None:
|
|
|
167
180
|
message = f"🚀 Streamlit app is running @:\n1- http://{local_ip_v4}:{port}\n2- http://{computer_name}:{port}\n3- http://localhost:{port}"
|
|
168
181
|
from rich.panel import Panel
|
|
169
182
|
from rich import print as rprint
|
|
183
|
+
|
|
170
184
|
rprint(Panel(message))
|
|
171
185
|
exe = f"streamlit run --server.address 0.0.0.0 --server.headless true --server.port {port}"
|
|
172
186
|
# exe = f"cd '{choice_file.parent}'; " + exe
|
|
173
|
-
elif args.interactive is False:
|
|
174
|
-
|
|
187
|
+
elif args.interactive is False:
|
|
188
|
+
exe = "python"
|
|
189
|
+
elif args.jupyter:
|
|
190
|
+
exe = "jupyter-lab"
|
|
175
191
|
else:
|
|
176
192
|
exe = f"ipython -i --no-banner --profile {ipy_profile} "
|
|
177
193
|
elif choice_file.suffix == ".ps1" or choice_file.suffix == ".sh":
|
|
@@ -181,7 +197,9 @@ def main() -> None:
|
|
|
181
197
|
else:
|
|
182
198
|
raise NotImplementedError(f"File type {choice_file.suffix} not supported, in the sense that I don't know how to fire it.")
|
|
183
199
|
|
|
184
|
-
if
|
|
200
|
+
if (
|
|
201
|
+
args.module or (args.debug and args.choose_function)
|
|
202
|
+
): # because debugging tools do not support choosing functions and don't interplay with fire module. So the only way to have debugging and choose function options is to import the file as a module into a new script and run the function of interest there and debug the new script.
|
|
185
203
|
assert choice_file.suffix == ".py", f"File must be a python file to be imported as a module. Got {choice_file}"
|
|
186
204
|
import_line = get_import_module_code(str(choice_file))
|
|
187
205
|
if repo_root is not None:
|
|
@@ -201,11 +219,15 @@ except (ImportError, ModuleNotFoundError) as ex:
|
|
|
201
219
|
print(fr"✅ Successfully imported `{choice_file}`")
|
|
202
220
|
"""
|
|
203
221
|
if choice_function is not None:
|
|
204
|
-
txt =
|
|
205
|
-
|
|
222
|
+
txt = (
|
|
223
|
+
txt
|
|
224
|
+
+ f"""
|
|
225
|
+
res = {choice_function}({("**" + str(kwargs)) if kwargs else ""})
|
|
206
226
|
"""
|
|
227
|
+
)
|
|
207
228
|
|
|
208
|
-
txt =
|
|
229
|
+
txt = (
|
|
230
|
+
f"""
|
|
209
231
|
try:
|
|
210
232
|
from rich.panel import Panel
|
|
211
233
|
from rich.console import Console
|
|
@@ -214,8 +236,10 @@ try:
|
|
|
214
236
|
console.print(Panel(Syntax(code=r'''{txt}''', lexer='python'), title='Import Script'), style="bold red")
|
|
215
237
|
except ImportError as _ex:
|
|
216
238
|
print(r'''{txt}''')
|
|
217
|
-
"""
|
|
218
|
-
|
|
239
|
+
"""
|
|
240
|
+
+ txt
|
|
241
|
+
)
|
|
242
|
+
choice_file = PathExtended.tmp().joinpath(f"tmp_scripts/python/{PathExtended(choice_file).parent.name}_{PathExtended(choice_file).stem}_{randstr()}.py")
|
|
219
243
|
choice_file.parent.mkdir(parents=True, exist_ok=True)
|
|
220
244
|
choice_file.write_text(txt, encoding="utf-8")
|
|
221
245
|
|
|
@@ -225,7 +249,8 @@ except ImportError as _ex:
|
|
|
225
249
|
command = f"{exe} -m ipdb {choice_file} " # pudb is not available on windows machines, use poor man's debugger instead.
|
|
226
250
|
elif platform.system() in ["Linux", "Darwin"]:
|
|
227
251
|
command = f"{exe} -m pudb {choice_file} " # TODO: functions not supported yet in debug mode.
|
|
228
|
-
else:
|
|
252
|
+
else:
|
|
253
|
+
raise NotImplementedError(f"Platform {platform.system()} not supported.")
|
|
229
254
|
elif args.module:
|
|
230
255
|
# both selected function and kwargs are mentioned in the made up script, therefore no need for fire module.
|
|
231
256
|
command = f"{exe} {choice_file} "
|
|
@@ -249,16 +274,19 @@ except ImportError as _ex:
|
|
|
249
274
|
# command = f"cd {choice_file.parent}\n{exe} {choice_file.name}\ncd {PathExtended.cwd()}"
|
|
250
275
|
command = f"{exe} {choice_file} "
|
|
251
276
|
if not args.cmd:
|
|
252
|
-
if "ipdb" in command:
|
|
253
|
-
|
|
277
|
+
if "ipdb" in command:
|
|
278
|
+
command = f"pip install ipdb\n{command}"
|
|
279
|
+
if "pudb" in command:
|
|
280
|
+
command = f"pip install pudb\n{command}"
|
|
254
281
|
command = f"{activate_ve_line}\n{command}"
|
|
255
282
|
else:
|
|
256
283
|
# CMD equivalent
|
|
257
|
-
if "ipdb" in command:
|
|
258
|
-
|
|
284
|
+
if "ipdb" in command:
|
|
285
|
+
command = f"pip install ipdb & {command}"
|
|
286
|
+
if "pudb" in command:
|
|
287
|
+
command = f"pip install pudb & {command}"
|
|
259
288
|
new_line = "\n"
|
|
260
|
-
command =
|
|
261
|
-
# this works from cmd # command = fr""" start cmd /k "%USERPROFILE%\venvs\{args.ve}\Scripts\activate.bat & {command} " """ # because start in cmd is different from start in powershell (in powershell it is short for Start-Process)
|
|
289
|
+
command = rf"""start cmd -Argument "/k {activate_ve_line.replace(".ps1", ".bat").replace(". ", "")} & {command.replace(new_line, " & ")} " """ # this works from powershell
|
|
262
290
|
|
|
263
291
|
if args.submit_to_cloud:
|
|
264
292
|
command = f"""
|
|
@@ -282,6 +310,7 @@ python -m machineconfig.cluster.templates.cli_click --file {choice_file} """
|
|
|
282
310
|
for an_arg in range(args.Nprocess):
|
|
283
311
|
tab_config[f"tab{an_arg}"] = (str(PathExtended.cwd()), f"uv run -m fire {choice_file} {choice_function} --idx={an_arg} --idx_max={args.Nprocess}")
|
|
284
312
|
from machineconfig.cluster.sessions_managers.zellij_local import run_zellij_layout
|
|
313
|
+
|
|
285
314
|
run_zellij_layout(tab_config=tab_config, session_name=None)
|
|
286
315
|
return None
|
|
287
316
|
|
|
@@ -294,6 +323,7 @@ python -m machineconfig.cluster.templates.cli_click --file {choice_file} """
|
|
|
294
323
|
from rich.panel import Panel
|
|
295
324
|
from rich.console import Console
|
|
296
325
|
from rich.syntax import Syntax
|
|
326
|
+
|
|
297
327
|
console = Console()
|
|
298
328
|
|
|
299
329
|
if args.zellij_tab is not None:
|
|
@@ -302,17 +332,22 @@ python -m machineconfig.cluster.templates.cli_click --file {choice_file} """
|
|
|
302
332
|
comman_path__.write_text(command, encoding="utf-8")
|
|
303
333
|
console.print(Panel(Syntax(command, lexer="shell"), title=f"🔥 fire command @ {comman_path__}: "), style="bold red")
|
|
304
334
|
import subprocess
|
|
335
|
+
|
|
305
336
|
existing_tab_names = subprocess.run(["zellij", "action", "query-tab-names"], capture_output=True, text=True, check=True).stdout.splitlines()
|
|
306
337
|
if args.zellij_tab in existing_tab_names:
|
|
307
338
|
print(f"⚠️ Tab name `{args.zellij_tab}` already exists. Please choose a different name.")
|
|
308
339
|
# args.zellij_tab = input("Please enter a new tab name: ")
|
|
309
340
|
args.zellij_tab += f"_{randstr(3)}"
|
|
310
341
|
from machineconfig.cluster.sessions_managers.zellij_local import run_command_in_zellij_tab
|
|
342
|
+
|
|
311
343
|
command = run_command_in_zellij_tab(command=str(comman_path__), tab_name=args.zellij_tab, cwd=None)
|
|
312
|
-
if args.watch:
|
|
313
|
-
|
|
344
|
+
if args.watch:
|
|
345
|
+
command = "watchexec --restart --exts py,sh,ps1 " + command
|
|
346
|
+
if args.git_pull:
|
|
347
|
+
command = f"\ngit -C {choice_file.parent} pull\n" + command
|
|
314
348
|
if args.PathExport:
|
|
315
|
-
if platform.system() in ["Linux", "Darwin"]:
|
|
349
|
+
if platform.system() in ["Linux", "Darwin"]:
|
|
350
|
+
export_line = f"""export PYTHONPATH="{repo_root}""" + """:${PYTHONPATH}" """
|
|
316
351
|
elif platform.system() == "Windows":
|
|
317
352
|
# export_line = f"""set PYTHONPATH="{repo_root}""" + """:%PYTHONPATH%" """
|
|
318
353
|
# powershell equivalent
|
|
@@ -328,8 +363,8 @@ python -m machineconfig.cluster.templates.cli_click --file {choice_file} """
|
|
|
328
363
|
command = command + "\nsleep 0.5"
|
|
329
364
|
elif platform.system() == "Windows":
|
|
330
365
|
# command = command + "timeout 0.5\n"
|
|
331
|
-
#pwsh equivalent
|
|
332
|
-
command ="$ErrorActionPreference = 'SilentlyContinue';\n" + command + "\nStart-Sleep -Seconds 0.5"
|
|
366
|
+
# pwsh equivalent
|
|
367
|
+
command = "$ErrorActionPreference = 'SilentlyContinue';\n" + command + "\nStart-Sleep -Seconds 0.5"
|
|
333
368
|
else:
|
|
334
369
|
raise NotImplementedError(f"Platform {platform.system()} not supported.")
|
|
335
370
|
command = command + f"\n. {program_path}"
|
|
@@ -338,6 +373,6 @@ python -m machineconfig.cluster.templates.cli_click --file {choice_file} """
|
|
|
338
373
|
program_path.write_text(command, encoding="utf-8")
|
|
339
374
|
|
|
340
375
|
|
|
341
|
-
if __name__ ==
|
|
342
|
-
# options, func_args = parse_pyfile(file_path="C:/Users/aalsaf01/code/
|
|
376
|
+
if __name__ == "__main__":
|
|
377
|
+
# options, func_args = parse_pyfile(file_path="C:/Users/aalsaf01/code/machineconfig/myresources/crocodile/core.py")
|
|
343
378
|
main()
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env -S uv run --project /home/alex/code/machineconfig --script
|
|
1
2
|
"""Sx & Rx
|
|
2
3
|
|
|
3
4
|
TODO: add support for cases in which source or target has non 22 default port number and is defineda as user@host:port:path which makes 2 colons in the string.
|
|
@@ -7,7 +8,7 @@ Currently, the only way to work around this is to predifine the host in ~/.ssh/c
|
|
|
7
8
|
|
|
8
9
|
import argparse
|
|
9
10
|
from machineconfig.utils.ssh import SSH
|
|
10
|
-
from machineconfig.utils.path_reduced import
|
|
11
|
+
from machineconfig.utils.path_reduced import PathExtended as PathExtended
|
|
11
12
|
from machineconfig.scripts.python.helpers.helpers2 import ES
|
|
12
13
|
from machineconfig.utils.utils2 import pprint
|
|
13
14
|
|
|
@@ -18,7 +19,7 @@ def main():
|
|
|
18
19
|
┃ 🚀 FTP File Transfer
|
|
19
20
|
┃ 📋 Starting transfer process...
|
|
20
21
|
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━""")
|
|
21
|
-
parser = argparse.ArgumentParser(description=
|
|
22
|
+
parser = argparse.ArgumentParser(description="FTP client")
|
|
22
23
|
|
|
23
24
|
parser.add_argument("source", help="source path (machine:path)")
|
|
24
25
|
parser.add_argument("target", help="target path (machine:path)")
|
|
@@ -37,36 +38,44 @@ def main():
|
|
|
37
38
|
source_parts = args.source.split(":")
|
|
38
39
|
machine = source_parts[0]
|
|
39
40
|
if len(source_parts) > 1 and source_parts[1] == ES: # the source path is to be inferred from target.
|
|
40
|
-
if args.target == ES:
|
|
41
|
+
if args.target == ES:
|
|
42
|
+
raise ValueError(f"""
|
|
41
43
|
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
42
44
|
┃ ❌ Configuration Error
|
|
43
45
|
┃ Cannot use expand symbol `{ES}` in both source and target
|
|
44
46
|
┃ This creates a cyclical inference dependency
|
|
45
47
|
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━""")
|
|
46
|
-
else:
|
|
48
|
+
else:
|
|
49
|
+
target = PathExtended(args.target).expanduser().absolute()
|
|
47
50
|
source = target.collapseuser().as_posix()
|
|
48
51
|
else:
|
|
49
52
|
source = ":".join(args.source.split(":")[1:])
|
|
50
|
-
if args.target == ES:
|
|
51
|
-
|
|
53
|
+
if args.target == ES:
|
|
54
|
+
target = None
|
|
55
|
+
else:
|
|
56
|
+
target = PathExtended(args.target).expanduser().absolute().as_posix()
|
|
52
57
|
|
|
53
58
|
elif ":" in args.target and (args.target[1] != ":" if len(args.target) > 1 else True): # avoid the case of "C:/":
|
|
54
59
|
source_is_remote = False
|
|
55
60
|
target_parts = args.target.split(":")
|
|
56
61
|
machine = target_parts[0]
|
|
57
62
|
if len(target_parts) > 1 and target_parts[1] == ES:
|
|
58
|
-
if args.source == ES:
|
|
63
|
+
if args.source == ES:
|
|
64
|
+
raise ValueError(f"""
|
|
59
65
|
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
60
66
|
┃ ❌ Configuration Error
|
|
61
67
|
┃ Cannot use expand symbol `{ES}` in both source and target
|
|
62
68
|
┃ This creates a cyclical inference dependency
|
|
63
69
|
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━""")
|
|
64
|
-
else:
|
|
70
|
+
else:
|
|
71
|
+
source = args.source
|
|
65
72
|
target = None
|
|
66
73
|
else:
|
|
67
74
|
target = ":".join(args.target.split(":")[1:])
|
|
68
|
-
if args.source == ES:
|
|
69
|
-
|
|
75
|
+
if args.source == ES:
|
|
76
|
+
source = None
|
|
77
|
+
else:
|
|
78
|
+
source = PathExtended(args.source).expanduser().absolute()
|
|
70
79
|
|
|
71
80
|
else:
|
|
72
81
|
raise ValueError("""
|
|
@@ -79,8 +88,9 @@ def main():
|
|
|
79
88
|
pprint({"source": str(source), "target": str(target), "machine": machine}, "CLI Resolution")
|
|
80
89
|
|
|
81
90
|
from paramiko.ssh_exception import AuthenticationException # type: ignore
|
|
91
|
+
|
|
82
92
|
try:
|
|
83
|
-
ssh = SSH(rf
|
|
93
|
+
ssh = SSH(rf"{machine}")
|
|
84
94
|
except AuthenticationException:
|
|
85
95
|
print("""
|
|
86
96
|
┌────────────────────────────────────────────────────────────────
|
|
@@ -91,8 +101,9 @@ def main():
|
|
|
91
101
|
│ This exception only handles password authentication
|
|
92
102
|
└────────────────────────────────────────────────────────────────""")
|
|
93
103
|
import getpass
|
|
104
|
+
|
|
94
105
|
pwd = getpass.getpass()
|
|
95
|
-
ssh = SSH(rf
|
|
106
|
+
ssh = SSH(rf"{machine}", pwd=pwd)
|
|
96
107
|
|
|
97
108
|
if args.cloud:
|
|
98
109
|
print("""
|
|
@@ -117,7 +128,7 @@ def main():
|
|
|
117
128
|
│ 📥 Transfer Mode: Remote → Local
|
|
118
129
|
│ Source: {source}
|
|
119
130
|
│ Target: {target}
|
|
120
|
-
│ Options: {
|
|
131
|
+
│ Options: {"ZIP compression" if args.zipFirst else "No compression"}, {"Recursive" if args.recursive else "Non-recursive"}
|
|
121
132
|
└────────────────────────────────────────────────────────────────""")
|
|
122
133
|
received_file = ssh.copy_to_here(source=source, target=target, z=args.zipFirst, r=args.recursive)
|
|
123
134
|
else:
|
|
@@ -128,7 +139,7 @@ def main():
|
|
|
128
139
|
│ 📤 Transfer Mode: Local → Remote
|
|
129
140
|
│ Source: {source}
|
|
130
141
|
│ Target: {target}
|
|
131
|
-
│ Options: {
|
|
142
|
+
│ Options: {"ZIP compression" if args.zipFirst else "No compression"}, {"Recursive" if args.recursive else "Non-recursive"}
|
|
132
143
|
└────────────────────────────────────────────────────────────────""")
|
|
133
144
|
received_file = ssh.copy_from_here(source=source, target=target, z=args.zipFirst, r=args.recursive)
|
|
134
145
|
|
|
@@ -146,5 +157,5 @@ def main():
|
|
|
146
157
|
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━""")
|
|
147
158
|
|
|
148
159
|
|
|
149
|
-
if __name__ ==
|
|
160
|
+
if __name__ == "__main__":
|
|
150
161
|
main()
|
|
@@ -3,12 +3,13 @@ from pathlib import Path
|
|
|
3
3
|
|
|
4
4
|
def get_zellij_cmd(wd1: Path, wd2: Path) -> str:
|
|
5
5
|
_ = wd1, wd2
|
|
6
|
-
lines = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
lines = [
|
|
7
|
+
""" zellij action new-tab --name gitdiff""",
|
|
8
|
+
"""zellij action new-pane --direction down --name local --cwd ./data """,
|
|
9
|
+
"""zellij action write-chars "cd '{wd1}'; git status" """,
|
|
10
|
+
"""zellij action move-focus up; zellij action close-pane """,
|
|
11
|
+
"""zellij action new-pane --direction down --name remote --cwd code """,
|
|
12
|
+
"""zellij action write-chars "cd '{wd2}' """,
|
|
13
|
+
"""git status" """,
|
|
13
14
|
]
|
|
14
15
|
return "; ".join(lines)
|
|
@@ -4,10 +4,10 @@ from pydantic import ConfigDict
|
|
|
4
4
|
from pydantic.dataclasses import dataclass
|
|
5
5
|
from typing import Optional
|
|
6
6
|
import os
|
|
7
|
-
from machineconfig.utils.
|
|
7
|
+
from machineconfig.utils.source_of_truth import DEFAULTS_PATH
|
|
8
8
|
from rich.console import Console
|
|
9
9
|
from rich.panel import Panel
|
|
10
|
-
from rich import box
|
|
10
|
+
from rich import box # Import box
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
console = Console()
|
|
@@ -16,10 +16,10 @@ console = Console()
|
|
|
16
16
|
class ArgsDefaults:
|
|
17
17
|
# source: str=None
|
|
18
18
|
# target: str=None
|
|
19
|
-
encrypt: bool=False
|
|
20
|
-
zip_: bool=False
|
|
21
|
-
overwrite: bool=False
|
|
22
|
-
share: bool=False
|
|
19
|
+
encrypt: bool = False
|
|
20
|
+
zip_: bool = False
|
|
21
|
+
overwrite: bool = False
|
|
22
|
+
share: bool = False
|
|
23
23
|
rel2home = False
|
|
24
24
|
root = None
|
|
25
25
|
os_specific = False
|
|
@@ -28,12 +28,12 @@ class ArgsDefaults:
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
@dataclass(config=ConfigDict(extra="forbid", frozen=False))
|
|
31
|
-
class Args
|
|
31
|
+
class Args:
|
|
32
32
|
cloud: Optional[str] = None
|
|
33
33
|
|
|
34
|
-
zip: bool=ArgsDefaults.zip_
|
|
35
|
-
overwrite: bool=ArgsDefaults.overwrite
|
|
36
|
-
share: bool=ArgsDefaults.share
|
|
34
|
+
zip: bool = ArgsDefaults.zip_
|
|
35
|
+
overwrite: bool = ArgsDefaults.overwrite
|
|
36
|
+
share: bool = ArgsDefaults.share
|
|
37
37
|
|
|
38
38
|
root: Optional[str] = ArgsDefaults.root
|
|
39
39
|
os_specific: bool = ArgsDefaults.os_specific
|
|
@@ -67,15 +67,16 @@ def find_cloud_config(path: Path):
|
|
|
67
67
|
|
|
68
68
|
def absolute(path: str) -> Path:
|
|
69
69
|
obj = Path(path).expanduser()
|
|
70
|
-
if not path.startswith(".") and
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
if not path.startswith(".") and obj.exists():
|
|
71
|
+
return obj
|
|
72
|
+
try_absing = Path.cwd().joinpath(path)
|
|
73
|
+
if try_absing.exists():
|
|
74
|
+
return try_absing
|
|
73
75
|
display_warning(f"Path {path} could not be resolved to absolute path.")
|
|
74
76
|
display_warning("Trying to resolve symlinks (this may result in unintended paths).")
|
|
75
77
|
return obj.absolute()
|
|
76
78
|
|
|
77
79
|
|
|
78
|
-
|
|
79
80
|
def get_secure_share_cloud_config(interactive: bool, cloud: Optional[str]) -> Args:
|
|
80
81
|
console = Console()
|
|
81
82
|
console.print(Panel("🔐 Secure Share Cloud Configuration", expand=False))
|
|
@@ -88,10 +89,10 @@ def get_secure_share_cloud_config(interactive: bool, cloud: Optional[str]) -> Ar
|
|
|
88
89
|
console.print(f"☁️ Using cloud from environment: {cloud}")
|
|
89
90
|
else:
|
|
90
91
|
try:
|
|
91
|
-
default_cloud__ = read_ini(DEFAULTS_PATH)[
|
|
92
|
+
default_cloud__ = read_ini(DEFAULTS_PATH)["general"]["rclone_config_name"]
|
|
92
93
|
except Exception:
|
|
93
|
-
default_cloud__ =
|
|
94
|
-
if default_cloud__ ==
|
|
94
|
+
default_cloud__ = "No default cloud found."
|
|
95
|
+
if default_cloud__ == "No default cloud found." or interactive:
|
|
95
96
|
# assert default_cloud is not None
|
|
96
97
|
cloud = input(f"☁️ Enter cloud name (default {default_cloud__}): ") or default_cloud__
|
|
97
98
|
else:
|
|
@@ -106,32 +107,36 @@ def get_secure_share_cloud_config(interactive: bool, cloud: Optional[str]) -> Ar
|
|
|
106
107
|
pwd = ""
|
|
107
108
|
default_message = "no default password found"
|
|
108
109
|
pwd = input(f"🔑 Enter encryption password ({default_message}): ") or pwd
|
|
109
|
-
res = Args(cloud=cloud,
|
|
110
|
-
pwd=pwd, encrypt=True,
|
|
111
|
-
zip=True, overwrite=True, share=True,
|
|
112
|
-
rel2home=True, root="myshare", os_specific=False,)
|
|
110
|
+
res = Args(cloud=cloud, pwd=pwd, encrypt=True, zip=True, overwrite=True, share=True, rel2home=True, root="myshare", os_specific=False)
|
|
113
111
|
|
|
114
112
|
display_success("Using SecureShare cloud config")
|
|
115
113
|
pprint(res.__dict__, "SecureShare Config")
|
|
116
114
|
return res
|
|
117
115
|
|
|
116
|
+
|
|
118
117
|
def display_header(title: str):
|
|
119
|
-
console.print(Panel(title, box=box.DOUBLE_EDGE, title_align="left"))
|
|
118
|
+
console.print(Panel(title, box=box.DOUBLE_EDGE, title_align="left")) # Replace print with Panel
|
|
119
|
+
|
|
120
120
|
|
|
121
121
|
def display_subheader(title: str):
|
|
122
|
-
console.print(Panel(title, box=box.ROUNDED, title_align="left"))
|
|
122
|
+
console.print(Panel(title, box=box.ROUNDED, title_align="left")) # Replace print with Panel
|
|
123
|
+
|
|
123
124
|
|
|
124
125
|
def display_content(content: str):
|
|
125
|
-
console.print(Panel(content, box=box.ROUNDED, title_align="left"))
|
|
126
|
+
console.print(Panel(content, box=box.ROUNDED, title_align="left")) # Replace print with Panel
|
|
127
|
+
|
|
126
128
|
|
|
127
129
|
def display_status(status: str):
|
|
128
|
-
console.print(Panel(status, box=box.ROUNDED, title_align="left"))
|
|
130
|
+
console.print(Panel(status, box=box.ROUNDED, title_align="left")) # Replace print with Panel
|
|
131
|
+
|
|
129
132
|
|
|
130
133
|
def display_success(message: str):
|
|
131
|
-
console.print(Panel(message, box=box.ROUNDED, border_style="green", title_align="left"))
|
|
134
|
+
console.print(Panel(message, box=box.ROUNDED, border_style="green", title_align="left")) # Replace print with Panel
|
|
135
|
+
|
|
132
136
|
|
|
133
137
|
def display_warning(message: str):
|
|
134
|
-
console.print(Panel(message, box=box.ROUNDED, border_style="yellow", title_align="left"))
|
|
138
|
+
console.print(Panel(message, box=box.ROUNDED, border_style="yellow", title_align="left")) # Replace print with Panel
|
|
139
|
+
|
|
135
140
|
|
|
136
141
|
def display_error(message: str):
|
|
137
|
-
console.print(Panel(message, box=box.ROUNDED, border_style="red", title_align="left"))
|
|
142
|
+
console.print(Panel(message, box=box.ROUNDED, border_style="red", title_align="left")) # Replace print with Panel
|