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.

Files changed (155) hide show
  1. machineconfig/__init__.py +8 -5
  2. machineconfig/jobs/python/check_installations.py +173 -163
  3. machineconfig/jobs/python/checkout_version.py +117 -0
  4. machineconfig/jobs/python/create_bootable_media.py +14 -14
  5. machineconfig/jobs/python/create_zellij_template.py +59 -56
  6. machineconfig/jobs/python/python_cargo_build_share.py +50 -45
  7. machineconfig/jobs/python/python_ve_symlink.py +20 -18
  8. machineconfig/jobs/python/tasks.py +4 -0
  9. machineconfig/jobs/script_installer/azure_data_studio.py +22 -0
  10. machineconfig/jobs/script_installer/bypass_paywall.py +23 -0
  11. machineconfig/jobs/script_installer/code.py +34 -0
  12. machineconfig/jobs/script_installer/docker_desktop.py +41 -0
  13. machineconfig/jobs/script_installer/ngrok.py +29 -0
  14. machineconfig/jobs/{python_linux_installers → script_installer}/skim.py +21 -19
  15. machineconfig/jobs/script_installer/wezterm.py +34 -0
  16. machineconfig/profile/create.py +107 -200
  17. machineconfig/profile/shell.py +127 -0
  18. machineconfig/scripts/__init__.py +6 -6
  19. machineconfig/scripts/python/cloud_copy.py +93 -0
  20. machineconfig/scripts/python/cloud_manager.py +38 -0
  21. machineconfig/scripts/python/cloud_mount.py +115 -52
  22. machineconfig/scripts/python/cloud_repo_sync.py +154 -114
  23. machineconfig/scripts/python/cloud_sync.py +261 -79
  24. machineconfig/scripts/python/croshell.py +151 -0
  25. machineconfig/scripts/python/devops.py +119 -87
  26. machineconfig/scripts/python/devops_add_identity.py +27 -23
  27. machineconfig/scripts/python/devops_add_ssh_key.py +70 -55
  28. machineconfig/scripts/python/devops_backup_retrieve.py +52 -46
  29. machineconfig/scripts/python/devops_devapps_install.py +120 -91
  30. machineconfig/scripts/python/devops_update_repos.py +82 -68
  31. machineconfig/scripts/python/dotfile.py +42 -38
  32. machineconfig/scripts/python/fire_jobs.py +351 -98
  33. machineconfig/scripts/python/ftpx.py +82 -0
  34. machineconfig/scripts/python/mount_nfs.py +54 -3
  35. machineconfig/scripts/python/mount_nw_drive.py +31 -0
  36. machineconfig/scripts/python/mount_ssh.py +44 -20
  37. machineconfig/scripts/python/onetimeshare.py +60 -51
  38. machineconfig/scripts/python/pomodoro.py +41 -37
  39. machineconfig/scripts/python/repos.py +195 -128
  40. machineconfig/scripts/python/scheduler.py +52 -0
  41. machineconfig/scripts/python/snapshot.py +21 -21
  42. machineconfig/scripts/python/start_slidev.py +104 -0
  43. machineconfig/scripts/python/start_terminals.py +97 -0
  44. machineconfig/scripts/python/wifi_conn.py +90 -71
  45. machineconfig/scripts/python/{transfer_wsl_win.py → wsl_windows_transfer.py} +47 -39
  46. machineconfig/setup_windows/wt_and_pwsh/set_pwsh_theme.py +44 -48
  47. machineconfig/setup_windows/wt_and_pwsh/set_wt_settings.py +136 -130
  48. machineconfig/utils/installer.py +251 -0
  49. machineconfig/utils/procs.py +114 -64
  50. machineconfig/utils/scheduling.py +188 -0
  51. machineconfig/utils/utils.py +353 -249
  52. machineconfig/utils/ve.py +222 -0
  53. {machineconfig-1.5.dist-info → machineconfig-1.8.dist-info}/METADATA +140 -110
  54. machineconfig-1.8.dist-info/RECORD +70 -0
  55. {machineconfig-1.5.dist-info → machineconfig-1.8.dist-info}/WHEEL +1 -1
  56. machineconfig/jobs/python/python_linux_installers_all.py +0 -73
  57. machineconfig/jobs/python/python_ve_installer.py +0 -73
  58. machineconfig/jobs/python/python_windows_installers_all.py +0 -23
  59. machineconfig/jobs/python_generic_installers/archive/nvim.py +0 -15
  60. machineconfig/jobs/python_generic_installers/archive/strongbox.py +0 -32
  61. machineconfig/jobs/python_generic_installers/archive/vtm.py +0 -25
  62. machineconfig/jobs/python_generic_installers/broot.py +0 -39
  63. machineconfig/jobs/python_generic_installers/browsh.py +0 -25
  64. machineconfig/jobs/python_generic_installers/bw.py +0 -26
  65. machineconfig/jobs/python_generic_installers/chatgpt.py +0 -24
  66. machineconfig/jobs/python_generic_installers/cpufetch.py +0 -23
  67. machineconfig/jobs/python_generic_installers/delta.py +0 -59
  68. machineconfig/jobs/python_generic_installers/dev/__init__.py +0 -0
  69. machineconfig/jobs/python_generic_installers/dev/autogpt.py +0 -28
  70. machineconfig/jobs/python_generic_installers/dev/bw.py +0 -29
  71. machineconfig/jobs/python_generic_installers/dev/evcxr.py +0 -22
  72. machineconfig/jobs/python_generic_installers/dev/kondo.py +0 -21
  73. machineconfig/jobs/python_generic_installers/dev/lvim.py +0 -60
  74. machineconfig/jobs/python_generic_installers/dev/ngrok.py +0 -35
  75. machineconfig/jobs/python_generic_installers/dev/opencommit.py +0 -21
  76. machineconfig/jobs/python_generic_installers/dev/qrcp.py +0 -25
  77. machineconfig/jobs/python_generic_installers/dev/qrscan.py +0 -16
  78. machineconfig/jobs/python_generic_installers/dev/rust-analyzer.py +0 -24
  79. machineconfig/jobs/python_generic_installers/dev/termscp.py +0 -23
  80. machineconfig/jobs/python_generic_installers/dev/tldr.py +0 -25
  81. machineconfig/jobs/python_generic_installers/dev/tokei.py +0 -24
  82. machineconfig/jobs/python_generic_installers/diskonaut.py +0 -26
  83. machineconfig/jobs/python_generic_installers/dua.py +0 -21
  84. machineconfig/jobs/python_generic_installers/evcxr.py +0 -21
  85. machineconfig/jobs/python_generic_installers/gitui.py +0 -23
  86. machineconfig/jobs/python_generic_installers/gopass.py +0 -19
  87. machineconfig/jobs/python_generic_installers/helix.py +0 -45
  88. machineconfig/jobs/python_generic_installers/kondo.py +0 -20
  89. machineconfig/jobs/python_generic_installers/lf.py +0 -25
  90. machineconfig/jobs/python_generic_installers/lvim.py +0 -34
  91. machineconfig/jobs/python_generic_installers/mprocs.py +0 -20
  92. machineconfig/jobs/python_generic_installers/navi.py +0 -20
  93. machineconfig/jobs/python_generic_installers/ots.py +0 -26
  94. machineconfig/jobs/python_generic_installers/ouch.py +0 -25
  95. machineconfig/jobs/python_generic_installers/pomodoro.py +0 -19
  96. machineconfig/jobs/python_generic_installers/procs.py +0 -20
  97. machineconfig/jobs/python_generic_installers/qrcp.py +0 -22
  98. machineconfig/jobs/python_generic_installers/qrscan.py +0 -14
  99. machineconfig/jobs/python_generic_installers/rclone.py +0 -21
  100. machineconfig/jobs/python_generic_installers/rust-analyzer.py +0 -24
  101. machineconfig/jobs/python_generic_installers/tere.py +0 -26
  102. machineconfig/jobs/python_generic_installers/termscp.py +0 -23
  103. machineconfig/jobs/python_generic_installers/tldr.py +0 -24
  104. machineconfig/jobs/python_generic_installers/tokei.py +0 -21
  105. machineconfig/jobs/python_generic_installers/vtm.py +0 -26
  106. machineconfig/jobs/python_generic_installers/watchexec.py +0 -21
  107. machineconfig/jobs/python_linux_installers/archive/__init__.py +0 -0
  108. machineconfig/jobs/python_linux_installers/archive/ranger.py +0 -18
  109. machineconfig/jobs/python_linux_installers/bandwhich.py +0 -11
  110. machineconfig/jobs/python_linux_installers/bottom.py +0 -17
  111. machineconfig/jobs/python_linux_installers/btop.py +0 -17
  112. machineconfig/jobs/python_linux_installers/dev/bandwhich.py +0 -13
  113. machineconfig/jobs/python_linux_installers/dev/bytehound.py +0 -20
  114. machineconfig/jobs/python_linux_installers/dev/nnn.py +0 -21
  115. machineconfig/jobs/python_linux_installers/gotty.py +0 -16
  116. machineconfig/jobs/python_linux_installers/joshuto.py +0 -28
  117. machineconfig/jobs/python_linux_installers/mcfly.py +0 -12
  118. machineconfig/jobs/python_linux_installers/nnn.py +0 -18
  119. machineconfig/jobs/python_linux_installers/topgrade.py +0 -15
  120. machineconfig/jobs/python_linux_installers/viu.py +0 -19
  121. machineconfig/jobs/python_linux_installers/xplr.py +0 -22
  122. machineconfig/jobs/python_linux_installers/zellij.py +0 -31
  123. machineconfig/jobs/python_windows_installers/archive/ntop.py +0 -20
  124. machineconfig/jobs/python_windows_installers/bat.py +0 -16
  125. machineconfig/jobs/python_windows_installers/boxes.py +0 -19
  126. machineconfig/jobs/python_windows_installers/bypass_paywall.py +0 -18
  127. machineconfig/jobs/python_windows_installers/dev/bypass_paywall.py +0 -21
  128. machineconfig/jobs/python_windows_installers/dev/obs_background_removal_plugin.py +0 -20
  129. machineconfig/jobs/python_windows_installers/fd.py +0 -17
  130. machineconfig/jobs/python_windows_installers/fzf.py +0 -19
  131. machineconfig/jobs/python_windows_installers/obs_background_removal_plugin.py +0 -19
  132. machineconfig/jobs/python_windows_installers/rg.py +0 -15
  133. machineconfig/jobs/python_windows_installers/ugrep.py +0 -14
  134. machineconfig/jobs/python_windows_installers/zoomit.py +0 -20
  135. machineconfig/jobs/python_windows_installers/zoxide.py +0 -20
  136. machineconfig/profile/fix_shell_profiles.py +0 -8
  137. machineconfig/scripts/python/archive/__init__.py +0 -0
  138. machineconfig/scripts/python/archive/bu_gdrive_rx.py +0 -41
  139. machineconfig/scripts/python/archive/bu_gdrive_sx.py +0 -40
  140. machineconfig/scripts/python/archive/bu_onedrive_rx.py +0 -59
  141. machineconfig/scripts/python/archive/bu_onedrive_sx.py +0 -45
  142. machineconfig/scripts/python/chatgpt.py +0 -28
  143. machineconfig/scripts/python/choose_ohmybash_theme.py +0 -25
  144. machineconfig/scripts/python/choose_ohmyposh_theme.py +0 -40
  145. machineconfig/scripts/python/cloud_rx.py +0 -42
  146. machineconfig/scripts/python/cloud_sx.py +0 -40
  147. machineconfig/scripts/python/ftprx.py +0 -37
  148. machineconfig/scripts/python/ftpsx.py +0 -36
  149. machineconfig/scripts/python/im2text.py +0 -15
  150. machineconfig/scripts/python/tmate_conn.py +0 -28
  151. machineconfig/scripts/python/tmate_start.py +0 -31
  152. machineconfig/utils/to_exe.py +0 -7
  153. machineconfig-1.5.dist-info/RECORD +0 -147
  154. /machineconfig/jobs/{python_generic_installers/archive → script_installer}/__init__.py +0 -0
  155. {machineconfig-1.5.dist-info → machineconfig-1.8.dist-info}/top_level.txt +0 -0
@@ -1,91 +1,120 @@
1
-
2
-
3
- from platform import system
4
- # import subprocess
5
- import crocodile.toolbox as tb
6
- from machineconfig.utils.utils import LIBRARY_ROOT, display_options
7
-
8
-
9
- if system() == "Windows": from machineconfig.jobs.python.python_windows_installers_all import get_cli_py_installers
10
- elif system() == "Linux": from machineconfig.jobs.python.python_linux_installers_all import get_cli_py_installers
11
- else: raise NotImplementedError(f"System {system()} not supported")
12
-
13
-
14
- def main(program_name=None):
15
- installers = get_cli_py_installers()
16
- default = tb.P("all")
17
- installers.list.insert(0, default)
18
- installers.list.insert(0, tb.P("System Installers"))
19
- installers.list.insert(0, tb.P("Other dev apps"))
20
- options = list(installers.apply(lambda x: x.stem + ((' -- ' + str(x.readit().__doc__)) if x.exists() else '')))
21
- # options.sort() # throws off sync between installers and options
22
-
23
- if program_name is None:
24
- program_names = display_options(msg="", options=options, header="CHOOSE DEV APP", default=str(default), fzf=True, multi=True)
25
- total_program = ""
26
- for program_name in program_names:
27
- total_program += "\n" + get_program(program_name, options, installers)
28
- else:
29
- total_program = get_program(program_name, options, installers)
30
- return total_program
31
-
32
-
33
- def get_program(program_name, options, installers):
34
- if program_name == "all":
35
- if system() == "Linux": from machineconfig.jobs.python.python_linux_installers_all import main
36
- elif system() == "Windows": from machineconfig.jobs.python.python_windows_installers_all import main
37
- else: raise NotImplementedError(f"System {system()} not supported")
38
- main()
39
- # program_linux = f"source {LIBRARY_ROOT}/setup_linux/devapps.sh"
40
- # program_windows = f"{LIBRARY_ROOT}/setup_windows/devapps.ps1"
41
- program = ""
42
- elif program_name == "System Installers":
43
- if system() == "Windows": options_more = parse_apps_installer_windows(LIBRARY_ROOT.joinpath("setup_windows/apps.ps1").read_text())
44
- elif system() == "Linux": options_more = 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 = display_options(msg="", options=sorted(list(options_more.keys())), header="CHOOSE DEV APP", fzf=True, multi=True)
47
- program = ""
48
- for name in program_names:
49
- sub_program = options_more[name]
50
- if sub_program.startswith("#winget"): sub_program = sub_program[1:]
51
- program += "\n" + sub_program
52
- elif program_name == "Other dev apps":
53
- installers = get_cli_py_installers(dev=True)
54
- options = list(installers.apply(lambda x: x.stem + ((' -- ' + str(x.readit().__doc__)) if x.exists() else '')))
55
- program_names = display_options(msg="", options=sorted(options), header="CHOOSE DEV APP", fzf=True, multi=True)
56
- program = ""
57
- for name in program_names:
58
- idx = options.index(name)
59
- try:
60
- sub_program = installers[idx].readit()['main']() # finish the task
61
- except KeyError:
62
- print(f"KeyError: could not find 'main' in {installers[idx]}")
63
- raise KeyError
64
- if sub_program is None: sub_program = "echo 'Finished Installation'" # write an empty program
65
- program += "\n" + sub_program
66
- else:
67
- idx = options.index(program_name)
68
- print(installers[idx])
69
- program = installers[idx].readit()['main']() # finish the task
70
- if program is None: program = "echo 'Finished Installation'" # write an empty program
71
- return program
72
-
73
-
74
- def parse_apps_installer_linux(txt):
75
- txt = txt.split("""yes '' | sed 3q; echo "----------------------------- installing """)
76
- return tb.Struct.from_keys_values_pairs(tb.L(txt).apply(lambda tmp: (tmp.split('----')[0].rstrip().lstrip(), "\n".join(tmp.split("\n")[1:])))[1:])
77
-
78
-
79
- def parse_apps_installer_windows(txt) -> dict:
80
- progs = tb.L(txt.splitlines()).filter(lambda x: x.startswith("winget ") or x.startswith("#winget"))
81
- res = {}
82
- for line in progs:
83
- try: res[line.split('--name ')[1].split(' --Id ')[0].strip('"').strip('"')] = line
84
- except IndexError as e:
85
- print(line)
86
- raise e
87
- return res
88
-
89
-
90
- if __name__ == '__main__':
91
- pass
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
- from platform import system
3
- import crocodile.toolbox as tb
4
- # from machineconfig.utils.utils import write_shell_script
5
-
6
- sep = "\n"
7
-
8
-
9
- def main(verbose=True) -> str:
10
- _ = verbose
11
- repos = tb.P.home().joinpath("dotfiles/config/reposXXX.ini")
12
- if repos.exists():
13
- repos = repos.readit()
14
- repo_package_list = repos.sections()
15
- else:
16
- repos = ["~/code/crocodile", "~/code/machineconfig", ]
17
- repo_package_list = repos
18
- repos_objs = []
19
- for a_package_path in repo_package_list:
20
- try:
21
- repo = tb.install_n_import("git", "gitpython").Repo(str(tb.P(a_package_path).expanduser()), search_parent_directories=True)
22
- repos_objs.append(repo)
23
- except Exception as ex:
24
- print(ex)
25
- if system() == "Linux":
26
- additions = []
27
- for a_repo in repos_objs:
28
- if "machineconfig" in a_repo.working_dir: # special treatment because of executables.
29
- an_addition = f"""
30
- echo ""
31
- echo "{("Pulling " + str(a_repo.working_dir)).center(80, "-")}"
32
- cd "{a_repo.working_dir}"
33
- git reset --hard
34
- git pull origin
35
- chmod +x ~/scripts -R
36
- chmod +x ~/code/machineconfig/src/machineconfig/jobs/linux -R
37
- chmod +x ~/code/machineconfig/src/machineconfig/settings/lf/linux/exe -R
38
- """
39
- additions.append(an_addition)
40
- else:
41
- # if a_repo.is_dirty() and input(f"Repository {a_repo} is not clean, hard-reset it? y/[n]"): a_repo.git.reset('--hard')
42
- additions.append(f"""
43
- echo "{("Pulling " + str(a_repo.working_dir)).center(80, "-")}"
44
- cd "{a_repo.working_dir}"
45
- {sep.join([f'git pull {remote.name} {a_repo.active_branch.name}' for remote in a_repo.remotes])}
46
- """)
47
- program = "\n".join(additions)
48
-
49
- elif system() == "Windows":
50
- program = "\n".join([f"""
51
- echo "{("Pulling " + str(a_repo.working_dir)).center(80, "-")}"
52
- cd "{a_repo.working_dir}"
53
- {sep.join([f'git pull {remote.name} {a_repo.active_branch.name}' for remote in a_repo.remotes])}
54
- """ for a_repo in repos_objs])
55
- else: raise NotImplementedError(f"System {system()} not supported")
56
- # write_shell_script(program, desc="Script to update repos")
57
- # return ""
58
- return program
59
-
60
-
61
- # def get_pulls(remote):
62
- # if len(remote.branches) == 0: return ""
63
- # elif len(remote.branches) == 1: return f'git pull {remote.name} {remote.branches[0].name}'
64
- # else: return f'git pull {remote.name} {remote.active_branch.name}'
65
-
66
-
67
- if __name__ == '__main__':
68
- pass
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
- import argparse
3
- import crocodile.toolbox as tb
4
- from machineconfig.profile.create import symlink
5
- from machineconfig.utils.utils import LIBRARY_ROOT, REPO_ROOT
6
-
7
-
8
- def main():
9
- parser = argparse.ArgumentParser(description='FTP client')
10
-
11
- parser.add_argument("file", help="file/folder path.", default="")
12
- # FLAGS
13
- parser.add_argument("--overwrite", "-o", help="Overwrite.", action="store_true") # default is False
14
- # optional
15
- parser.add_argument("-d", "--dest", help=f"destination folder", default="")
16
-
17
- args = parser.parse_args()
18
- orig_path = tb.P(args.file).expanduser().absolute()
19
- if args.dest == "":
20
- if "Local" in orig_path: junction = orig_path.split(at="Local", sep=-1)[1]
21
- elif "Roaming" in orig_path: junction = orig_path.split(at="Roaming", sep=-1)[1]
22
- elif ".config" in orig_path: junction = orig_path.split(at=".config", sep=-1)[1]
23
- else: junction = orig_path.rel2home()
24
- new_path = REPO_ROOT.joinpath(junction)
25
- else: new_path = tb.P(args.dest).expanduser().absolute().create().joinpath(orig_path.name)
26
-
27
- symlink(this=orig_path, to_this=new_path, prioritize_to_this=args.overwrite)
28
-
29
- print(f"Map completed. To enshrine this mapping, add the following line to the mapper.toml file:")
30
- print(f"nano {LIBRARY_ROOT}/symlinks/mapper.toml")
31
- print(f"""
32
- [{new_path.parent.name}]
33
- {orig_path.trunk} = {{ this = '{orig_path.collapseuser().as_posix()}', to_this = '{new_path.collapseuser().as_posix()}' }}
34
- """)
35
-
36
-
37
- if __name__ == '__main__':
38
- main()
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()