machineconfig 1.5__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 +8 -5
- machineconfig/jobs/python/check_installations.py +173 -163
- machineconfig/jobs/python/checkout_version.py +117 -0
- machineconfig/jobs/python/create_bootable_media.py +14 -14
- machineconfig/jobs/python/create_zellij_template.py +59 -56
- machineconfig/jobs/python/python_cargo_build_share.py +50 -45
- machineconfig/jobs/python/python_ve_symlink.py +20 -18
- machineconfig/jobs/python/tasks.py +4 -0
- machineconfig/jobs/script_installer/azure_data_studio.py +22 -0
- machineconfig/jobs/script_installer/bypass_paywall.py +23 -0
- machineconfig/jobs/script_installer/code.py +34 -0
- machineconfig/jobs/script_installer/docker_desktop.py +41 -0
- machineconfig/jobs/script_installer/ngrok.py +29 -0
- machineconfig/jobs/{python_linux_installers → script_installer}/skim.py +21 -19
- machineconfig/jobs/script_installer/wezterm.py +34 -0
- machineconfig/profile/create.py +107 -200
- machineconfig/profile/shell.py +127 -0
- machineconfig/scripts/__init__.py +6 -6
- machineconfig/scripts/python/cloud_copy.py +93 -0
- machineconfig/scripts/python/cloud_manager.py +38 -0
- machineconfig/scripts/python/cloud_mount.py +115 -52
- machineconfig/scripts/python/cloud_repo_sync.py +154 -114
- machineconfig/scripts/python/cloud_sync.py +261 -79
- machineconfig/scripts/python/croshell.py +151 -0
- machineconfig/scripts/python/devops.py +119 -87
- machineconfig/scripts/python/devops_add_identity.py +27 -23
- machineconfig/scripts/python/devops_add_ssh_key.py +70 -55
- machineconfig/scripts/python/devops_backup_retrieve.py +52 -46
- machineconfig/scripts/python/devops_devapps_install.py +120 -91
- machineconfig/scripts/python/devops_update_repos.py +82 -68
- machineconfig/scripts/python/dotfile.py +42 -38
- machineconfig/scripts/python/fire_jobs.py +351 -98
- machineconfig/scripts/python/ftpx.py +82 -0
- machineconfig/scripts/python/mount_nfs.py +54 -3
- machineconfig/scripts/python/mount_nw_drive.py +31 -0
- machineconfig/scripts/python/mount_ssh.py +44 -20
- machineconfig/scripts/python/onetimeshare.py +60 -51
- machineconfig/scripts/python/pomodoro.py +41 -37
- machineconfig/scripts/python/repos.py +195 -128
- machineconfig/scripts/python/scheduler.py +52 -0
- machineconfig/scripts/python/snapshot.py +21 -21
- machineconfig/scripts/python/start_slidev.py +104 -0
- machineconfig/scripts/python/start_terminals.py +97 -0
- machineconfig/scripts/python/wifi_conn.py +90 -71
- machineconfig/scripts/python/{transfer_wsl_win.py → wsl_windows_transfer.py} +47 -39
- machineconfig/setup_windows/wt_and_pwsh/set_pwsh_theme.py +44 -48
- machineconfig/setup_windows/wt_and_pwsh/set_wt_settings.py +136 -130
- machineconfig/utils/installer.py +251 -0
- machineconfig/utils/procs.py +114 -64
- machineconfig/utils/scheduling.py +188 -0
- machineconfig/utils/utils.py +353 -249
- machineconfig/utils/ve.py +222 -0
- {machineconfig-1.5.dist-info → machineconfig-1.8.dist-info}/METADATA +140 -110
- machineconfig-1.8.dist-info/RECORD +70 -0
- {machineconfig-1.5.dist-info → machineconfig-1.8.dist-info}/WHEEL +1 -1
- machineconfig/jobs/python/python_linux_installers_all.py +0 -73
- machineconfig/jobs/python/python_ve_installer.py +0 -73
- machineconfig/jobs/python/python_windows_installers_all.py +0 -23
- machineconfig/jobs/python_generic_installers/archive/nvim.py +0 -15
- machineconfig/jobs/python_generic_installers/archive/strongbox.py +0 -32
- machineconfig/jobs/python_generic_installers/archive/vtm.py +0 -25
- machineconfig/jobs/python_generic_installers/broot.py +0 -39
- machineconfig/jobs/python_generic_installers/browsh.py +0 -25
- machineconfig/jobs/python_generic_installers/bw.py +0 -26
- machineconfig/jobs/python_generic_installers/chatgpt.py +0 -24
- machineconfig/jobs/python_generic_installers/cpufetch.py +0 -23
- machineconfig/jobs/python_generic_installers/delta.py +0 -59
- machineconfig/jobs/python_generic_installers/dev/__init__.py +0 -0
- machineconfig/jobs/python_generic_installers/dev/autogpt.py +0 -28
- machineconfig/jobs/python_generic_installers/dev/bw.py +0 -29
- machineconfig/jobs/python_generic_installers/dev/evcxr.py +0 -22
- machineconfig/jobs/python_generic_installers/dev/kondo.py +0 -21
- machineconfig/jobs/python_generic_installers/dev/lvim.py +0 -60
- machineconfig/jobs/python_generic_installers/dev/ngrok.py +0 -35
- machineconfig/jobs/python_generic_installers/dev/opencommit.py +0 -21
- machineconfig/jobs/python_generic_installers/dev/qrcp.py +0 -25
- machineconfig/jobs/python_generic_installers/dev/qrscan.py +0 -16
- machineconfig/jobs/python_generic_installers/dev/rust-analyzer.py +0 -24
- machineconfig/jobs/python_generic_installers/dev/termscp.py +0 -23
- machineconfig/jobs/python_generic_installers/dev/tldr.py +0 -25
- machineconfig/jobs/python_generic_installers/dev/tokei.py +0 -24
- machineconfig/jobs/python_generic_installers/diskonaut.py +0 -26
- machineconfig/jobs/python_generic_installers/dua.py +0 -21
- machineconfig/jobs/python_generic_installers/evcxr.py +0 -21
- machineconfig/jobs/python_generic_installers/gitui.py +0 -23
- machineconfig/jobs/python_generic_installers/gopass.py +0 -19
- machineconfig/jobs/python_generic_installers/helix.py +0 -45
- machineconfig/jobs/python_generic_installers/kondo.py +0 -20
- machineconfig/jobs/python_generic_installers/lf.py +0 -25
- machineconfig/jobs/python_generic_installers/lvim.py +0 -34
- machineconfig/jobs/python_generic_installers/mprocs.py +0 -20
- machineconfig/jobs/python_generic_installers/navi.py +0 -20
- machineconfig/jobs/python_generic_installers/ots.py +0 -26
- machineconfig/jobs/python_generic_installers/ouch.py +0 -25
- machineconfig/jobs/python_generic_installers/pomodoro.py +0 -19
- machineconfig/jobs/python_generic_installers/procs.py +0 -20
- machineconfig/jobs/python_generic_installers/qrcp.py +0 -22
- machineconfig/jobs/python_generic_installers/qrscan.py +0 -14
- machineconfig/jobs/python_generic_installers/rclone.py +0 -21
- machineconfig/jobs/python_generic_installers/rust-analyzer.py +0 -24
- machineconfig/jobs/python_generic_installers/tere.py +0 -26
- machineconfig/jobs/python_generic_installers/termscp.py +0 -23
- machineconfig/jobs/python_generic_installers/tldr.py +0 -24
- machineconfig/jobs/python_generic_installers/tokei.py +0 -21
- machineconfig/jobs/python_generic_installers/vtm.py +0 -26
- machineconfig/jobs/python_generic_installers/watchexec.py +0 -21
- machineconfig/jobs/python_linux_installers/archive/__init__.py +0 -0
- machineconfig/jobs/python_linux_installers/archive/ranger.py +0 -18
- machineconfig/jobs/python_linux_installers/bandwhich.py +0 -11
- machineconfig/jobs/python_linux_installers/bottom.py +0 -17
- machineconfig/jobs/python_linux_installers/btop.py +0 -17
- machineconfig/jobs/python_linux_installers/dev/bandwhich.py +0 -13
- machineconfig/jobs/python_linux_installers/dev/bytehound.py +0 -20
- machineconfig/jobs/python_linux_installers/dev/nnn.py +0 -21
- machineconfig/jobs/python_linux_installers/gotty.py +0 -16
- machineconfig/jobs/python_linux_installers/joshuto.py +0 -28
- machineconfig/jobs/python_linux_installers/mcfly.py +0 -12
- machineconfig/jobs/python_linux_installers/nnn.py +0 -18
- machineconfig/jobs/python_linux_installers/topgrade.py +0 -15
- machineconfig/jobs/python_linux_installers/viu.py +0 -19
- machineconfig/jobs/python_linux_installers/xplr.py +0 -22
- machineconfig/jobs/python_linux_installers/zellij.py +0 -31
- machineconfig/jobs/python_windows_installers/archive/ntop.py +0 -20
- machineconfig/jobs/python_windows_installers/bat.py +0 -16
- machineconfig/jobs/python_windows_installers/boxes.py +0 -19
- machineconfig/jobs/python_windows_installers/bypass_paywall.py +0 -18
- machineconfig/jobs/python_windows_installers/dev/bypass_paywall.py +0 -21
- machineconfig/jobs/python_windows_installers/dev/obs_background_removal_plugin.py +0 -20
- machineconfig/jobs/python_windows_installers/fd.py +0 -17
- machineconfig/jobs/python_windows_installers/fzf.py +0 -19
- machineconfig/jobs/python_windows_installers/obs_background_removal_plugin.py +0 -19
- machineconfig/jobs/python_windows_installers/rg.py +0 -15
- machineconfig/jobs/python_windows_installers/ugrep.py +0 -14
- machineconfig/jobs/python_windows_installers/zoomit.py +0 -20
- machineconfig/jobs/python_windows_installers/zoxide.py +0 -20
- machineconfig/profile/fix_shell_profiles.py +0 -8
- machineconfig/scripts/python/archive/__init__.py +0 -0
- machineconfig/scripts/python/archive/bu_gdrive_rx.py +0 -41
- machineconfig/scripts/python/archive/bu_gdrive_sx.py +0 -40
- machineconfig/scripts/python/archive/bu_onedrive_rx.py +0 -59
- machineconfig/scripts/python/archive/bu_onedrive_sx.py +0 -45
- machineconfig/scripts/python/chatgpt.py +0 -28
- machineconfig/scripts/python/choose_ohmybash_theme.py +0 -25
- machineconfig/scripts/python/choose_ohmyposh_theme.py +0 -40
- machineconfig/scripts/python/cloud_rx.py +0 -42
- machineconfig/scripts/python/cloud_sx.py +0 -40
- machineconfig/scripts/python/ftprx.py +0 -37
- machineconfig/scripts/python/ftpsx.py +0 -36
- machineconfig/scripts/python/im2text.py +0 -15
- machineconfig/scripts/python/tmate_conn.py +0 -28
- machineconfig/scripts/python/tmate_start.py +0 -31
- machineconfig/utils/to_exe.py +0 -7
- machineconfig-1.5.dist-info/RECORD +0 -147
- /machineconfig/jobs/{python_generic_installers/archive → script_installer}/__init__.py +0 -0
- {machineconfig-1.5.dist-info → machineconfig-1.8.dist-info}/top_level.txt +0 -0
|
@@ -1,91 +1,120 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
installers
|
|
19
|
-
|
|
20
|
-
options =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
program = ""
|
|
42
|
-
elif program_name == "
|
|
43
|
-
if system() == "Windows":
|
|
44
|
-
elif system() == "Linux":
|
|
45
|
-
else: raise NotImplementedError(f"System {system()} not supported")
|
|
46
|
-
program_names =
|
|
47
|
-
program = ""
|
|
48
|
-
for name in program_names:
|
|
49
|
-
sub_program =
|
|
50
|
-
if sub_program.startswith("#winget"): sub_program = sub_program[1:]
|
|
51
|
-
program += "\n" + sub_program
|
|
52
|
-
elif program_name == "
|
|
53
|
-
installers =
|
|
54
|
-
|
|
55
|
-
program_names =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
try:
|
|
60
|
-
|
|
61
|
-
except
|
|
62
|
-
print(f"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def
|
|
80
|
-
|
|
81
|
-
res = {}
|
|
82
|
-
for
|
|
83
|
-
try:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
1
|
+
|
|
2
|
+
"""Devops Devapps Install
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
# import subprocess
|
|
6
|
+
from crocodile.core import List as L
|
|
7
|
+
from machineconfig.utils.utils import LIBRARY_ROOT, choose_multiple_options
|
|
8
|
+
from machineconfig.utils.installer import get_installers, Installer, install_all
|
|
9
|
+
from platform import system
|
|
10
|
+
from typing import Any, Optional, Literal, TypeAlias
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
WHICH: TypeAlias = Literal["AllEssentials", "EssentialsAndOthers", "SystemInstallers", "OtherDevApps", "PrecheckedCloudInstaller"]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main(which: Optional[str] = None):
|
|
17
|
+
sys = system()
|
|
18
|
+
installers = get_installers(dev=False, system=sys) + get_installers(dev=True, system=sys)
|
|
19
|
+
default = "AllEssentials"
|
|
20
|
+
options = ["SystemInstallers", "OtherDevApps", "EssentialsAndOthers", "PrecheckedCloudInstaller"]
|
|
21
|
+
options = [default] + options
|
|
22
|
+
options = [x.get_description() for x in installers] + options
|
|
23
|
+
|
|
24
|
+
if which is not None:
|
|
25
|
+
return get_program(program_name=which, options=options, installers=list(installers))
|
|
26
|
+
|
|
27
|
+
program_names = choose_multiple_options(msg="", options=options, header="CHOOSE DEV APP", default=str(default))
|
|
28
|
+
total_program = ""
|
|
29
|
+
for which in program_names:
|
|
30
|
+
assert isinstance(which, str), f"program_name is not a string: {which}"
|
|
31
|
+
total_program += "\n" + get_program(program_name=which, options=options, installers=list(installers))
|
|
32
|
+
return total_program
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_program(program_name: str, options: list[str], installers: list[Installer]):
|
|
36
|
+
if program_name == "AllEssentials" or program_name == "EssentialsAndOthers":
|
|
37
|
+
installers_ = get_installers(dev=False, system=system())
|
|
38
|
+
if program_name == "EssentialsAndOthers":
|
|
39
|
+
installers_ += get_installers(dev=True, system=system())
|
|
40
|
+
install_all(installers=L(installers))
|
|
41
|
+
program = ""
|
|
42
|
+
elif program_name == "SystemInstallers":
|
|
43
|
+
if system() == "Windows": options_system = parse_apps_installer_windows(LIBRARY_ROOT.joinpath("setup_windows/apps.ps1").read_text())
|
|
44
|
+
elif system() == "Linux": options_system = parse_apps_installer_linux(LIBRARY_ROOT.joinpath("setup_linux/apps.sh").read_text())
|
|
45
|
+
else: raise NotImplementedError(f"System {system()} not supported")
|
|
46
|
+
program_names = choose_multiple_options(msg="", options=sorted(list(options_system.keys())), header="CHOOSE DEV APP")
|
|
47
|
+
program = ""
|
|
48
|
+
for name in program_names:
|
|
49
|
+
sub_program = options_system[name]
|
|
50
|
+
if sub_program.startswith("#winget"): sub_program = sub_program[1:]
|
|
51
|
+
program += "\n" + sub_program
|
|
52
|
+
elif program_name == "OtherDevApps":
|
|
53
|
+
installers = get_installers(dev=True, system=system())
|
|
54
|
+
options__: list[str] = [x.get_description() for x in installers]
|
|
55
|
+
program_names = choose_multiple_options(msg="", options=sorted(options__) + ["all"], header="CHOOSE DEV APP")
|
|
56
|
+
if "all" in program_names: program_names = options__
|
|
57
|
+
program = ""
|
|
58
|
+
for name in program_names:
|
|
59
|
+
try:
|
|
60
|
+
idx = options__.index(name)
|
|
61
|
+
except ValueError as ve:
|
|
62
|
+
print(f"{name=}")
|
|
63
|
+
print(f"{options__=}")
|
|
64
|
+
raise ve
|
|
65
|
+
sub_program = installers[idx].install_robust(version=None) # finish the task
|
|
66
|
+
elif program_name == "PrecheckedCloudInstaller":
|
|
67
|
+
from machineconfig.jobs.python.check_installations import PrecheckedCloudInstaller
|
|
68
|
+
ci = PrecheckedCloudInstaller()
|
|
69
|
+
ci.download_safe_apps(name="AllEssentials")
|
|
70
|
+
program = ""
|
|
71
|
+
else:
|
|
72
|
+
idx = options.index(program_name)
|
|
73
|
+
print(installers[idx])
|
|
74
|
+
program = installers[idx].install_robust(version=None) # finish the task
|
|
75
|
+
program = "echo 'Finished Installation'" # write an empty program
|
|
76
|
+
return program
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def parse_apps_installer_linux(txt: str) -> dict[str, Any]:
|
|
80
|
+
txts = txt.split("""yes '' | sed 3q; echo "----------------------------- installing """)
|
|
81
|
+
res = {}
|
|
82
|
+
for chunk in txts[1:]:
|
|
83
|
+
try:
|
|
84
|
+
k = chunk.split('----')[0].rstrip().lstrip()
|
|
85
|
+
v = "\n".join(chunk.split("\n")[1:])
|
|
86
|
+
res[k] = v
|
|
87
|
+
except IndexError as e:
|
|
88
|
+
print(chunk)
|
|
89
|
+
raise e
|
|
90
|
+
return res
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def parse_apps_installer_windows(txt: str) -> dict[str, Any]:
|
|
94
|
+
chunks: list[str] = []
|
|
95
|
+
for idx, item in enumerate(txt.split(sep="winget install")):
|
|
96
|
+
if idx == 0: continue
|
|
97
|
+
if idx == 1: chunks.append(item)
|
|
98
|
+
else: chunks.append("winget install" + item)
|
|
99
|
+
# progs = L(txt.splitlines()).filter(lambda x: x.startswith("winget ") or x.startswith("#winget"))
|
|
100
|
+
res: dict[str, str] = {}
|
|
101
|
+
for a_chunk in chunks:
|
|
102
|
+
try:
|
|
103
|
+
name = a_chunk.split('--name ')[1]
|
|
104
|
+
if "--Id" not in name:
|
|
105
|
+
print(f"Warning: {name} does not have an Id, skipping")
|
|
106
|
+
continue
|
|
107
|
+
name = name.split(' --Id ', maxsplit=1)[0].strip('"').strip('"')
|
|
108
|
+
res[name] = a_chunk
|
|
109
|
+
except IndexError as e:
|
|
110
|
+
print(a_chunk)
|
|
111
|
+
raise e
|
|
112
|
+
# Struct(res).print(as_config=True)
|
|
113
|
+
# L(chunks).print(sep="-----------------------------------------------------------------------\n\n")
|
|
114
|
+
# import time
|
|
115
|
+
# time.sleep(10)
|
|
116
|
+
return res
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
if __name__ == '__main__':
|
|
120
|
+
pass
|
|
@@ -1,68 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
git
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
""
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
1
|
+
|
|
2
|
+
"""Update
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from crocodile.file_management import P, Read
|
|
6
|
+
from crocodile.core import install_n_import
|
|
7
|
+
from machineconfig.utils.utils import DEFAULTS_PATH
|
|
8
|
+
from platform import system
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
sep = "\n"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def main(verbose: bool = True) -> str:
|
|
15
|
+
_ = verbose
|
|
16
|
+
repos: list[str] = ["~/code/crocodile", "~/code/machineconfig", ]
|
|
17
|
+
try:
|
|
18
|
+
tmp = Read.ini(DEFAULTS_PATH)['general']['repos'].split(",")
|
|
19
|
+
if tmp[-1] == "": tmp = tmp[:-1]
|
|
20
|
+
repos += tmp
|
|
21
|
+
except (FileNotFoundError, KeyError, IndexError):
|
|
22
|
+
print(f"Missing {DEFAULTS_PATH} or section [general] or key repos. Using default repos.")
|
|
23
|
+
print(f"""It should look like this:
|
|
24
|
+
[general]
|
|
25
|
+
repos = ~/code/repo1,~/code/repo2
|
|
26
|
+
rclone_config_name = onedriveWork
|
|
27
|
+
email_config_name = Yahoo3
|
|
28
|
+
to_email = myemail@email.com
|
|
29
|
+
""")
|
|
30
|
+
|
|
31
|
+
repos_objs = []
|
|
32
|
+
for a_package_path in repos:
|
|
33
|
+
try:
|
|
34
|
+
repo = install_n_import("git", "gitpython").Repo(str(P(a_package_path).expanduser()), search_parent_directories=True)
|
|
35
|
+
repos_objs.append(repo)
|
|
36
|
+
except Exception as ex:
|
|
37
|
+
print(ex)
|
|
38
|
+
|
|
39
|
+
if system() == "Linux":
|
|
40
|
+
additions = []
|
|
41
|
+
for a_repo in repos_objs:
|
|
42
|
+
if "machineconfig" in a_repo.working_dir: # special treatment because of executables.
|
|
43
|
+
an_addition = f"""
|
|
44
|
+
echo ""
|
|
45
|
+
echo "{("Pulling " + str(a_repo.working_dir)).center(80, "-")}"
|
|
46
|
+
cd "{a_repo.working_dir}"
|
|
47
|
+
# git reset --hard
|
|
48
|
+
git pull origin
|
|
49
|
+
chmod +x ~/scripts -R
|
|
50
|
+
chmod +x ~/code/machineconfig/src/machineconfig/jobs/linux -R
|
|
51
|
+
chmod +x ~/code/machineconfig/src/machineconfig/settings/lf/linux/exe -R
|
|
52
|
+
"""
|
|
53
|
+
additions.append(an_addition)
|
|
54
|
+
else:
|
|
55
|
+
# if a_repo.is_dirty() and input(f"Repository {a_repo} is not clean, hard-reset it? y/[n]"): a_repo.git.reset('--hard')
|
|
56
|
+
additions.append(f"""
|
|
57
|
+
echo "{("Pulling " + str(a_repo.working_dir)).center(80, "-")}"
|
|
58
|
+
cd "{a_repo.working_dir}"
|
|
59
|
+
{sep.join([f'git pull {remote.name} {a_repo.active_branch.name}' for remote in a_repo.remotes])}
|
|
60
|
+
""")
|
|
61
|
+
program = "\n".join(additions)
|
|
62
|
+
|
|
63
|
+
elif system() == "Windows":
|
|
64
|
+
program = "\n".join([f"""
|
|
65
|
+
echo "{("Pulling " + str(a_repo.working_dir)).center(80, "-")}"
|
|
66
|
+
cd "{a_repo.working_dir}"
|
|
67
|
+
{sep.join([f'git pull {remote.name} {a_repo.active_branch.name}' for remote in a_repo.remotes])}
|
|
68
|
+
""" for a_repo in repos_objs])
|
|
69
|
+
else: raise NotImplementedError(f"System {system()} not supported")
|
|
70
|
+
# write_shell_script(program, desc="Script to update repos")
|
|
71
|
+
# return ""
|
|
72
|
+
return program
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# def get_pulls(remote):
|
|
76
|
+
# if len(remote.branches) == 0: return ""
|
|
77
|
+
# elif len(remote.branches) == 1: return f'git pull {remote.name} {remote.branches[0].name}'
|
|
78
|
+
# else: return f'git pull {remote.name} {remote.active_branch.name}'
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
if __name__ == '__main__':
|
|
82
|
+
pass
|
|
@@ -1,38 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
parser.
|
|
14
|
-
|
|
15
|
-
parser.add_argument("
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
""
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
|
|
2
|
+
"""Like yadm and dotter.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from crocodile.file_management import P
|
|
7
|
+
from machineconfig.profile.create import symlink
|
|
8
|
+
from machineconfig.utils.utils import LIBRARY_ROOT, REPO_ROOT
|
|
9
|
+
import argparse
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main():
|
|
13
|
+
parser = argparse.ArgumentParser(description='FTP client')
|
|
14
|
+
|
|
15
|
+
parser.add_argument("file", help="file/folder path.", default="")
|
|
16
|
+
# FLAGS
|
|
17
|
+
parser.add_argument("--overwrite", "-o", help="Overwrite.", action="store_true") # default is False
|
|
18
|
+
# optional
|
|
19
|
+
parser.add_argument("-d", "--dest", help=f"destination folder", default="")
|
|
20
|
+
|
|
21
|
+
args = parser.parse_args()
|
|
22
|
+
orig_path = P(args.file).expanduser().absolute()
|
|
23
|
+
if args.dest == "":
|
|
24
|
+
if "Local" in orig_path: junction = orig_path.split(at="Local", sep=-1)[1]
|
|
25
|
+
elif "Roaming" in orig_path: junction = orig_path.split(at="Roaming", sep=-1)[1]
|
|
26
|
+
elif ".config" in orig_path: junction = orig_path.split(at=".config", sep=-1)[1]
|
|
27
|
+
else: junction = orig_path.rel2home()
|
|
28
|
+
new_path = REPO_ROOT.joinpath(junction)
|
|
29
|
+
else: new_path = P(args.dest).expanduser().absolute().create().joinpath(orig_path.name)
|
|
30
|
+
|
|
31
|
+
symlink(this=orig_path, to_this=new_path, prioritize_to_this=args.overwrite)
|
|
32
|
+
|
|
33
|
+
print(f"Map completed. To enshrine this mapping, add the following line to the mapper.toml file:")
|
|
34
|
+
print(f"nano {LIBRARY_ROOT}/symlinks/mapper.toml")
|
|
35
|
+
print(f"""
|
|
36
|
+
[{new_path.parent.name}]
|
|
37
|
+
{orig_path.trunk} = {{ this = '{orig_path.collapseuser().as_posix()}', to_this = '{new_path.collapseuser().as_posix()}' }}
|
|
38
|
+
""")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
if __name__ == '__main__':
|
|
42
|
+
main()
|