machineconfig 2.0__py3-none-any.whl → 2.1__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 +3 -5
- 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 +26 -10
- machineconfig/jobs/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/jobs/linux/msc/cli_agents.sh +16 -0
- machineconfig/jobs/python/check_installations.py +1 -0
- 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/__pycache__/__init__.cpython-313.pyc +0 -0
- 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 +14 -21
- 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_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 +29 -22
- machineconfig/profile/create_hardlinks.py +26 -19
- machineconfig/profile/shell.py +51 -28
- 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 +4 -6
- 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__/croshell.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_jobs.cpython-313.pyc +0 -0
- machineconfig/scripts/python/ai/__init__.py +0 -0
- machineconfig/scripts/python/ai/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/scripts/python/ai/__pycache__/generate_files.cpython-313.pyc +0 -0
- machineconfig/scripts/python/ai/__pycache__/mcinit.cpython-313.pyc +0 -0
- machineconfig/scripts/python/ai/generate_files.py +84 -0
- machineconfig/scripts/python/ai/instructions/python/dev.instructions.md +2 -2
- machineconfig/scripts/python/ai/mcinit.py +7 -3
- machineconfig/scripts/python/ai/scripts/lint_and_type_check.sh +10 -5
- machineconfig/scripts/python/cloud_copy.py +1 -1
- machineconfig/scripts/python/cloud_mount.py +1 -1
- machineconfig/scripts/python/cloud_repo_sync.py +4 -4
- machineconfig/scripts/python/croshell.py +5 -3
- machineconfig/scripts/python/devops_add_identity.py +1 -1
- machineconfig/scripts/python/devops_add_ssh_key.py +1 -1
- machineconfig/scripts/python/devops_backup_retrieve.py +1 -1
- machineconfig/scripts/python/devops_update_repos.py +140 -52
- machineconfig/scripts/python/dotfile.py +1 -1
- machineconfig/scripts/python/fire_agents.py +28 -9
- machineconfig/scripts/python/fire_jobs.py +3 -4
- machineconfig/scripts/python/ftpx.py +2 -1
- machineconfig/scripts/python/helpers/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/scripts/python/helpers/__pycache__/helpers4.cpython-313.pyc +0 -0
- machineconfig/scripts/python/helpers/helpers2.py +2 -2
- machineconfig/scripts/python/helpers/helpers4.py +1 -2
- machineconfig/scripts/python/helpers/repo_sync_helpers.py +1 -1
- machineconfig/scripts/python/mount_nfs.py +1 -1
- machineconfig/scripts/python/mount_ssh.py +1 -1
- machineconfig/scripts/python/repos.py +1 -1
- machineconfig/scripts/python/start_slidev.py +1 -1
- machineconfig/scripts/python/wsl_windows_transfer.py +1 -1
- 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 +1 -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 +0 -54
- machineconfig/setup_linux/web_shortcuts/interactive.sh +6 -6
- 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 +66 -12
- machineconfig/setup_windows/wt_and_pwsh/set_wt_settings.py +44 -36
- 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 +60 -39
- machineconfig/utils/installer.py +27 -33
- machineconfig/utils/installer_utils/installer_abc.py +8 -7
- machineconfig/utils/installer_utils/installer_class.py +149 -70
- machineconfig/utils/links.py +22 -11
- machineconfig/utils/notifications.py +197 -0
- machineconfig/utils/options.py +29 -23
- machineconfig/utils/path.py +13 -6
- machineconfig/utils/path_reduced.py +485 -216
- machineconfig/utils/procs.py +47 -41
- machineconfig/utils/scheduling.py +0 -1
- machineconfig/utils/ssh.py +157 -76
- machineconfig/utils/terminal.py +82 -37
- machineconfig/utils/utils.py +12 -10
- machineconfig/utils/utils2.py +38 -48
- machineconfig/utils/utils5.py +183 -116
- machineconfig/utils/ve.py +9 -4
- {machineconfig-2.0.dist-info → machineconfig-2.1.dist-info}/METADATA +3 -2
- {machineconfig-2.0.dist-info → machineconfig-2.1.dist-info}/RECORD +200 -217
- 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__/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__/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__/repo_sync_helpers.cpython-311.pyc +0 -0
- machineconfig/scripts/windows/activate_ve.ps1 +0 -54
- {machineconfig-2.0.dist-info → machineconfig-2.1.dist-info}/WHEEL +0 -0
- {machineconfig-2.0.dist-info → machineconfig-2.1.dist-info}/top_level.txt +0 -0
machineconfig/utils/links.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from machineconfig.utils.path_reduced import
|
|
1
|
+
from machineconfig.utils.path_reduced import PathExtended as PathExtended, PLike
|
|
2
2
|
from machineconfig.utils.utils2 import randstr
|
|
3
3
|
from rich.console import Console
|
|
4
4
|
from rich.panel import Panel
|
|
@@ -19,6 +19,7 @@ def build_links(target_paths: list[tuple[PLike, str]], repo_root: PLike):
|
|
|
19
19
|
target_dirs_filtered.append((a_dir_obj, a_name))
|
|
20
20
|
|
|
21
21
|
import git
|
|
22
|
+
|
|
22
23
|
repo = git.Repo(repo_root, search_parent_directories=True)
|
|
23
24
|
root_maybe = repo.working_tree_dir
|
|
24
25
|
assert root_maybe is not None
|
|
@@ -31,7 +32,8 @@ def build_links(target_paths: list[tuple[PLike, str]], repo_root: PLike):
|
|
|
31
32
|
links_path = repo_root_obj.joinpath("links", a_name)
|
|
32
33
|
links_path.symlink_to(target=a_target_path)
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
|
|
36
|
+
def symlink_func(this: PathExtended, to_this: PathExtended, prioritize_to_this: bool = True):
|
|
35
37
|
"""helper function. creates a symlink from `this` to `to_this`.
|
|
36
38
|
What can go wrong?
|
|
37
39
|
depending on this and to_this existence, one will be prioretized depending on overwrite value.
|
|
@@ -39,15 +41,19 @@ def symlink_func(this: PathExtended, to_this: PathExtended, prioritize_to_this:
|
|
|
39
41
|
False means to_this will potentially be overwittten."""
|
|
40
42
|
this = PathExtended(this).expanduser().absolute()
|
|
41
43
|
to_this = PathExtended(to_this).expanduser().absolute()
|
|
42
|
-
if this.is_symlink():
|
|
44
|
+
if this.is_symlink():
|
|
45
|
+
this.delete(sure=True) # delete if it exists as symblic link, not a concrete path.
|
|
43
46
|
if this.exists(): # this is a problem. It will be resolved via `overwrite`
|
|
44
47
|
if prioritize_to_this is True: # it *can* be deleted, but let's look at target first.
|
|
45
48
|
if to_this.exists(): # this exists, to_this as well. to_this is prioritized.
|
|
46
49
|
this.append(f".orig_{randstr()}", inplace=True) # rename is better than deletion
|
|
47
|
-
else:
|
|
50
|
+
else:
|
|
51
|
+
this.move(path=to_this) # this exists, to_this doesn't. to_this is prioritized.
|
|
48
52
|
elif prioritize_to_this is False: # don't sacrefice this, sacrefice to_this.
|
|
49
|
-
if to_this.exists():
|
|
50
|
-
|
|
53
|
+
if to_this.exists():
|
|
54
|
+
this.move(path=to_this, overwrite=True) # this exists, to_this as well, this is prioritized. # now we are readly to make the link
|
|
55
|
+
else:
|
|
56
|
+
this.move(path=to_this) # this exists, to_this doesn't, this is prioritized.
|
|
51
57
|
else: # this doesn't exist.
|
|
52
58
|
if not to_this.exists():
|
|
53
59
|
to_this.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -58,18 +64,23 @@ def symlink_func(this: PathExtended, to_this: PathExtended, prioritize_to_this:
|
|
|
58
64
|
except Exception as ex:
|
|
59
65
|
console.print(Panel(f"❌ ERROR | Failed at linking {this} ➡️ {to_this}. Reason: {ex}", title="Error", expand=False))
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
|
|
68
|
+
def symlink_copy(this: PathExtended, to_this: PathExtended, prioritize_to_this: bool = True):
|
|
62
69
|
this = PathExtended(this).expanduser().absolute()
|
|
63
70
|
to_this = PathExtended(to_this).expanduser().absolute()
|
|
64
|
-
if this.is_symlink():
|
|
71
|
+
if this.is_symlink():
|
|
72
|
+
this.delete(sure=True) # delete if it exists as symblic link, not a concrete path.
|
|
65
73
|
if this.exists(): # this is a problem. It will be resolved via `overwrite`
|
|
66
74
|
if prioritize_to_this is True: # it *can* be deleted, but let's look at target first.
|
|
67
75
|
if to_this.exists(): # this exists, to_this as well. to_this is prioritized.
|
|
68
76
|
this.append(f".orig_{randstr()}", inplace=True) # rename is better than deletion
|
|
69
|
-
else:
|
|
77
|
+
else:
|
|
78
|
+
this.move(path=to_this) # this exists, to_this doesn't. to_this is prioritized.
|
|
70
79
|
elif prioritize_to_this is False: # don't sacrefice this, sacrefice to_this.
|
|
71
|
-
if to_this.exists():
|
|
72
|
-
|
|
80
|
+
if to_this.exists():
|
|
81
|
+
this.move(path=to_this, overwrite=True) # this exists, to_this as well, this is prioritized. # now we are readly to make the link
|
|
82
|
+
else:
|
|
83
|
+
this.move(path=to_this) # this exists, to_this doesn't, this is prioritized.
|
|
73
84
|
else: # this doesn't exist.
|
|
74
85
|
if not to_this.exists():
|
|
75
86
|
to_this.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
|
|
2
|
+
"""Notifications Module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
# from crocodile.core import install_n_import
|
|
6
|
+
# from crocodile.file_management import P, Read
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
# from crocodile.meta import RepeatUntilNoException
|
|
9
|
+
import smtplib
|
|
10
|
+
import imaplib
|
|
11
|
+
# from email import message
|
|
12
|
+
# from email import encoders
|
|
13
|
+
# from email.mime.base import MIMEBase
|
|
14
|
+
from email.mime.text import MIMEText
|
|
15
|
+
from email.mime.multipart import MIMEMultipart
|
|
16
|
+
from typing import Optional, Any, Union, Literal
|
|
17
|
+
from markdown import markdown
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def download_to_memory(path: Path, allow_redirects: bool = True, timeout: Optional[float] = None, params: Any = None) -> 'Any':
|
|
22
|
+
import requests
|
|
23
|
+
return requests.get(path.as_posix().replace("https:/", "https://").replace("http:/", "http://"), allow_redirects=allow_redirects, timeout=timeout, params=params) # Alternative: from urllib import request; request.urlopen(url).read().decode('utf-8').
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def get_github_markdown_css() -> str:
|
|
27
|
+
pp = r'https://raw.githubusercontent.com/sindresorhus/github-markdown-css/main/github-markdown-dark.css'
|
|
28
|
+
return download_to_memory(Path(pp)).text
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def md2html(body: str):
|
|
32
|
+
gh_style = Path(__file__).parent.joinpath("gh_style.css").read_text()
|
|
33
|
+
return f"""
|
|
34
|
+
<!DOCTYPE html>
|
|
35
|
+
<html>
|
|
36
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
37
|
+
<style>
|
|
38
|
+
{gh_style}
|
|
39
|
+
.markdown-body {{
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
min-width: 200px;
|
|
42
|
+
max-width: 1350px;
|
|
43
|
+
margin: 0 auto;
|
|
44
|
+
padding: 45px;
|
|
45
|
+
line-height: 1.8;
|
|
46
|
+
}}
|
|
47
|
+
@media (max-width: 767px) {{.markdown-body {{padding: 15px;}}
|
|
48
|
+
}}
|
|
49
|
+
</style>
|
|
50
|
+
<body>
|
|
51
|
+
<div class="markdown-body">
|
|
52
|
+
{markdown(body)}
|
|
53
|
+
</div>
|
|
54
|
+
</body>
|
|
55
|
+
</html>"""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class Email:
|
|
59
|
+
@staticmethod
|
|
60
|
+
def get_source_of_truth():
|
|
61
|
+
path = Path.home().joinpath("dotfiles/machineconfig/emails.ini")
|
|
62
|
+
if not path.exists():
|
|
63
|
+
raise FileNotFoundError(f"""File not found: {path}. It should be an ini file with this structure
|
|
64
|
+
[resend]
|
|
65
|
+
api_key = xxx
|
|
66
|
+
|
|
67
|
+
[config1]
|
|
68
|
+
email_add = a@b.com
|
|
69
|
+
password = 123
|
|
70
|
+
smtp_host = a@b.com
|
|
71
|
+
smtp_port = 465
|
|
72
|
+
imap_host = b@c.com
|
|
73
|
+
imap_port = 465
|
|
74
|
+
encryption = ssl
|
|
75
|
+
|
|
76
|
+
""")
|
|
77
|
+
|
|
78
|
+
if not Path(path).exists() or Path(path).is_dir(): raise FileNotFoundError(f"File not found or is a directory: {path}")
|
|
79
|
+
import configparser
|
|
80
|
+
res = configparser.ConfigParser()
|
|
81
|
+
res.read(filenames=[str(path)], encoding=None)
|
|
82
|
+
return res
|
|
83
|
+
|
|
84
|
+
def __init__(self, config: dict[str, Any]):
|
|
85
|
+
self.config = config
|
|
86
|
+
from smtplib import SMTP_SSL, SMTP
|
|
87
|
+
self.server: Union[SMTP_SSL, SMTP]
|
|
88
|
+
if config['encryption'].lower() == "ssl": self.server = smtplib.SMTP_SSL(host=self.config["smtp_host"], port=self.config["smtp_port"])
|
|
89
|
+
elif config['encryption'].lower() == "tls": self.server = smtplib.SMTP(host=self.config["smtp_host"], port=self.config["smtp_port"])
|
|
90
|
+
self.server.login(self.config['email_add'], password=self.config["password"])
|
|
91
|
+
|
|
92
|
+
def send_message(self, to: str, subject: str, body: str, txt_to_html: bool = True, attachments: Optional[list[Any]] = None):
|
|
93
|
+
_ = attachments
|
|
94
|
+
body += "\n\nThis is an automated email sent via crocodile.comms script."
|
|
95
|
+
# msg = message.EmailMessage()
|
|
96
|
+
msg = MIMEMultipart("alternative")
|
|
97
|
+
msg["subject"] = subject
|
|
98
|
+
msg["From"] = self.config['email_add']
|
|
99
|
+
msg["To"] = to
|
|
100
|
+
# msg['Content-Type'] = "text/html"
|
|
101
|
+
# msg.set_content(body)
|
|
102
|
+
|
|
103
|
+
# <link rel="stylesheet" href="github-markdown.css">
|
|
104
|
+
# <link type="text/css" rel="stylesheet" href="https://raw.githubusercontent.com/sindresorhus/github-markdown-css/main/github-markdown-dark.css" />
|
|
105
|
+
|
|
106
|
+
if txt_to_html: body = md2html(body=body)
|
|
107
|
+
msg.attach(MIMEText(body, "html"))
|
|
108
|
+
# if attachments is None: attachments = [] # see: https://fedingo.com/how-to-send-html-mail-with-attachment-using-python/
|
|
109
|
+
# for attachment in attachmenthrs: msg.attach(attachment.read_bytes(), filename=attachment.stem, maintype="image", subtype=attachment.suffix)
|
|
110
|
+
# for attachment in attachments: msg.attach(attachment.read_bytes(), filename=attachment.stem, maintype="application", subtype="octet-stream")
|
|
111
|
+
|
|
112
|
+
self.server.send_message(msg)
|
|
113
|
+
|
|
114
|
+
@staticmethod
|
|
115
|
+
def manage_folders(email_add: str, pwd: str):
|
|
116
|
+
server = imaplib.IMAP4()
|
|
117
|
+
server.starttls()
|
|
118
|
+
server.login(email_add, password=pwd)
|
|
119
|
+
|
|
120
|
+
def send_email(self, to_addrs: str, msg: str): return self.server.sendmail(from_addr=self.config['email_add'], to_addrs=to_addrs, msg=msg)
|
|
121
|
+
def close(self): self.server.quit() # Closing is vital as many servers do not allow mutiple connections.
|
|
122
|
+
|
|
123
|
+
@staticmethod
|
|
124
|
+
def send_and_close(config_name: Optional[str], to: str, subject: str, body: str) -> Any:
|
|
125
|
+
"""If config_name is None, it sends from a generic email address."""
|
|
126
|
+
if config_name is None:
|
|
127
|
+
raise NotImplementedError("Sending email without a config_name is not implemented. You need to create an emails.ini file in ~/dotfiles/machineconfig/ with your email configuration. See the docstring of the get_source_of_truth method for more information.")
|
|
128
|
+
# config = Email.get_source_of_truth()
|
|
129
|
+
# try:
|
|
130
|
+
# api_key = config['resend']['api_key']
|
|
131
|
+
# to = config["resend"]["signup_email"]
|
|
132
|
+
# except KeyError as ke:
|
|
133
|
+
# msggg = "You did not pass a config_name, therefore, the default is to use resend, however, you need to add your resend api key to the emails.ini file."
|
|
134
|
+
# raise KeyError(msggg) from ke
|
|
135
|
+
|
|
136
|
+
# _resend = install_n_import("resend")
|
|
137
|
+
# import resend # type: ignore
|
|
138
|
+
# resend.api_key = api_key
|
|
139
|
+
# r = resend.Emails.send({
|
|
140
|
+
# "from": "onboarding@resend.dev",
|
|
141
|
+
# "to": to,
|
|
142
|
+
# "subject": subject,
|
|
143
|
+
# "html": md2html(body=body)
|
|
144
|
+
# })
|
|
145
|
+
# return r
|
|
146
|
+
|
|
147
|
+
else:
|
|
148
|
+
config = dict(Email.get_source_of_truth()[config_name])
|
|
149
|
+
tmp = Email(config=config)
|
|
150
|
+
tmp.send_message(to=to, subject=subject, body=body)
|
|
151
|
+
tmp.close()
|
|
152
|
+
|
|
153
|
+
@staticmethod
|
|
154
|
+
def send_m365(to: list[str], subject: str, body: Optional[str], body_file: Optional[str], body_content_type: Literal["HTML", "Text"], attachments: Optional[list[Path]] = None) -> None:
|
|
155
|
+
if body_file is not None:
|
|
156
|
+
assert body is None, "You cannot pass both body and body_file."
|
|
157
|
+
body_file_path = Path(body_file)
|
|
158
|
+
assert body_file_path.exists(), f"File not found: {body_file_path}"
|
|
159
|
+
else:
|
|
160
|
+
body_file_path = None
|
|
161
|
+
assert body is not None, "You must pass either body or body_file."
|
|
162
|
+
from crocodile.meta import Terminal
|
|
163
|
+
to_str = ",".join(to)
|
|
164
|
+
attachments_str = " ".join([f"--attachment {str(p)}" for p in attachments]) if attachments is not None else ""
|
|
165
|
+
|
|
166
|
+
if body_file is not None:
|
|
167
|
+
body_arg = f"--bodyContents @{body_file_path}"
|
|
168
|
+
else:
|
|
169
|
+
body_arg = f'"{body}"'
|
|
170
|
+
cmd = f"""m365 outlook mail send --verbose --saveToSentItems --importance normal --bodyContentType {body_content_type} --bodyContents {body_arg} --subject "{subject}" --to {to_str} {attachments_str}"""
|
|
171
|
+
response = Terminal().run(cmd, shell="powershell")
|
|
172
|
+
response.print(desc="Email sending response")
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
# class PhoneNotification: # security concerns: avoid using this.
|
|
176
|
+
# def __init__(self, token: Optional[str]):
|
|
177
|
+
# if token is None:
|
|
178
|
+
# path = P.home().joinpath("dotfiles/machineconfig/phone_notification.ini")
|
|
179
|
+
# ini = Read.ini(path)
|
|
180
|
+
# token_ = ini["default"]["token"]
|
|
181
|
+
# else:
|
|
182
|
+
# token_ = token
|
|
183
|
+
# pushbullet = install_n_import("pushbullet")
|
|
184
|
+
# self.api = pushbullet.Pushbullet(token_)
|
|
185
|
+
# def send_notification(self, title: str = "Note From Python", body: str = "A notfication"):
|
|
186
|
+
# self.api.push_note(title=title, body=body)
|
|
187
|
+
# @staticmethod
|
|
188
|
+
# def open_website():
|
|
189
|
+
# P(r"https://www.pushbullet.com/")()
|
|
190
|
+
# @staticmethod # https://www.youtube.com/watch?v=tbzPcKRZlHg
|
|
191
|
+
# def try_me(bulletpoint_token: str):
|
|
192
|
+
# n = PhoneNotification(bulletpoint_token)
|
|
193
|
+
# n.send_notification()
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
if __name__ == '__main__':
|
|
197
|
+
pass
|
machineconfig/utils/options.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
from pathlib import Path
|
|
3
2
|
from rich.text import Text
|
|
4
3
|
from rich.panel import Panel
|
|
@@ -10,18 +9,20 @@ from typing import Optional, Union, TypeVar, Iterable
|
|
|
10
9
|
T = TypeVar("T")
|
|
11
10
|
|
|
12
11
|
|
|
13
|
-
|
|
14
12
|
def check_tool_exists(tool_name: str, install_script: Optional[str] = None) -> bool:
|
|
15
13
|
if platform.system() == "Windows":
|
|
16
14
|
tool_name = tool_name.replace(".exe", "") + ".exe"
|
|
17
15
|
|
|
18
|
-
if platform.system() == "Windows":
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
if platform.system() == "Windows":
|
|
17
|
+
cmd = "where.exe"
|
|
18
|
+
elif platform.system() in ["Linux", "Darwin"]:
|
|
19
|
+
cmd = "which"
|
|
20
|
+
else:
|
|
21
|
+
raise NotImplementedError(f"platform {platform.system()} not implemented")
|
|
21
22
|
|
|
22
23
|
try:
|
|
23
24
|
_tmp = subprocess.check_output([cmd, tool_name], stderr=subprocess.DEVNULL)
|
|
24
|
-
res: bool=True
|
|
25
|
+
res: bool = True
|
|
25
26
|
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
26
27
|
res = False
|
|
27
28
|
if res is False and install_script is not None:
|
|
@@ -38,25 +39,20 @@ def check_tool_exists(tool_name: str, install_script: Optional[str] = None) -> b
|
|
|
38
39
|
return res
|
|
39
40
|
|
|
40
41
|
|
|
41
|
-
def choose_one_option(options: Iterable[T], header: str="", tail: str="", prompt: str="", msg: str="",
|
|
42
|
-
|
|
43
|
-
choice_key = display_options(msg=msg, options=options, header=header, tail=tail, prompt=prompt,
|
|
44
|
-
default=default, fzf=fzf, multi=False, custom_input=custom_input)
|
|
42
|
+
def choose_one_option(options: Iterable[T], header: str = "", tail: str = "", prompt: str = "", msg: str = "", default: Optional[T] = None, fzf: bool = False, custom_input: bool = False) -> T:
|
|
43
|
+
choice_key = display_options(msg=msg, options=options, header=header, tail=tail, prompt=prompt, default=default, fzf=fzf, multi=False, custom_input=custom_input)
|
|
45
44
|
assert not isinstance(choice_key, list)
|
|
46
45
|
return choice_key
|
|
47
46
|
|
|
48
47
|
|
|
49
|
-
def choose_multiple_options(options: Iterable[T], header: str="", tail: str="", prompt: str="", msg: str="",
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
custom_input=custom_input)
|
|
54
|
-
if isinstance(choice_key, list): return choice_key
|
|
48
|
+
def choose_multiple_options(options: Iterable[T], header: str = "", tail: str = "", prompt: str = "", msg: str = "", default: Optional[T] = None, custom_input: bool = False) -> list[T]:
|
|
49
|
+
choice_key = display_options(msg=msg, options=options, header=header, tail=tail, prompt=prompt, default=default, fzf=True, multi=True, custom_input=custom_input)
|
|
50
|
+
if isinstance(choice_key, list):
|
|
51
|
+
return choice_key
|
|
55
52
|
return [choice_key]
|
|
56
53
|
|
|
57
54
|
|
|
58
|
-
def display_options(msg: str, options: Iterable[T], header: str="", tail: str="", prompt: str="",
|
|
59
|
-
default: Optional[T] = None, fzf: bool=False, multi: bool=False, custom_input: bool=False) -> Union[T, list[T]]:
|
|
55
|
+
def display_options(msg: str, options: Iterable[T], header: str = "", tail: str = "", prompt: str = "", default: Optional[T] = None, fzf: bool = False, multi: bool = False, custom_input: bool = False) -> Union[T, list[T]]:
|
|
60
56
|
# TODO: replace with https://github.com/tmbo/questionary
|
|
61
57
|
# # also see https://github.com/charmbracelet/gum
|
|
62
58
|
tool_name = "fzf"
|
|
@@ -65,6 +61,7 @@ def display_options(msg: str, options: Iterable[T], header: str="", tail: str=""
|
|
|
65
61
|
console = Console()
|
|
66
62
|
if fzf and check_tool_exists(tool_name):
|
|
67
63
|
from pyfzf.pyfzf import FzfPrompt
|
|
64
|
+
|
|
68
65
|
fzf_prompt = FzfPrompt()
|
|
69
66
|
nl = "\n"
|
|
70
67
|
choice_string_multi: list[str] = fzf_prompt.prompt(choices=options_strings, fzf_options=("--multi" if multi else "") + f' --prompt "{prompt.replace(nl, " ")}" ') # --border-label={msg.replace(nl, ' ')}")
|
|
@@ -84,7 +81,8 @@ def display_options(msg: str, options: Iterable[T], header: str="", tail: str=""
|
|
|
84
81
|
if default is not None:
|
|
85
82
|
assert default in options, f"Default `{default}` option not in options `{list(options)}`"
|
|
86
83
|
default_msg = Text(" <<<<-------- DEFAULT", style="bold red")
|
|
87
|
-
else:
|
|
84
|
+
else:
|
|
85
|
+
default_msg = Text("")
|
|
88
86
|
txt = Text("\n" + msg + "\n")
|
|
89
87
|
for idx, key in enumerate(options):
|
|
90
88
|
txt = txt + Text(f"{idx:2d} ", style="bold blue") + str(key) + (default_msg if default is not None and default == key else "") + "\n"
|
|
@@ -111,7 +109,8 @@ def display_options(msg: str, options: Iterable[T], header: str="", tail: str=""
|
|
|
111
109
|
if choice_string in options_strings: # string input
|
|
112
110
|
choice_idx = options_strings.index(choice_one) # type: ignore
|
|
113
111
|
choice_one = list(options)[choice_idx]
|
|
114
|
-
elif custom_input:
|
|
112
|
+
elif custom_input:
|
|
113
|
+
return str(choice_string) # type: ignore
|
|
115
114
|
else:
|
|
116
115
|
_ = ie
|
|
117
116
|
# raise ValueError(f"Unknown choice. {choice_string}") from ie
|
|
@@ -129,7 +128,8 @@ def display_options(msg: str, options: Iterable[T], header: str="", tail: str=""
|
|
|
129
128
|
console.print(Panel(f"❓ Unknown choice: '{choice_string}'", title="Error", expand=False))
|
|
130
129
|
return display_options(msg=msg, options=options, header=header, tail=tail, prompt=prompt, default=default, fzf=fzf, multi=multi, custom_input=custom_input)
|
|
131
130
|
console.print(Panel(f"✅ Selected option {choice_idx}: {choice_one}", title="Selected", expand=False))
|
|
132
|
-
if multi:
|
|
131
|
+
if multi:
|
|
132
|
+
return [choice_one]
|
|
133
133
|
return choice_one
|
|
134
134
|
|
|
135
135
|
|
|
@@ -141,16 +141,22 @@ def choose_cloud_interactively() -> str:
|
|
|
141
141
|
if isinstance(tmp, str):
|
|
142
142
|
remotes: list[str] = [x.replace(":", "") for x in tmp.splitlines()]
|
|
143
143
|
|
|
144
|
-
else:
|
|
144
|
+
else:
|
|
145
|
+
raise ValueError(f"Got {tmp} from rclone listremotes")
|
|
145
146
|
if len(remotes) == 0:
|
|
146
147
|
raise RuntimeError("You don't have remotes. Configure your rclone first to get cloud services access.")
|
|
147
148
|
cloud: str = choose_one_option(msg="WHICH CLOUD?", options=list(remotes), default=remotes[0], fzf=True)
|
|
148
149
|
console.print(Panel(f"✅ SELECTED CLOUD | {cloud}", border_style="bold blue", expand=False))
|
|
149
150
|
return cloud
|
|
150
151
|
|
|
152
|
+
|
|
151
153
|
def get_ssh_hosts() -> list[str]:
|
|
152
154
|
from paramiko import SSHConfig
|
|
155
|
+
|
|
153
156
|
c = SSHConfig()
|
|
154
157
|
c.parse(open(Path.home().joinpath(".ssh/config"), encoding="utf-8"))
|
|
155
158
|
return list(c.get_hostnames())
|
|
156
|
-
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def choose_ssh_host(multi: bool = True):
|
|
162
|
+
return display_options(msg="", options=get_ssh_hosts(), multi=multi, fzf=True)
|
machineconfig/utils/path.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from machineconfig.utils.path_reduced import
|
|
1
|
+
from machineconfig.utils.path_reduced import PathExtended as PathExtended
|
|
2
2
|
from machineconfig.utils.options import choose_one_option
|
|
3
3
|
from rich.console import Console
|
|
4
4
|
from rich.panel import Panel
|
|
@@ -11,12 +11,14 @@ from pathlib import Path
|
|
|
11
11
|
T = TypeVar("T")
|
|
12
12
|
console = Console()
|
|
13
13
|
|
|
14
|
+
|
|
14
15
|
def sanitize_path(a_path: PathExtended) -> PathExtended:
|
|
15
16
|
path = PathExtended(a_path)
|
|
16
17
|
if Path.cwd() == Path.home() and not path.exists():
|
|
17
18
|
result = input("Current working directory is home, and passed path is not full path, are you sure you want to continue, [y]/n? ") or "y"
|
|
18
19
|
if result == "y":
|
|
19
20
|
import sys
|
|
21
|
+
|
|
20
22
|
sys.exit()
|
|
21
23
|
if path.as_posix().startswith("/home") or path.as_posix().startswith("/Users"):
|
|
22
24
|
if platform.system() == "Windows": # path copied from Linux/Mac to Windows
|
|
@@ -70,7 +72,8 @@ def match_file_name(sub_string: str, search_root: PathExtended) -> PathExtended:
|
|
|
70
72
|
search_root_obj = search_root.absolute()
|
|
71
73
|
# assume subscript is filename only, not a sub_path. There is no need to fzf over the paths.
|
|
72
74
|
filename_matches, partial_path_matches = find_scripts(search_root_obj, sub_string)
|
|
73
|
-
if len(filename_matches) == 1:
|
|
75
|
+
if len(filename_matches) == 1:
|
|
76
|
+
return PathExtended(filename_matches[0])
|
|
74
77
|
console.print(Panel(f"Partial filename match with case-insensitivity failed. This generated #{len(filename_matches)} results.", title="Search", expand=False))
|
|
75
78
|
if len(filename_matches) < 10:
|
|
76
79
|
print("\n".join([a_potential_match.as_posix() for a_potential_match in filename_matches]))
|
|
@@ -78,7 +81,8 @@ def match_file_name(sub_string: str, search_root: PathExtended) -> PathExtended:
|
|
|
78
81
|
print("Try to narrow down filename_matches search by case-sensitivity.")
|
|
79
82
|
# let's see if avoiding .lower() helps narrowing down to one result
|
|
80
83
|
reduced_scripts = [a_potential_match for a_potential_match in filename_matches if sub_string in a_potential_match.name]
|
|
81
|
-
if len(reduced_scripts) == 1:
|
|
84
|
+
if len(reduced_scripts) == 1:
|
|
85
|
+
return PathExtended(reduced_scripts[0])
|
|
82
86
|
elif len(reduced_scripts) > 1:
|
|
83
87
|
choice = choose_one_option(msg="Multiple matches found", options=reduced_scripts, fzf=True)
|
|
84
88
|
return PathExtended(choice)
|
|
@@ -92,18 +96,21 @@ def match_file_name(sub_string: str, search_root: PathExtended) -> PathExtended:
|
|
|
92
96
|
elif len(partial_path_matches) > 1:
|
|
93
97
|
print("Try to narrow down partial_path_matches search by case-sensitivity.")
|
|
94
98
|
reduced_scripts = [a_potential_match for a_potential_match in partial_path_matches if sub_string in a_potential_match.as_posix()]
|
|
95
|
-
if len(reduced_scripts) == 1:
|
|
99
|
+
if len(reduced_scripts) == 1:
|
|
100
|
+
return PathExtended(reduced_scripts[0])
|
|
96
101
|
print(f"Result: This still generated {len(reduced_scripts)} results.")
|
|
97
102
|
try:
|
|
98
103
|
fzf_cmd = f"cd '{search_root_obj}'; fd --type file --strip-cwd-prefix | fzf --ignore-case --exact --query={sub_string}"
|
|
99
104
|
console.print(Panel(f"🔍 Second attempt: SEARCH STRATEGY | Using fd to search for '{sub_string}' in '{search_root_obj}' ...\n{fzf_cmd}", title="Search Strategy", expand=False))
|
|
100
|
-
search_res_raw = subprocess.run(fzf_cmd, stdout=subprocess.PIPE, text=True, check=True, shell=True
|
|
105
|
+
search_res_raw = subprocess.run(fzf_cmd, stdout=subprocess.PIPE, text=True, check=True, shell=True).stdout
|
|
101
106
|
search_res = search_res_raw.strip().split("\\n")[:-1]
|
|
102
107
|
except subprocess.CalledProcessError as cpe:
|
|
103
108
|
console.print(Panel(f"❌ ERROR | FZF search failed with '{sub_string}' in '{search_root_obj}'.\n{cpe}", title="Error", expand=False))
|
|
104
109
|
import sys
|
|
110
|
+
|
|
105
111
|
sys.exit(f"💥 FILE NOT FOUND | Path {sub_string} does not exist @ root {search_root_obj}. No search results.")
|
|
106
|
-
if len(search_res) == 1:
|
|
112
|
+
if len(search_res) == 1:
|
|
113
|
+
return search_root_obj.joinpath(search_res_raw)
|
|
107
114
|
|
|
108
115
|
print(f"⚠️ WARNING | Multiple search results found for `{sub_string}`\n'{search_res_raw}'")
|
|
109
116
|
cmd = f"cd '{search_root_obj}'; fd --type file | fzf --select-1 --query={sub_string}"
|