machineconfig 1.7__py3-none-any.whl → 1.8__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/__init__.py +2 -2
- machineconfig/jobs/python/check_installations.py +37 -31
- machineconfig/jobs/python/create_bootable_media.py +4 -4
- machineconfig/jobs/python/create_zellij_template.py +3 -2
- machineconfig/jobs/python/python_cargo_build_share.py +14 -9
- machineconfig/jobs/python/python_ve_symlink.py +6 -6
- machineconfig/jobs/{python_linux_installers/dev → script_installer}/azure_data_studio.py +6 -5
- machineconfig/jobs/{python_windows_installers/dev → script_installer}/bypass_paywall.py +5 -4
- machineconfig/jobs/script_installer/code.py +34 -0
- machineconfig/jobs/{python_linux_installers/dev → script_installer}/docker_desktop.py +2 -2
- machineconfig/jobs/script_installer/ngrok.py +29 -0
- machineconfig/jobs/script_installer/skim.py +21 -0
- machineconfig/jobs/script_installer/wezterm.py +34 -0
- machineconfig/profile/create.py +8 -6
- machineconfig/profile/shell.py +15 -13
- machineconfig/scripts/python/cloud_copy.py +14 -13
- machineconfig/scripts/python/cloud_mount.py +27 -11
- machineconfig/scripts/python/cloud_repo_sync.py +32 -14
- machineconfig/scripts/python/cloud_sync.py +9 -9
- machineconfig/scripts/python/croshell.py +3 -3
- machineconfig/scripts/python/devops.py +22 -6
- machineconfig/scripts/python/devops_add_identity.py +7 -6
- machineconfig/scripts/python/devops_add_ssh_key.py +10 -9
- machineconfig/scripts/python/devops_backup_retrieve.py +5 -5
- machineconfig/scripts/python/devops_devapps_install.py +13 -14
- machineconfig/scripts/python/devops_update_repos.py +5 -4
- machineconfig/scripts/python/dotfile.py +8 -4
- machineconfig/scripts/python/fire_jobs.py +95 -24
- machineconfig/scripts/python/ftpx.py +1 -1
- machineconfig/scripts/python/mount_nfs.py +13 -10
- machineconfig/scripts/python/mount_nw_drive.py +4 -3
- machineconfig/scripts/python/mount_ssh.py +8 -5
- machineconfig/scripts/python/repos.py +21 -20
- machineconfig/scripts/python/snapshot.py +2 -2
- machineconfig/scripts/python/start_slidev.py +104 -0
- machineconfig/setup_windows/wt_and_pwsh/set_pwsh_theme.py +20 -34
- machineconfig/setup_windows/wt_and_pwsh/set_wt_settings.py +11 -12
- machineconfig/utils/installer.py +96 -204
- machineconfig/utils/scheduling.py +1 -1
- machineconfig/utils/utils.py +102 -51
- machineconfig/utils/ve.py +96 -13
- {machineconfig-1.7.dist-info → machineconfig-1.8.dist-info}/METADATA +8 -8
- machineconfig-1.8.dist-info/RECORD +70 -0
- machineconfig/jobs/python_generic_installers/archive/gopass.py +0 -18
- machineconfig/jobs/python_generic_installers/archive/nvim.py +0 -20
- machineconfig/jobs/python_generic_installers/archive/opencommit.py +0 -25
- machineconfig/jobs/python_generic_installers/archive/strongbox.py +0 -33
- machineconfig/jobs/python_generic_installers/dev/__init__.py +0 -0
- machineconfig/jobs/python_linux_installers/archive/__init__.py +0 -0
- machineconfig/jobs/python_linux_installers/archive/bandwhich.py +0 -14
- machineconfig/jobs/python_linux_installers/archive/ranger.py +0 -19
- machineconfig/jobs/python_linux_installers/dev/bytehound.py +0 -20
- machineconfig/jobs/python_linux_installers/dev/nnn.py +0 -22
- machineconfig/jobs/python_windows_installers/archive/ntop.py +0 -21
- machineconfig/jobs/python_windows_installers/dev/obs_background_removal_plugin.py +0 -22
- machineconfig/scripts/python/choose_ohmybash_theme.py +0 -31
- machineconfig/scripts/python/choose_ohmyposh_theme.py +0 -57
- machineconfig/utils/pandas_type.py +0 -37
- machineconfig/utils/to_exe.py +0 -7
- machineconfig-1.7.dist-info/RECORD +0 -81
- /machineconfig/jobs/{python_generic_installers/archive → script_installer}/__init__.py +0 -0
- {machineconfig-1.7.dist-info → machineconfig-1.8.dist-info}/WHEEL +0 -0
- {machineconfig-1.7.dist-info → machineconfig-1.8.dist-info}/top_level.txt +0 -0
machineconfig/__init__.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"""CI
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
import time
|
|
7
7
|
import pandas as pd
|
|
8
8
|
import platform
|
|
@@ -10,18 +10,21 @@ from rich.console import Console
|
|
|
10
10
|
# from rich.progress import track
|
|
11
11
|
from machineconfig.utils.utils import LIBRARY_ROOT, INSTALL_VERSION_ROOT
|
|
12
12
|
from machineconfig.utils.installer import get_installed_cli_apps
|
|
13
|
+
from crocodile.core import List as L, install_n_import, Struct
|
|
14
|
+
from crocodile.file_management import P
|
|
15
|
+
from crocodile.meta import Terminal
|
|
13
16
|
from tqdm import tqdm
|
|
14
17
|
from typing import Optional
|
|
15
18
|
|
|
16
19
|
|
|
17
20
|
APP_SUMMARY_PATH = LIBRARY_ROOT.joinpath(f"profile/records/{platform.system().lower()}/apps_summary_report.csv")
|
|
18
|
-
CLOUD: str = "gdw" #
|
|
21
|
+
CLOUD: str = "gdw" # Read.ini(DEFAULTS_PATH)['general']['rclone_config_name']
|
|
19
22
|
# my onedrive doesn't allow sharing.
|
|
20
23
|
|
|
21
24
|
|
|
22
|
-
def scan(path:
|
|
23
|
-
vt =
|
|
24
|
-
client = vt.Client(
|
|
25
|
+
def scan(path: P, pct: float = 0.0):
|
|
26
|
+
vt = install_n_import(library="vt", package="vt-py")
|
|
27
|
+
client = vt.Client(P.home().joinpath("dotfiles/creds/tokens/virustotal").read_text().split("\n")[0])
|
|
25
28
|
console = Console()
|
|
26
29
|
console.rule(f"Scanning {path}. {pct:.2f}% done")
|
|
27
30
|
if path.is_dir():
|
|
@@ -34,7 +37,6 @@ def scan(path: tb.P, pct: float = 0.0):
|
|
|
34
37
|
with console.status(f"waiting for scan of {path} ... "):
|
|
35
38
|
try:
|
|
36
39
|
anal = client.get_object("/analyses/{}", analysis.id)
|
|
37
|
-
# print(anal.status)
|
|
38
40
|
if anal.status == "completed": break
|
|
39
41
|
except Exception as ex: # type: ignore
|
|
40
42
|
repeat_counter += 1
|
|
@@ -42,33 +44,37 @@ def scan(path: tb.P, pct: float = 0.0):
|
|
|
42
44
|
raise ValueError(f"Error in scanning {path}") from ex
|
|
43
45
|
print(f"Error in scanning, trying again.")
|
|
44
46
|
time.sleep(30)
|
|
45
|
-
df = pd.DataFrame(anal.results)
|
|
47
|
+
df = pd.DataFrame(anal.results.values())
|
|
46
48
|
malicious = []
|
|
47
49
|
for _idx, row in df.iterrows():
|
|
50
|
+
# try:
|
|
51
|
+
# print(row.result)
|
|
52
|
+
# except Exception as ex: # type: ignore
|
|
53
|
+
# print(row)
|
|
48
54
|
if row.result is None and row.category in ["undetected", "type-unsupported", "failure", "timeout", "confirmed-timeout"]: continue
|
|
49
55
|
else:
|
|
50
|
-
|
|
56
|
+
Struct(row.to_dict()).print(as_config=True, title=f"Found Category {row.category}")
|
|
51
57
|
malicious.append(row)
|
|
52
|
-
positive_pct = round(len(malicious) / len(df) * 100, 1)
|
|
58
|
+
positive_pct: float = round(number=len(malicious) / len(df) * 100, ndigits=1)
|
|
53
59
|
print(f"positive_ratio = {positive_pct:.1f} %")
|
|
54
60
|
return positive_pct, df
|
|
55
61
|
|
|
56
62
|
|
|
57
63
|
def main() -> None:
|
|
58
|
-
apps_paths_tmp:
|
|
59
|
-
versions_files_paths:
|
|
64
|
+
apps_paths_tmp: L[P] = get_installed_cli_apps()
|
|
65
|
+
versions_files_paths: L[P] = INSTALL_VERSION_ROOT.search()
|
|
60
66
|
app_versions: list[Optional[str]] = []
|
|
61
|
-
apps_paths_raw:
|
|
62
|
-
for an_app in
|
|
63
|
-
|
|
64
|
-
if len(
|
|
65
|
-
app_versions.append(
|
|
66
|
-
apps_paths_raw.append(
|
|
67
|
+
apps_paths_raw: L[P] = L([])
|
|
68
|
+
for an_app in apps_paths_tmp:
|
|
69
|
+
version_path = versions_files_paths.filter(lambda x: x.stem == an_app.stem)
|
|
70
|
+
if len(version_path) == 1:
|
|
71
|
+
app_versions.append(version_path.list[0].read_text())
|
|
72
|
+
apps_paths_raw.append(an_app)
|
|
67
73
|
# if an_app.stem in versions_files_paths.stem:
|
|
68
74
|
# app_versions.append(versions_files_paths.filter(lambda x: x.stem == an_app.stem.replace(".exe", "")).list[0].read_text())
|
|
69
75
|
# else:
|
|
70
76
|
# print(f"🤔 Cloud not find a documented version for installation of {an_app.stem}, trying to get it from the app itself.")
|
|
71
|
-
# tmp =
|
|
77
|
+
# tmp = Terminal().run(f"{an_app.stem} --version", shell="powershell").capture().op_if_successfull_or_default(strict_err=False, strict_returcode=False)
|
|
72
78
|
# if tmp is not None: tmp = tmp.split("\n")[0]
|
|
73
79
|
# print(f"➡️ Found version `{tmp}` for {an_app.stem}.")
|
|
74
80
|
# app_versions.append(None)
|
|
@@ -94,8 +100,8 @@ def main() -> None:
|
|
|
94
100
|
|
|
95
101
|
app_url: list[Optional[str]] = []
|
|
96
102
|
for idx, row in tqdm(res_df.iterrows(), total=res_df.shape[0]):
|
|
97
|
-
apps_safe_url = upload(
|
|
98
|
-
app_url.append(apps_safe_url.as_posix() if type(apps_safe_url) is
|
|
103
|
+
apps_safe_url = upload(P(str(row["app_path"])).expanduser())
|
|
104
|
+
app_url.append(apps_safe_url.as_posix() if type(apps_safe_url) is P else apps_safe_url)
|
|
99
105
|
res_df["app_url"] = app_url
|
|
100
106
|
res_df.to_csv(APP_SUMMARY_PATH.with_suffix(".csv").create(parents_only=True), index=False)
|
|
101
107
|
APP_SUMMARY_PATH.with_suffix(".md").write_text(res_df.to_markdown())
|
|
@@ -103,8 +109,8 @@ def main() -> None:
|
|
|
103
109
|
print(res_df)
|
|
104
110
|
|
|
105
111
|
|
|
106
|
-
def upload(path:
|
|
107
|
-
set_time_out =
|
|
112
|
+
def upload(path: P):
|
|
113
|
+
set_time_out = install_n_import("call_function_with_timeout").SetTimeout
|
|
108
114
|
func_with_timeout = set_time_out(lambda: path.to_cloud(CLOUD, rel2home=True, share=True, os_specific=True), timeout=180)
|
|
109
115
|
is_done, _is_timeout, _erro_message, results = func_with_timeout()
|
|
110
116
|
if is_done: return results
|
|
@@ -113,17 +119,17 @@ def upload(path: tb.P):
|
|
|
113
119
|
|
|
114
120
|
class PrecheckedCloudInstaller:
|
|
115
121
|
def __init__(self):
|
|
116
|
-
|
|
122
|
+
install_n_import("gdown")
|
|
117
123
|
self.df = pd.read_csv(APP_SUMMARY_PATH)
|
|
118
124
|
|
|
119
125
|
@staticmethod
|
|
120
126
|
def download_google_links(url: str):
|
|
121
127
|
# if "drive.google.com" in str(url): url = str(url).replace("open?", "uc?")
|
|
122
128
|
# else: raise NotImplementedError("Only google drive is supported for now.")
|
|
123
|
-
# return
|
|
124
|
-
gdrive_id =
|
|
125
|
-
gdown =
|
|
126
|
-
result =
|
|
129
|
+
# return P(url).download(name=name)
|
|
130
|
+
gdrive_id = P(url).parts[-1].split("id=")[1]
|
|
131
|
+
gdown = install_n_import("gdown")
|
|
132
|
+
result = P(gdown.download(id=gdrive_id)).absolute()
|
|
127
133
|
return result
|
|
128
134
|
|
|
129
135
|
@staticmethod
|
|
@@ -134,10 +140,10 @@ class PrecheckedCloudInstaller:
|
|
|
134
140
|
print(f"Error in downloading {app_url} {ex}")
|
|
135
141
|
return None
|
|
136
142
|
if platform.system().lower() == "linux":
|
|
137
|
-
|
|
138
|
-
|
|
143
|
+
Terminal().run(f"chmod +x {exe}")
|
|
144
|
+
Terminal().run(f"mv {exe} /usr/local/bin/")
|
|
139
145
|
elif platform.system().lower() == "windows":
|
|
140
|
-
exe.move(folder=
|
|
146
|
+
exe.move(folder=P.home().joinpath("AppData/Local/Microsoft/WindowsApps"), overwrite=True)
|
|
141
147
|
return True
|
|
142
148
|
|
|
143
149
|
def download_safe_apps(self, name: str = "AllEssentials"):
|
|
@@ -152,7 +158,7 @@ class PrecheckedCloudInstaller:
|
|
|
152
158
|
if name == "AllEssentials":
|
|
153
159
|
print(f"Downloading {self.df.shape[0]} apps ...")
|
|
154
160
|
print(self.df)
|
|
155
|
-
_res =
|
|
161
|
+
_res = L(self.df.app_url).apply(PrecheckedCloudInstaller.install_cli_apps, jobs=20)
|
|
156
162
|
else:
|
|
157
163
|
app_url = self.df[self.df.app_name == name].iloc[0].app_url
|
|
158
164
|
_res = PrecheckedCloudInstaller.install_cli_apps(app_url=app_url)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
#
|
|
4
4
|
|
|
5
5
|
# # one can either install rufus: https://rufus.ie/en/
|
|
6
6
|
# # however, to create bootable media with multiple OSs to choose from:
|
|
7
7
|
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
8
|
+
# P(r'https://github.com/ventoy/Ventoy/archive/refs/tags/v1.0.78.zip').download().unzip().search[0]()
|
|
9
|
+
# P(r'https://mirrors.layeronline.com/linuxmint/stable/21/linuxmint-21-cinnamon-64bit.iso').download(folder=P.home().joinpath("Downloads/os").create())
|
|
10
|
+
# P(r'https://download.manjaro.org/kde/21.3.7/manjaro-kde-21.3.7-minimal-220816-linux515.iso').download(folder=P.home().joinpath("Downloads/os").create())
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
# if __name__ == '__main__':
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
"""ZT
|
|
3
3
|
"""
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import socket
|
|
6
6
|
from machineconfig.utils.utils import choose_ssh_host, write_shell_script
|
|
7
|
+
from crocodile.file_management import P
|
|
7
8
|
|
|
8
9
|
prefix = """
|
|
9
10
|
|
|
@@ -41,7 +42,7 @@ def build_template(tabs: list[str]):
|
|
|
41
42
|
for t in tabs:
|
|
42
43
|
res += tab.replace("TABNAME", t).replace("TABCOMMAND", f"ssh").replace("TABARGS", t)
|
|
43
44
|
res += suffix.replace("THISMACHINE", socket.gethostname())
|
|
44
|
-
file =
|
|
45
|
+
file = P.tmp().joinpath(f"tmp_files/templates/zellij_template.kdl").create(parents_only=True).write_text(res)
|
|
45
46
|
res = f"zellij --layout {file}"
|
|
46
47
|
return res
|
|
47
48
|
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
"""
|
|
3
|
+
cargo install
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from crocodile.meta import Terminal
|
|
7
|
+
from crocodile.file_management import P
|
|
3
8
|
import platform
|
|
4
9
|
|
|
5
10
|
|
|
@@ -18,22 +23,22 @@ cargo install --path .
|
|
|
18
23
|
"""
|
|
19
24
|
print(f"Executing {script}")
|
|
20
25
|
if platform.system() == "Windows":
|
|
21
|
-
|
|
26
|
+
Terminal(stdout=None).run(f". {P.tmpfile(suffix='.ps1').write_text(script)}", shell="pwsh").print()
|
|
22
27
|
else:
|
|
23
|
-
|
|
28
|
+
Terminal(stdout=None).run(script, shell="pwsh")
|
|
24
29
|
|
|
25
|
-
exe =
|
|
30
|
+
exe = P.home().joinpath(f".cargo/bin/{tool_name}" + (".exe" if platform.system() == "Windows" else ""))
|
|
26
31
|
|
|
27
32
|
try:
|
|
28
|
-
|
|
33
|
+
P.home().joinpath(tool_name).delete(sure=True)
|
|
29
34
|
except PermissionError:
|
|
30
|
-
print(f"PermissionError, couldn't delete: {
|
|
35
|
+
print(f"PermissionError, couldn't delete: {P.home().joinpath(tool_name)}")
|
|
31
36
|
|
|
32
37
|
if platform.system() == "Windows":
|
|
33
|
-
exe = exe.move(folder=
|
|
38
|
+
exe = exe.move(folder=P.get_env().WindowsApps)
|
|
34
39
|
elif platform.system() == "Linux":
|
|
35
|
-
|
|
36
|
-
exe =
|
|
40
|
+
Terminal().run(f"sudo mv {exe} /usr/local/bin")
|
|
41
|
+
exe = P(r"/usr/local/bin").joinpath(exe.name)
|
|
37
42
|
else:
|
|
38
43
|
raise NotImplementedError(f"Platform {platform.system()} not supported.")
|
|
39
44
|
share_link = exe.to_cloud("gdpo", share=True)
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
"""Symlinks
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
from crocodile.file_management import P
|
|
6
6
|
# from machineconfig.utils.utils import display_options
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def main():
|
|
10
|
-
target =
|
|
11
|
-
source = input(f"symlink from which source ? [default to: CWD/{target.name}] ") or
|
|
12
|
-
if isinstance(source, str): source =
|
|
13
|
-
# ve_path = display_options(msg="symlin link? ", options=
|
|
14
|
-
#
|
|
10
|
+
target = P(input("Symlink to which target? ")).expanduser().absolute()
|
|
11
|
+
source = input(f"symlink from which source ? [default to: CWD/{target.name}] ") or P.cwd().joinpath(target.name)
|
|
12
|
+
if isinstance(source, str): source = P(source).expanduser().absolute()
|
|
13
|
+
# ve_path = display_options(msg="symlin link? ", options=P.home().joinpath("ve").starget.symlink_to; P(r'$pwd').joinpath('venv').symlink_to(r'$to'); P('.gitignore').modify_text('venv', 'venv', replace_line=True)"(target.symlink_to(
|
|
14
|
+
# P('.gitignore').modify_text('venv', 'venv', replace_line=True)"
|
|
15
15
|
source.symlink_to(target, overwrite=True)
|
|
16
16
|
return "echo '😁 Finished creating symlink.'"
|
|
17
17
|
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
from typing import Optional
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
__doc__ = """Azure Data Studio is a data management tool that enables working with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux."""
|
|
3
|
+
import platform
|
|
6
4
|
|
|
7
5
|
|
|
8
6
|
def main(version: Optional[str] = None):
|
|
9
7
|
_ = version
|
|
10
|
-
return f"""
|
|
8
|
+
if platform.system() == "Linux": return f"""
|
|
11
9
|
|
|
12
10
|
curl https://azuredatastudio-update.azurewebsites.net/latest/linux-x64/stable -o ~/azuredatastudio-linux-x64.tar.gz
|
|
13
11
|
tar -xvf ~/azuredatastudio-linux-<version string>.tar.gz
|
|
@@ -15,7 +13,10 @@ echo 'export PATH="$PATH:~/azuredatastudio-linux-x64"' >> ~/.bashrc
|
|
|
15
13
|
source ~/.bashrc
|
|
16
14
|
|
|
17
15
|
"""
|
|
16
|
+
elif platform.system() == "Windows": return "winget install -e --id Microsoft.AzureDataStudio"
|
|
17
|
+
else:
|
|
18
|
+
raise NotImplementedError(f"Your platform {platform.system()} is not supported!")
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
if __name__ == '__main__':
|
|
21
|
-
|
|
22
|
+
pass
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
# import numpy as np
|
|
3
3
|
# import matplotlib.pyplot as plt
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
# from platform import system
|
|
6
6
|
from typing import Optional
|
|
7
|
+
from crocodile.file_management import P
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
__doc__ = """Plugin for chrome to bypass paywalls"""
|
|
@@ -13,10 +14,10 @@ def main(version: Optional[str] = None):
|
|
|
13
14
|
_ = version
|
|
14
15
|
# see remove paywalls and enhance YT experience by Chris Titus
|
|
15
16
|
folder = r"C:\\"
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
P("https://github.com/iamadamdev/bypass-paywalls-chrome/archive/master.zip").download().unzip(folder=folder, content=True)
|
|
18
|
+
P(folder).joinpath("bypass-paywalls-chrome-master")
|
|
18
19
|
return ""
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
if __name__ == '__main__':
|
|
22
|
-
|
|
23
|
+
pass
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
"""vs code installer as per https://code.visualstudio.com/docs/setup/linux
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Optional
|
|
6
|
+
import platform
|
|
7
|
+
|
|
8
|
+
def main(version: Optional[str] = None):
|
|
9
|
+
|
|
10
|
+
if platform.system() == 'Linux':
|
|
11
|
+
code = """
|
|
12
|
+
|
|
13
|
+
sudo apt-get install wget gpg
|
|
14
|
+
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
|
|
15
|
+
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
|
|
16
|
+
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
|
|
17
|
+
rm -f packages.microsoft.gpg
|
|
18
|
+
|
|
19
|
+
sudo apt install apt-transport-https -y
|
|
20
|
+
sudo apt update
|
|
21
|
+
sudo apt install code -y # or code-insiders
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
elif platform.system() == 'Windows':
|
|
26
|
+
code = "winget install -e --id Microsoft.VisualStudioCode"
|
|
27
|
+
else:
|
|
28
|
+
raise NotImplementedError(f"Unsupported platform: {platform.system()}")
|
|
29
|
+
_ = version
|
|
30
|
+
return code
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if __name__ == '__main__':
|
|
34
|
+
pass
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
# from machineconfig.utils.installer import get_latest_release
|
|
3
|
-
#
|
|
3
|
+
#
|
|
4
4
|
# from crocodile.meta import Terminal
|
|
5
5
|
from typing import Optional
|
|
6
6
|
|
|
@@ -38,4 +38,4 @@ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
if __name__ == '__main__':
|
|
41
|
-
|
|
41
|
+
pass
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
"""ngrok
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import platform
|
|
6
|
+
from typing import Optional
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main(version: Optional[str]):
|
|
10
|
+
_ = version
|
|
11
|
+
if platform.system() == "Windows":
|
|
12
|
+
program = "winget install ngrok.ngrok"
|
|
13
|
+
elif platform.system() == "Linux":
|
|
14
|
+
# as per https://ngrok.com/docs/getting-started/?os=linux
|
|
15
|
+
program = """
|
|
16
|
+
|
|
17
|
+
curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | \
|
|
18
|
+
sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && \
|
|
19
|
+
echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | \
|
|
20
|
+
sudo tee /etc/apt/sources.list.d/ngrok.list && \
|
|
21
|
+
sudo apt update && sudo apt install ngrok
|
|
22
|
+
"""
|
|
23
|
+
else:
|
|
24
|
+
raise NotImplementedError("unsupported platform")
|
|
25
|
+
return program
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if __name__ == "__main__":
|
|
29
|
+
pass
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
"""
|
|
3
|
+
Rust version of FZF (GO)
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# from machineconfig.utils.utils import get_latest_release
|
|
7
|
+
#
|
|
8
|
+
from typing import Optional
|
|
9
|
+
|
|
10
|
+
__doc__ = """skim is a fuzzy finder in rust!"""
|
|
11
|
+
repo_url = r"https://github.com/lotabout/skim"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def main(version: Optional[str] = None):
|
|
15
|
+
_ = version
|
|
16
|
+
# release = get_latest_release(repo_url.as_url_str(), suffix='x86_64-unknown-linux-musl', compression='tar.gz', linux=True, strip_v=True, download_n_extract=True)
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
if __name__ == '__main__':
|
|
21
|
+
pass
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
"""wezterm installer
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from machineconfig.utils.installer import get_installers
|
|
6
|
+
from typing import Optional
|
|
7
|
+
import platform
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main(version: Optional[str]):
|
|
11
|
+
if platform.system() == "Windows":
|
|
12
|
+
program = "winget install wez.wezterm"
|
|
13
|
+
elif platform.system() == "Linux":
|
|
14
|
+
insts = get_installers(system=platform.system(), dev=False)
|
|
15
|
+
program = ""
|
|
16
|
+
for inst in insts:
|
|
17
|
+
if "wezterm" in inst.name:
|
|
18
|
+
# as per https://wezfurlong.org/wezterm/install/linux.html#installing-on-ubuntu-and-debian-based-systems
|
|
19
|
+
downloaded, version_to_be_installed = inst.download(version=version)
|
|
20
|
+
_= version_to_be_installed
|
|
21
|
+
|
|
22
|
+
program = f"""
|
|
23
|
+
sudo apt install -y {downloaded}
|
|
24
|
+
rm {downloaded}
|
|
25
|
+
"""
|
|
26
|
+
break
|
|
27
|
+
else:
|
|
28
|
+
raise NotImplementedError("unsupported platform")
|
|
29
|
+
return program
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
if __name__ == "__main__":
|
|
33
|
+
# main(version=None)
|
|
34
|
+
pass
|
machineconfig/profile/create.py
CHANGED
|
@@ -5,8 +5,10 @@ This script Takes away all config files from the computer, place them in one dir
|
|
|
5
5
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
from crocodile.environment import system, UserName # ProgramFiles, WindowsApps # , exe
|
|
10
|
+
from crocodile.meta import Terminal
|
|
11
|
+
from crocodile.file_management import P
|
|
10
12
|
from machineconfig.utils.utils import symlink, LIBRARY_ROOT, REPO_ROOT, display_options
|
|
11
13
|
from machineconfig.profile.shell import create_default_shell_profile
|
|
12
14
|
# import os
|
|
@@ -24,7 +26,7 @@ SYSTEM = system.lower()
|
|
|
24
26
|
# =================== SYMLINKS ====================================
|
|
25
27
|
|
|
26
28
|
|
|
27
|
-
def symlink_contents(source_dir:
|
|
29
|
+
def symlink_contents(source_dir: P, target_dir: P, overwrite: bool = True):
|
|
28
30
|
for a_target in target_dir.expanduser().search("*"):
|
|
29
31
|
symlink(this=source_dir.joinpath(a_target.name), to_this=a_target, prioritize_to_this=overwrite)
|
|
30
32
|
|
|
@@ -58,7 +60,7 @@ def main_symlinks(choice: Optional[str] = None):
|
|
|
58
60
|
else: choice_selected = choice
|
|
59
61
|
|
|
60
62
|
if isinstance(choice_selected, str):
|
|
61
|
-
if str(choice_selected) == "all" and system == "Windows" and not
|
|
63
|
+
if str(choice_selected) == "all" and system == "Windows" and not Terminal.is_user_admin():
|
|
62
64
|
print("*" * 200)
|
|
63
65
|
raise RuntimeError(f"Run terminal as admin and try again, otherwise, there will be too many popups for admin requests and no chance to terminate the program.")
|
|
64
66
|
elif choice_selected == "all":
|
|
@@ -69,8 +71,8 @@ def main_symlinks(choice: Optional[str] = None):
|
|
|
69
71
|
|
|
70
72
|
for program_key in program_keys:
|
|
71
73
|
for file_key, file_map in symlink_mapper[program_key].items():
|
|
72
|
-
this =
|
|
73
|
-
to_this =
|
|
74
|
+
this = P(file_map['this'])
|
|
75
|
+
to_this = P(file_map['to_this'].replace("REPO_ROOT", REPO_ROOT.as_posix()).replace("LIBRARY_ROOT", LIBRARY_ROOT.as_posix()))
|
|
74
76
|
if "contents" in file_map:
|
|
75
77
|
try: symlink_contents(source_dir=this, target_dir=to_this, overwrite=overwrite)
|
|
76
78
|
except Exception as ex: print("Config error: ", program_key, file_key, "missing keys 'this ==> to_this'.", ex)
|
|
@@ -87,7 +89,7 @@ def main_symlinks(choice: Optional[str] = None):
|
|
|
87
89
|
ERROR_LIST.append(e)
|
|
88
90
|
print("Caught error", e)
|
|
89
91
|
|
|
90
|
-
if system == "Linux":
|
|
92
|
+
if system == "Linux": Terminal().run(f'chmod +x {LIBRARY_ROOT.joinpath(f"scripts/{system.lower()}")} -R')
|
|
91
93
|
|
|
92
94
|
|
|
93
95
|
def main(choice: Optional[str] = None):
|
machineconfig/profile/shell.py
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
from crocodile.environment import PathVar
|
|
6
|
-
|
|
6
|
+
from crocodile.core import randstr
|
|
7
|
+
from crocodile.file_management import P
|
|
8
|
+
from crocodile.meta import Terminal
|
|
7
9
|
from machineconfig.utils.utils import LIBRARY_ROOT, REPO_ROOT, display_options
|
|
8
10
|
import platform
|
|
9
11
|
from typing import Optional
|
|
@@ -27,7 +29,7 @@ def create_default_shell_profile():
|
|
|
27
29
|
else:
|
|
28
30
|
profile += "\n" + source + "\n"
|
|
29
31
|
if system == "Linux":
|
|
30
|
-
res =
|
|
32
|
+
res = Terminal().run("cat /proc/version").op
|
|
31
33
|
if "microsoft" in res.lower() or "wsl" in res.lower():
|
|
32
34
|
profile += "\ncd ~" # this is to make sure that the current dir is not in the windows file system, which is terribly slow and its a bad idea to be there anyway.
|
|
33
35
|
profile_path.create(parents_only=True).write_text(profile)
|
|
@@ -35,10 +37,10 @@ def create_default_shell_profile():
|
|
|
35
37
|
|
|
36
38
|
def get_shell_profile_path():
|
|
37
39
|
if system == "Windows":
|
|
38
|
-
res =
|
|
39
|
-
if isinstance(res,
|
|
40
|
+
res = Terminal().run("$profile", shell="pwsh").op2path()
|
|
41
|
+
if isinstance(res, P): profile_path = res
|
|
40
42
|
else: raise ValueError(f"Could not get profile path for Windows. Got {res}")
|
|
41
|
-
elif system == "Linux": profile_path =
|
|
43
|
+
elif system == "Linux": profile_path = P("~/.bashrc").expanduser()
|
|
42
44
|
else: raise ValueError(f"Not implemented for this system {system}")
|
|
43
45
|
print(f"Working on shell profile `{profile_path}`")
|
|
44
46
|
return profile_path
|
|
@@ -49,7 +51,7 @@ def main_env_path(choice: Optional[str] = None, profile_path: Optional[str] = No
|
|
|
49
51
|
dirs = env_path[f'path_{system.lower()}']['extension']
|
|
50
52
|
|
|
51
53
|
print(f"Current PATH: ", "\n============")
|
|
52
|
-
|
|
54
|
+
P.get_env().PATH.print()
|
|
53
55
|
|
|
54
56
|
if choice is None:
|
|
55
57
|
tmp = display_options(msg="Which directory to add?", options=dirs + ["all", "none(EXIT)"], default="none(EXIT)")
|
|
@@ -59,8 +61,8 @@ def main_env_path(choice: Optional[str] = None, profile_path: Optional[str] = No
|
|
|
59
61
|
if choice == "none(EXIT)": return
|
|
60
62
|
|
|
61
63
|
addition = PathVar.append_temporarily(dirs=dirs)
|
|
62
|
-
profile_path_obj =
|
|
63
|
-
profile_path_obj.copy(name=profile_path_obj.name + f".orig_" +
|
|
64
|
+
profile_path_obj = P(profile_path) if isinstance(profile_path, str) else get_shell_profile_path()
|
|
65
|
+
profile_path_obj.copy(name=profile_path_obj.name + f".orig_" + randstr())
|
|
64
66
|
profile_path_obj.modify_text(addition, addition, replace_line=False, notfound_append=True)
|
|
65
67
|
|
|
66
68
|
|
|
@@ -78,13 +80,13 @@ def main_add_sources_to_shell_profile(profile_path: Optional[str] = None, choice
|
|
|
78
80
|
elif choice == "none(EXIT)": return
|
|
79
81
|
|
|
80
82
|
if isinstance(profile_path, str):
|
|
81
|
-
profile_path_obj =
|
|
83
|
+
profile_path_obj = P(profile_path)
|
|
82
84
|
else: profile_path_obj = get_shell_profile_path()
|
|
83
85
|
profile = profile_path_obj.read_text()
|
|
84
86
|
|
|
85
87
|
for a_file in sources:
|
|
86
88
|
tmp = a_file.replace("REPO_ROOT", REPO_ROOT.as_posix()).replace("LIBRARY_ROOT", LIBRARY_ROOT.as_posix())
|
|
87
|
-
file =
|
|
89
|
+
file = P(tmp).collapseuser() # this makes the shell profile interuseable across machines.
|
|
88
90
|
file = file.as_posix() if system == "Linux" else str(file)
|
|
89
91
|
if file not in profile:
|
|
90
92
|
if system == "Windows": profile += f"\n. {file}"
|
|
@@ -104,17 +106,17 @@ def main_add_patches_to_shell_profile(profile_path: Optional[str] = None, choice
|
|
|
104
106
|
elif str(choice) == "all": pass # i.e. patches = patches
|
|
105
107
|
else: patches = [choice]
|
|
106
108
|
|
|
107
|
-
profile_path_obj =
|
|
109
|
+
profile_path_obj = P(profile_path) if isinstance(profile_path, str) else get_shell_profile_path()
|
|
108
110
|
profile = profile_path_obj.read_text()
|
|
109
111
|
|
|
110
112
|
for patch_path in patches:
|
|
111
|
-
patch_path_obj =
|
|
113
|
+
patch_path_obj = P(patch_path)
|
|
112
114
|
patch = patch_path_obj.read_text()
|
|
113
115
|
if patch in profile: print(f"Skipping `{patch_path_obj.name}`; patch already in profile")
|
|
114
116
|
else: profile += "\n" + patch
|
|
115
117
|
|
|
116
118
|
if system == "Linux":
|
|
117
|
-
res =
|
|
119
|
+
res = Terminal().run("cat /proc/version").op
|
|
118
120
|
if "microsoft" in res.lower() or "wsl" in res.lower():
|
|
119
121
|
profile += "\ncd ~" # this is to make sure that the current dir is not in the windows file system, which is terribly slow and its a bad idea to be there anyway.
|
|
120
122
|
|