machineconfig 1.91__py3-none-any.whl → 1.92__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 CHANGED
@@ -2,9 +2,7 @@
2
2
  """DS
3
3
  """
4
4
 
5
- __version__ = "1.91"
5
+ __version__ = "1.92"
6
6
  release_notes = """
7
-
8
- imporoved installer
9
-
7
+ included settings
10
8
  """
@@ -15,10 +15,11 @@ from crocodile.file_management import P
15
15
  from crocodile.meta import Terminal
16
16
  from tqdm import tqdm
17
17
  from typing import Optional
18
+ from datetime import datetime
18
19
 
19
20
 
20
21
  APP_SUMMARY_PATH = LIBRARY_ROOT.joinpath(f"profile/records/{platform.system().lower()}/apps_summary_report.csv")
21
- CLOUD: str="gdw" # Read.ini(DEFAULTS_PATH)['general']['rclone_config_name']
22
+ CLOUD: str = "gdw" # Read.ini(DEFAULTS_PATH)['general']['rclone_config_name']
22
23
  # my onedrive doesn't allow sharing.
23
24
 
24
25
 
@@ -81,6 +82,7 @@ def main() -> None:
81
82
  print(f"Checking tools collected from `{INSTALL_VERSION_ROOT}`:")
82
83
  apps_paths_raw.print()
83
84
  positive_pct: list[Optional[float]] = []
85
+ scan_time: list[str] = []
84
86
  detailed_results: list[dict[str, Optional[pd.DataFrame]]] = []
85
87
 
86
88
  for idx, app in enumerate(apps_paths_raw):
@@ -95,9 +97,13 @@ def main() -> None:
95
97
  ppct, df = res
96
98
  positive_pct.append(ppct)
97
99
  detailed_results.append({app.stem: df})
100
+ scan_time.append(datetime.now().strftime("%Y-%m-%d %H:%M"))
98
101
 
99
- res_df = pd.DataFrame({"app_name": apps_paths_raw.apply(lambda x: x.stem).list, "version": app_versions, "positive_pct": positive_pct,
100
- "app_path": apps_paths_raw.apply(lambda x: x.collapseuser(strict=False).as_posix()).list})
102
+ res_df = pd.DataFrame({"app_name": apps_paths_raw.apply(lambda x: x.stem).list,
103
+ "version": app_versions,
104
+ "positive_pct": positive_pct,
105
+ "scan_time": scan_time,
106
+ "app_path": apps_paths_raw.apply(lambda x: x.collapseuser(strict=False).as_posix()).list})
101
107
 
102
108
  app_url: list[Optional[str]] = []
103
109
  for idx, row in tqdm(res_df.iterrows(), total=res_df.shape[0]):
@@ -24,7 +24,10 @@ def main(version: Optional[str]):
24
24
  config_dict_copy["repo_url"] = "https://github.com/helix-editor/helix"
25
25
  inst = Installer.from_dict(d=config_dict_copy, name="hx")
26
26
  downloaded, _version_to_be_installed = inst.download(version=version)
27
- hx_file_search = downloaded.search("hx", folders=False, files=True, r=True)
27
+ if platform.system() == "Windows":
28
+ hx_file_search = downloaded.search("hx.exe", folders=False, files=True, r=True)
29
+ else:
30
+ hx_file_search = downloaded.search("hx", folders=False, files=True, r=True)
28
31
  assert len(hx_file_search) == 1
29
32
  hx_file = hx_file_search.list[0]
30
33
  contrib = hx_file.parent / "contrib"
@@ -37,9 +37,12 @@ def create_default_shell_profile():
37
37
 
38
38
  def get_shell_profile_path():
39
39
  if system == "Windows":
40
- res = Terminal().run("$profile", shell="pwsh").op2path()
40
+ obj = Terminal().run("$PROFILE", shell="pwsh")
41
+ res = obj.op2path()
41
42
  if isinstance(res, P): profile_path = res
42
- else: raise ValueError(f"Could not get profile path for Windows. Got {res}")
43
+ else:
44
+ obj.print(capture=False)
45
+ raise ValueError(f"Could not get profile path for Windows. Got {res}")
43
46
  elif system == "Linux": profile_path = P("~/.bashrc").expanduser()
44
47
  else: raise ValueError(f"Not implemented for this system {system}")
45
48
  print(f"Working on shell profile `{profile_path}`")
@@ -133,8 +133,8 @@ func(remote_repo=r'{repo_remote_root.to_str()}', local_repo=r'{repo_local_root.t
133
133
  program_2 = f"""
134
134
  rm -rfd {repo_local_root}
135
135
  mv {repo_remote_root} {repo_local_root}
136
- sudo chmod 600 ~/.ssh/*
137
- sudo chmod 700 ~/.ssh
136
+ sudo chmod 600 $HOME/.ssh/*
137
+ sudo chmod 700 $HOME/.ssh
138
138
  """
139
139
 
140
140
  shell_file_2 = get_shell_script(shell_script=program_2)
@@ -149,9 +149,12 @@ func(repo_local_root=r'{repo_local_root.to_str()}', repo_remote_root=r'{repo_rem
149
149
  # ================================================================================
150
150
 
151
151
  option4 = 'Remove problematic rclone file from repo and replace with remote:'
152
- program_4 = """
153
- rm ~/dotfiles/creds/rclone/rclone.conf
154
- cp ~/.config/machineconfig/remote/dotfiles/creds/rclone/rclone.conf ~/dotfiles/creds/rclone
152
+ program_4 = f"""
153
+ rm $HOME/dotfiles/creds/rclone/rclone.conf
154
+ cp $HOME/.config/machineconfig/remote/dotfiles/creds/rclone/rclone.conf $HOME/dotfiles/creds/rclone
155
+ cd $HOME/dotfiles
156
+ git commit -am "finished merging"
157
+ . {shell_file_1}
155
158
  """
156
159
  shell_file_4 = get_shell_script(shell_script=program_4)
157
160
  # ================================================================================
@@ -163,7 +166,7 @@ cp ~/.config/machineconfig/remote/dotfiles/creds/rclone/rclone.conf ~/dotfiles/c
163
166
 
164
167
  match action:
165
168
  case "ask":
166
- choice = choose_one_option(options=[option1, option2, option3, option4])
169
+ choice = choose_one_option(options=[option1, option2, option3, option4], fzf=False)
167
170
  if choice == option1: PROGRAM_PATH.write_text(shell_file_1.read_text())
168
171
  elif choice == option2: PROGRAM_PATH.write_text(program_2)
169
172
  elif choice == option3: PROGRAM_PATH.write_text(shell_file_3.read_text())
@@ -193,15 +196,14 @@ def delete_remote_repo_copy_and_push_local(remote_repo: str, local_repo: str, cl
193
196
  def inspect_repos(repo_local_root: str, repo_remote_root: str):
194
197
  if platform.system() == "Windows":
195
198
  program = get_wt_cmd(wd1=P(repo_local_root), wd2=P(repo_local_root))
196
- write_shell_script(program=program, execute=True)
199
+ write_shell_script(program=program, execute=True, desc="Inspecting repos ...", preserve_cwd=True, display=True)
197
200
  return None
198
201
  elif platform.system() == "Linux":
199
202
  program = get_zellij_cmd(wd1=P(repo_local_root), wd2=P(repo_remote_root))
200
- write_shell_script(program=program, execute=True)
203
+ write_shell_script(program=program, execute=True, desc="Inspecting repos ...", preserve_cwd=True, display=True)
201
204
  return None
202
205
  else: raise NotImplementedError(f"Platform {platform.system()} not implemented.")
203
206
 
204
207
 
205
-
206
208
  if __name__ == "__main__":
207
209
  args_parser()
@@ -44,10 +44,10 @@ class Args():
44
44
  share: bool=ArgsDefaults.share
45
45
 
46
46
  root: Optional[str] = ArgsDefaults.root
47
- os_specific: bool=ArgsDefaults.os_specific
48
- rel2home: bool=ArgsDefaults.rel2home
47
+ os_specific: bool = ArgsDefaults.os_specific
48
+ rel2home: bool = ArgsDefaults.rel2home
49
49
 
50
- encrypt: bool=ArgsDefaults.encrypt
50
+ encrypt: bool = ArgsDefaults.encrypt
51
51
  key: Optional[str] = ArgsDefaults.key
52
52
  pwd: Optional[str] = ArgsDefaults.pwd
53
53
 
@@ -114,6 +114,22 @@ def find_cloud_config(path: P):
114
114
 
115
115
  def parse_cloud_source_target(args: Args, source: str, target: str) -> tuple[str, str, str]:
116
116
  config = args.config
117
+ if config == "ss":
118
+ maybe_config = get_secure_share_cloud_config()
119
+ elif config is not None:
120
+ maybe_config = Args.from_config(absolute(config))
121
+ else:
122
+ maybe_config = None
123
+
124
+ if maybe_config is not None:
125
+ if args.zip == ArgsDefaults.zip_: args.zip = maybe_config.zip
126
+ if args.encrypt == ArgsDefaults.encrypt: args.encrypt = maybe_config.encrypt
127
+ if args.share == ArgsDefaults.share: args.share = maybe_config.share
128
+ if args.root == ArgsDefaults.root: args.root = maybe_config.root
129
+ if args.rel2home == ArgsDefaults.rel2home: args.rel2home = maybe_config.rel2home
130
+ if args.pwd == ArgsDefaults.pwd: args.pwd = maybe_config.pwd
131
+ if args.os_specific == ArgsDefaults.os_specific: args.os_specific = maybe_config.os_specific
132
+
117
133
  root = args.root
118
134
  rel2home = args.rel2home
119
135
  pwd = args.pwd
@@ -122,13 +138,6 @@ def parse_cloud_source_target(args: Args, source: str, target: str) -> tuple[str
122
138
  share = args.share
123
139
  os_specific = args.os_specific
124
140
 
125
- if config == "ss":
126
- maybe_config = get_secure_share_cloud_config()
127
- elif config is not None:
128
- maybe_config = Args.from_config(absolute(config))
129
- else:
130
- maybe_config = None
131
-
132
141
  if source.startswith(":"): # default cloud name is omitted cloud_name: # or ES in source
133
142
  # At the moment, this cloud.json defaults overrides the args and is activated only when source or target are just ":"
134
143
  # consider activating it by a flag, and also not not overriding explicitly passed args options.
@@ -184,13 +193,14 @@ def parse_cloud_source_target(args: Args, source: str, target: str) -> tuple[str
184
193
  raise NotImplementedError("There is no .get_local_path method yet")
185
194
  else:
186
195
  target_obj = absolute(target)
187
- if zip_arg and ".zip" not in source: source += ".zip"
188
- if encrypt and ".enc" not in source: source += ".enc"
196
+ if zip_arg and ".zip" not in source:
197
+ source += ".zip"
198
+ if encrypt and ".enc" not in source:
199
+ source += ".enc"
189
200
 
190
201
  elif ":" in target and (target[1] != ":" if len(target) > 1 else True): # avoid the case of "C:/"
191
202
  target_parts: list[str] = target.split(":")
192
203
  cloud = target.split(":")[0]
193
-
194
204
  if len(target_parts) > 1 and target_parts[1] == ES: # the target path is to be inferred from source.
195
205
  assert ES not in source, "You can't use $ in both source and target. Cyclical inference dependency arised."
196
206
  source_obj = absolute(source)
@@ -110,8 +110,9 @@ def main(which: Optional[str] = None):
110
110
  program = helper()
111
111
 
112
112
  else: raise ValueError(f"Unimplemented choice: {choice_key}")
113
- if program: write_shell_script(program, display=True, preserve_cwd=True, desc="Shell script prepared by Python.", execute=True if which is not None else False)
114
- else: write_shell_script("echo 'Done.'", display=False, ) # Python did not return any script to run.
113
+ if program:
114
+ write_shell_script(program=program, display=True, preserve_cwd=True, desc="Shell script prepared by Python.", execute=True if which is not None else False)
115
+ else: write_shell_script(program="echo 'Done.'", display=False, desc="Shell script prepared by Python.", preserve_cwd=True, execute=False) # Python did not return any script to run.
115
116
 
116
117
 
117
118
  if __name__ == "__main__":
@@ -38,7 +38,7 @@ def get_add_ssh_key_script(path_to_key: P):
38
38
  program = LIBRARY_ROOT.joinpath("setup_windows/openssh-server_add-sshkey.ps1")
39
39
  program = P(program).expanduser().read_text().replace('$sshfile=""', f'$sshfile="{path_to_key}"')
40
40
 
41
- if system() == "Linux": program += f"""
41
+ if system() == "Linux": program += """
42
42
 
43
43
  sudo chmod 700 ~/.ssh
44
44
  sudo chmod 644 ~/.ssh/authorized_keys
@@ -33,6 +33,28 @@ def search_for_files_of_interest(path_obj: P):
33
33
  return files
34
34
 
35
35
 
36
+ def convert_kwargs_to_fire_kwargs_str(kwargs: dict[str, Any]) -> str:
37
+ # https://google.github.io/python-fire/guide/
38
+ # https://github.com/google/python-fire/blob/master/docs/guide.md#argument-parsing
39
+ if not kwargs: # empty dict
40
+ kwargs_str = ''
41
+ else:
42
+ if len(kwargs) == 1:
43
+ kwargs_str = f""" --{list(kwargs.keys())[0]} {list(kwargs.values())[0]} """
44
+ else:
45
+ # print(f"len(kwargs) = {len(kwargs)}")
46
+ tmp_list: list[str] = []
47
+ for k, v in kwargs.items():
48
+ if v is not None:
49
+ item = f'"{k}": "{v}"'
50
+ else:
51
+ item = f'"{k}": None'
52
+ tmp_list.append(item)
53
+ tmp__ = ", ".join(tmp_list)
54
+ kwargs_str = "'{" + tmp__ + "}'"
55
+ return kwargs_str
56
+
57
+
36
58
  str2obj = {"True": True, "False": False, "None": None}
37
59
 
38
60
 
@@ -56,16 +78,19 @@ def main() -> None:
56
78
  # parser.add_argument("--git_pull", "-g", action="store_true", help="Start by pulling the git repo")
57
79
  parser.add_argument("--optimized", "-O", action="store_true", help="Run the optimized version of the function")
58
80
  parser.add_argument("--Nprocess", "-p", type=int, help="Number of processes to use", default=1)
59
- parser.add_argument("--kw", nargs="*", default=None, help="keyword arguments to pass to the function in the form of k1 v1 k2 v2 ...")
81
+ parser.add_argument("--kw", nargs="*", default=None, help="keyword arguments to pass to the function in the form of k1 v1 k2 v2 ... (meaning k1=v1, k2=v2, etc)")
60
82
 
61
83
  args = parser.parse_args()
84
+
85
+ # Convert args.kw to dictionary
62
86
  if args.kw is not None:
63
87
  assert len(args.kw) % 2 == 0, f"args.kw must be a list of even length. Got {len(args.kw)}"
64
88
  kwargs = dict(zip(args.kw[::2], args.kw[1::2]))
65
89
  for key, value in kwargs.items():
66
90
  if value in str2obj:
67
91
  kwargs[key] = str2obj[value]
68
- # print(f"kwargs = {kwargs}")
92
+ if args.function is None: # if user passed arguments and forgot to pass function, then assume they want to run the main function.
93
+ args.choose_function = True
69
94
  else:
70
95
  kwargs = {}
71
96
 
@@ -120,6 +145,7 @@ def main() -> None:
120
145
  from rich import print as rprint
121
146
  rprint(Panel(message))
122
147
  exe = "streamlit run --server.address 0.0.0.0 --server.headless true"
148
+ exe = f"cd '{choice_file.parent}'; " + exe
123
149
  elif args.interactive is False: exe = "python"
124
150
  elif args.jupyter: exe = "jupyter-lab"
125
151
  else:
@@ -128,7 +154,7 @@ def main() -> None:
128
154
 
129
155
  if args.module or (args.debug and args.choose_function): # because debugging tools do not support choosing functions and don't interplay with fire module. So the only way to have debugging and choose function options is to import the file as a module into a new script and run the function of interest there and debug the new script.
130
156
  import_line = get_import_module_code(str(choice_file))
131
- txt: str=f"""
157
+ txt: str = f"""
132
158
  try:
133
159
  {import_line}
134
160
  except (ImportError, ModuleNotFoundError) as ex:
@@ -143,6 +169,7 @@ except (ImportError, ModuleNotFoundError) as ex:
143
169
  txt = txt + f"""
144
170
  res = {choice_function}({('**' + str(kwargs)) if kwargs else ''})
145
171
  """
172
+
146
173
  txt = f"""
147
174
  try:
148
175
  from rich.panel import Panel
@@ -155,49 +182,27 @@ except ImportError as _ex:
155
182
  """ + txt
156
183
  choice_file = P.tmp().joinpath(f'tmp_scripts/python/{P(choice_file).parent.name}_{P(choice_file).stem}_{randstr()}.py').create(parents_only=True).write_text(txt)
157
184
 
158
- # determining basic command structure: putting together exe & choice_file & choice_function & pdb
185
+ # ========================= determining basic command structure: putting together exe & choice_file & choice_function & pdb
159
186
  if args.debug:
160
187
  if platform.system() == "Windows":
161
188
  command = f"{exe} -m ipdb {choice_file} " # pudb is not available on windows machines, use poor man's debugger instead.
162
189
  elif platform.system() in ["Linux", "Darwin"]:
163
190
  command = f"{exe} -m pudb {choice_file} " # TODO: functions not supported yet in debug mode.
164
191
  else: raise NotImplementedError(f"Platform {platform.system()} not supported.")
165
- elif choice_function is not None and not args.module: # if args.module, then kwargs are handled in the impot script, no need to pass them in fire command.
166
- # https://google.github.io/python-fire/guide/
167
- # https://github.com/google/python-fire/blob/master/docs/guide.md#argument-parsing
168
- if not kwargs: # empty dict
169
- kwargs_str = ''
170
- else:
171
- if len(kwargs) == 1:
172
- kwargs_str = f""" --{list(kwargs.keys())[0]} {list(kwargs.values())[0]} """
173
- else:
174
- # print(f"len(kwargs) = {len(kwargs)}")
175
- tmp_list: list[str] = []
176
- for k, v in kwargs.items():
177
- if v is not None:
178
- item = f'"{k}": "{v}"'
179
- else:
180
- item = f'"{k}": None'
181
- tmp_list.append(item)
182
- tmp__ = ", ".join(tmp_list)
183
- kwargs_str = "'{" + tmp__ + "}'"
192
+ elif args.module:
193
+ # both selected function and kwargs are mentioned in the made up script, therefore no need for fire module.
194
+ command = f"{exe} {choice_file} "
195
+ elif choice_function is not None:
196
+ kwargs_str = convert_kwargs_to_fire_kwargs_str(kwargs)
184
197
  command = f"{exe} -m fire {choice_file} {choice_function} {kwargs_str}"
185
- # else:
186
- # print(f"{kwargs=}")
187
- # print(f"{choice_function_args=}")
188
- # if choice_function != "RUN AS MAIN":
189
- # kgs1, _ = interactively_run_function(module[choice_function])
190
- # " ".join([f"--{k} {v}" for k, v in kgs1.items()])
198
+ elif args.streamlit:
199
+ # for .streamlit config to work, it needs to be in the current directory.
200
+ command = f"cd {choice_file.parent}\n\n{exe} {choice_file.name}\n\ncd {P.cwd()}"
201
+ elif args.cmd:
202
+ command = rf""" cd /d {choice_file.parent} & {exe} {choice_file.name} """
191
203
  else:
192
- if not args.streamlit: command = f"{exe} {choice_file} "
193
- else:
194
- if not args.cmd:
195
- # for .streamlit config to work, it needs to be in the current directory.
196
- command = f"cd {choice_file.parent}\n\n{exe} {choice_file.name}\n\ncd {P.cwd()}"
197
- else:
198
- command = rf""" cd /d {choice_file.parent} & {exe} {choice_file.name} """
199
- # command = f"cd {choice_file.parent}\n\n{exe} {choice_file.name}\n\ncd {P.cwd()}"
200
-
204
+ # command = f"cd {choice_file.parent}\n\n{exe} {choice_file.name}\n\ncd {P.cwd()}"
205
+ command = f"{exe} {choice_file} "
201
206
  # this installs in ve env, which is not execution env
202
207
  # if "ipdb" in command: install_n_import("ipdb")
203
208
  # if "pudb" in command: install_n_import("pudb")
@@ -220,7 +225,8 @@ except ImportError as _ex:
220
225
  command = f"""
221
226
  . $HOME/scripts/activate_ve {args.ve}
222
227
  python -m crocodile.cluster.templates.cli_click --file {choice_file} """
223
- if choice_function is not None: command += f"--function {choice_function} "
228
+ if choice_function is not None:
229
+ command += f"--function {choice_function} "
224
230
  try: install_n_import("clipboard").copy(command)
225
231
  except Exception as ex: print(f"Failed to copy command to clipboard. {ex}")
226
232
 
@@ -365,11 +371,23 @@ def find_repo_root_path(start_path: str) -> Optional[str]:
365
371
  def get_import_module_code(module_path: str):
366
372
  root_path = find_repo_root_path(module_path)
367
373
  if root_path is None: # just make a desperate attempt to import it
368
- module_name = module_path.lstrip(os.sep).replace(os.sep, '.').replace('.py', '')
374
+ module_name = module_path.lstrip(os.sep).replace(os.sep, '.')
375
+ if module_name.endswith(".py"):
376
+ module_name = module_name[:-3]
369
377
  else:
370
378
  relative_path = module_path.replace(root_path, '')
371
- module_name = relative_path.lstrip(os.sep).replace(os.sep, '.').replace('.py', '')
372
- module_name = module_name.replace("src.", "").replace("myresources.", "").replace("resources.", "").replace("source.", "").replace("resources.", "").replace("source.", "").replace("src.", "").replace("myresources.", "").replace("resources.", "").replace("source.", "").replace("src.", "").replace("myresources.", "").replace("resources.", "").replace("source.", "").replace("src.", "").replace("myresources.", "").replace("resources.", "").replace("source.", "").replace("src.", "").replace("myresources.", "").replace("resources.", "").replace("source.", "").replace("src.", "").replace("myresources.", "").replace("resources.", "").replace("source.", "").replace("src.", "").replace("myresources.", "").replace("resources.", "").replace("source.", "").replace("src.", "").replace("resources.", "").replace("source.", "")
379
+ module_name = relative_path.lstrip(os.sep).replace(os.sep, '.')
380
+ if module_name.endswith(".py"):
381
+ module_name = module_name[:-3]
382
+ # module_name = module_name.replace("src.", "").replace("myresources.", "").replace("resources.", "").replace("source.", "")
383
+ if module_name.startswith("src."):
384
+ module_name = module_name[4:]
385
+ if module_name.startswith("myresources."):
386
+ module_name = module_name[12:]
387
+ if module_name.startswith("resources."):
388
+ module_name = module_name[10:]
389
+ if module_name.startswith("source."):
390
+ module_name = module_name[7:]
373
391
  if any(char in module_name for char in "- :/\\"):
374
392
  module_name = "IncorrectModuleName"
375
393
  # TODO: use py_compile to check if the statement is valid code to avoid syntax errors that can't be caught.
@@ -6,13 +6,15 @@ from crocodile.file_management import Read, P
6
6
 
7
7
  gh_token = Read.ini(P.home().joinpath("dotfiles/creds/git/git_host_tokens.ini"))['thisismygitrepo']['newLongterm']
8
8
  endpoint = "https://models.inference.ai.azure.com"
9
- model_name_preferences = ["o1-preview", "o1-mini", "GPT-4o", "GPT-4-o-mini"]
9
+ model_name_preferences = ["o3-mini", "o1-preview", "o1-mini", "GPT-4o", "GPT-4-o-mini"]
10
10
  client__ = OpenAI(
11
11
  base_url=endpoint,
12
12
  api_key=gh_token,
13
13
  )
14
14
 
15
- def get_response(client, model_name, messages):
15
+
16
+ def get_response(client, model_name: str, messages: list[str]):
17
+ print(f"Getting response from model {model_name}")
16
18
  try:
17
19
  response = client.chat.completions.create(
18
20
  messages=messages,
@@ -118,7 +118,7 @@ def main():
118
118
  if args.commit or args.all: program += git_action(a_path, action=GitAction.commit, r=args.recursive)
119
119
  if args.push or args.all: program += git_action(a_path, action=GitAction.push, r=args.recursive)
120
120
  else: program = "echo 'no action specified, try to pass --push, --pull, --commit or --all'"
121
- write_shell_script(program, "Script to update repos")
121
+ write_shell_script(program=program, desc="Script to update repos", preserve_cwd=True)
122
122
 
123
123
 
124
124
  def record_repos(repos_root: str, r: bool=True) -> list[dict[str, Any]]:
@@ -90,7 +90,7 @@ def main() -> None:
90
90
  import socket
91
91
  try: local_ip_v4 = socket.gethostbyname(socket.gethostname() + ".local") # without .local, in linux machines, '/etc/hosts' file content, you have an IP address mapping with '127.0.1.1' to your hostname
92
92
  except Exception:
93
- print(f"Warning: Could not get local_ip_v4. This is probably because you are running a WSL instance") # TODO find a way to get the local_ip_v4 in WSL
93
+ print("Warning: Could not get local_ip_v4. This is probably because you are running a WSL instance") # TODO find a way to get the local_ip_v4 in WSL
94
94
  local_ip_v4 = socket.gethostbyname(socket.gethostname())
95
95
 
96
96
  print(f"Presentation is served at http://{platform.node()}:{port}")
@@ -103,7 +103,7 @@ def main() -> None:
103
103
  # Then you can do the following:
104
104
  program = "npm run dev slides.md -- --remote"
105
105
  PROGRAM_PATH.write_text(program)
106
- print_code(program, lexer="bash")
106
+ print_code(code=program, lexer="bash", desc="Run the following command to start the presentation")
107
107
 
108
108
 
109
109
  if __name__ == '__main__':
File without changes
@@ -14,7 +14,9 @@ import platform
14
14
  # import os
15
15
 
16
16
 
17
- LINUX_INSTALL_PATH = '/usr/local/bin'
17
+ # LINUX_INSTALL_PATH = '/usr/local/bin'
18
+ LINUX_INSTALL_PATH = '~/.local/bin'
19
+
18
20
  WINDOWS_INSTALL_PATH = P.home().joinpath("AppData/Local/Microsoft/WindowsApps").__str__()
19
21
  CATEGORY: TypeAlias = Literal["OS_SPECIFIC", "OS_GENERIC", "CUSTOM", "OS_SPECIFIC_DEV", "OS_GENERIC_DEV", "CUSTOM_DEV"]
20
22
 
@@ -60,7 +62,10 @@ def find_move_delete_linux(downloaded: P, tool_name: str, delete: Optional[bool]
60
62
  print(f"MOVING file `{repr(exe)}` to '{LINUX_INSTALL_PATH}'")
61
63
  exe.chmod(0o777)
62
64
  # exe.move(folder=LINUX_INSTALL_PATH, overwrite=False)
63
- Terminal().run(f"sudo mv {exe} {LINUX_INSTALL_PATH}/").print_if_unsuccessful(desc=f"MOVING executable `{exe}` to {LINUX_INSTALL_PATH}", strict_err=True, strict_returncode=True)
65
+ if "/usr" in LINUX_INSTALL_PATH:
66
+ Terminal().run(f"sudo mv {exe} {LINUX_INSTALL_PATH}/").print_if_unsuccessful(desc=f"MOVING executable `{exe}` to {LINUX_INSTALL_PATH}", strict_err=True, strict_returncode=True)
67
+ else:
68
+ exe.move(folder=LINUX_INSTALL_PATH, overwrite=True)
64
69
  if delete: downloaded.delete(sure=True)
65
70
  exe_new_location = P(LINUX_INSTALL_PATH).joinpath(exe.name)
66
71
  return exe_new_location
@@ -110,7 +115,7 @@ class Installer:
110
115
  new_version_cli = Terminal().run(f"{self.exe_name} --version").op.replace("\n", "")
111
116
 
112
117
  if old_version_cli == new_version_cli: return f"""echo "📦️ 😑 {self.exe_name}, same version: {old_version_cli}" """
113
- else: return f"""echo "📦️ 🤩 {self.exe_name} updated from {old_version_cli} === to ===> {new_version_cli}" """
118
+ else: return f"""echo "📦️ 🤩 {self.exe_name} updated from {old_version_cli} ➡️ TO ➡️ {new_version_cli}" """
114
119
 
115
120
  except Exception as ex:
116
121
  print(ex)
@@ -126,7 +131,7 @@ class Installer:
126
131
 
127
132
  import runpy
128
133
  print(f"Executing func `main` from `{installer_path}`to get the program to run")
129
- program: str=runpy.run_path(str(installer_path), run_name=None)['main'](version=version)
134
+ program: str = runpy.run_path(str(installer_path), run_name=None)['main'](version=version)
130
135
  # print(program)
131
136
  Terminal(stdin=None, stdout=None, stderr=None).run_script(script=program, shell="default").print(desc="Running custom installer", capture=True)
132
137
  # import subprocess
@@ -174,6 +179,7 @@ class Installer:
174
179
  print(f"📦️ Version to be installed: {version_to_be_installed}")
175
180
  print(f"📦️ Release URL: {release_url}")
176
181
  version_to_be_installed_stripped = version_to_be_installed.replace("v", "") if self.strip_v else version_to_be_installed
182
+ version_to_be_installed_stripped = version_to_be_installed_stripped.replace("ipinfo-", "")
177
183
  if platform.system() == "Windows":
178
184
  file_name = self.filename_template_windows_amd_64.format(version_to_be_installed_stripped)
179
185
  elif platform.system() == "Linux":
@@ -19,11 +19,10 @@ from typing import Optional, Union, TypeVar, Iterable
19
19
 
20
20
  LIBRARY_ROOT = P(machineconfig.__file__).resolve().parent # .replace(P.home().to_str().lower(), P.home().str)
21
21
  REPO_ROOT = LIBRARY_ROOT.parent.parent
22
- PROGRAM_PATH = (P.tmp().joinpath("shells/python_return_command") + (".ps1" if platform.system() == "Windows" else ".sh")).create(parents_only=True)
22
+ PROGRAM_PATH = (P.home().joinpath("tmp_results", "shells", "python_return_command") + (".ps1" if platform.system() == "Windows" else ".sh"))
23
23
  CONFIG_PATH = P.home().joinpath(".config/machineconfig")
24
24
  INSTALL_VERSION_ROOT = CONFIG_PATH.joinpath("cli_tools_installers/versions")
25
- INSTALL_TMP_DIR = P.tmp(folder="tmp_installers")
26
-
25
+ INSTALL_TMP_DIR = P.home().joinpath("tmp_results", "tmp_installers")
27
26
  DEFAULTS_PATH = P.home().joinpath("dotfiles/machineconfig/defaults.ini")
28
27
 
29
28
 
@@ -106,7 +105,7 @@ def match_file_name(sub_string: str, search_root: Optional[P] = None) -> P:
106
105
 
107
106
  if check_tool_exists(tool_name="fzf"):
108
107
  try:
109
- print("Trying with fd ...")
108
+ print(f"Using fd to searching for `{sub_string}` in `{search_root_obj}` ...")
110
109
  fzf_cmd = f"cd '{search_root_obj}'; fd --type f --strip-cwd-prefix | fzf --filter={sub_string}"
111
110
  search_res = subprocess.run(fzf_cmd, stdout=subprocess.PIPE, text=True, check=True, shell=True).stdout.split("\n")[:-1]
112
111
  except subprocess.CalledProcessError as cpe:
@@ -151,7 +150,8 @@ def choose_multiple_options(options: Iterable[T], header: str="", tail: str="",
151
150
 
152
151
  def display_options(msg: str, options: Iterable[T], header: str="", tail: str="", prompt: str="",
153
152
  default: Optional[T] = None, fzf: bool=False, multi: bool=False, custom_input: bool=False) -> Union[T, list[T]]:
154
- # TODO: replace with https://github.com/tmbo/questionary # also see https://github.com/charmbracelet/gum
153
+ # TODO: replace with https://github.com/tmbo/questionary
154
+ # # also see https://github.com/charmbracelet/gum
155
155
  tool_name = "fzf"
156
156
  options_strings: list[str] = [str(x) for x in options]
157
157
  default_string = str(default) if default is not None else None
@@ -301,7 +301,8 @@ except ImportError: print(code)
301
301
  return shell_file
302
302
 
303
303
 
304
- def write_shell_script(program: str, desc: str="", preserve_cwd: bool=True, display: bool=True, execute: bool=False):
304
+ # def write_shell_script(program: str, desc: str="", preserve_cwd: bool=True, display: bool=True, execute: bool=False):
305
+ def write_shell_script(program: str, desc: str, preserve_cwd: bool, display: bool, execute: bool):
305
306
  if preserve_cwd:
306
307
  if platform.system() == "Windows":
307
308
  program = "$orig_path = $pwd\n" + program + "\ncd $orig_path"
@@ -316,7 +317,7 @@ def write_shell_script(program: str, desc: str="", preserve_cwd: bool=True, disp
316
317
  return None
317
318
 
318
319
 
319
- def print_code(code: str, lexer: str, desc: str=""):
320
+ def print_code(code: str, lexer: str, desc: str):
320
321
  if lexer == "shell":
321
322
  if platform.system() == "Windows": lexer = "powershell"
322
323
  elif platform.system() == "Linux": lexer = "sh"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: machineconfig
3
- Version: 1.91
3
+ Version: 1.92
4
4
  Summary: Dotfiles management package
5
5
  Home-page: https://github.com/thisismygitrepo/machineconfig
6
6
  Author: Alex Al-Saffar
@@ -1,7 +1,7 @@
1
- machineconfig/__init__.py,sha256=zFmBYpknJZWoUoOu6Zh1tiiGKu_rEvtMhSjRqhGNb1Q,79
1
+ machineconfig/__init__.py,sha256=wu9UsflBjt4NGTucNPu5-nUn1bbUMI1U2sVVlzDviFY,75
2
2
  machineconfig/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  machineconfig/jobs/python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- machineconfig/jobs/python/check_installations.py,sha256=VCWm1gusV126HFS-LxW8_ALejMzvYKohTQ3zheYfLsk,7785
4
+ machineconfig/jobs/python/check_installations.py,sha256=XchBafqLFChIOF6K5BkvV8mNeMQqmqQrX8PFP_C3zo8,8016
5
5
  machineconfig/jobs/python/checkout_version.py,sha256=CynwqWoFD8yddKw4bfJWmU9BWx2ORN0Pl6igLo50hK8,4318
6
6
  machineconfig/jobs/python/create_bootable_media.py,sha256=OGZB_hiGVVlKVXE-7mGCdNhntOiLvXsno8cyRzB0EGI,611
7
7
  machineconfig/jobs/python/create_zellij_template.py,sha256=tIGieeq2n21B_dpgkXiR_Zh2q4xUPG3QhqCwLKCkhog,1301
@@ -10,7 +10,7 @@ machineconfig/jobs/python/python_ve_symlink.py,sha256=ZdXuTfEBkO1uYc6F-xg_bWF46S
10
10
  machineconfig/jobs/python/tasks.py,sha256=palEhxnzY0roWg16-LS6mZM9pjOiUe8g9Ye7UKxe8kw,151
11
11
  machineconfig/jobs/python_custom_installers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  machineconfig/jobs/python_custom_installers/gh.py,sha256=4XRUUuT5b29V5WAPgJMGqxLqQ9-wbBv-mAisIxUNubQ,1433
13
- machineconfig/jobs/python_custom_installers/hx.py,sha256=AdrLrk8kH-Fa1Is4ZJkpxiellvYxnWof8yaGKGnU2i4,1967
13
+ machineconfig/jobs/python_custom_installers/hx.py,sha256=drxM9mMmS3yGlakeHFPVhzSKv5SZANjAr83pXm6p6fA,2116
14
14
  machineconfig/jobs/python_generic_installers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  machineconfig/jobs/python_linux_installers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  machineconfig/jobs/python_linux_installers/dev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -20,50 +20,51 @@ machineconfig/jobs/python_windows_installers/dev/__init__.py,sha256=47DEQpj8HBSa
20
20
  machineconfig/profile/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  machineconfig/profile/create.py,sha256=k2PKsdOdJ_Jpe9gJ2xkDh60mWlA2FS1TQpmRQUXeWvQ,5162
22
22
  machineconfig/profile/create_hardlinks.py,sha256=5y3IqCGf8qE34W40IQTLXkzig5dipUre9C9DTEhHMo4,4581
23
- machineconfig/profile/shell.py,sha256=FsmZhNoVmzD_Fn22jwFtstVm6fTbkcdI5qY3K8o-0cg,6136
23
+ machineconfig/profile/shell.py,sha256=X7eYnPRZ91gCxeeFMGqToceI4eQnaQPcMP1e7FHPm04,6203
24
24
  machineconfig/scripts/__init__.py,sha256=8aZPVoch_gcI0Ihcr30zQcPjRQMWiWzDnQXnOm7spzo,73
25
25
  machineconfig/scripts/python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  machineconfig/scripts/python/choose_wezterm_theme.py,sha256=2nQ9ruqYENQXYepFTocjeIS03P3mFdUNN8zJxCMA6r4,2697
27
27
  machineconfig/scripts/python/cloud_copy.py,sha256=2oX58QlyhQs6SKNcAEbYhvNhIBSJyie_zKM0i2D206o,5049
28
28
  machineconfig/scripts/python/cloud_manager.py,sha256=qfmO63t1LQxO6QHhz3qxePQnas4RsNOjLV1cGK8xK8I,1639
29
29
  machineconfig/scripts/python/cloud_mount.py,sha256=7ygg8tu-L-N0Q4KYcV7X2oxQgj6aEF9uIC8YWzdPioc,4882
30
- machineconfig/scripts/python/cloud_repo_sync.py,sha256=RiP23IR1hpLD5bKxyahfZYPA2cbkP577DYa6g7ks86E,10178
31
- machineconfig/scripts/python/cloud_sync.py,sha256=4vh8AwL6OL1fMZe5278oezRVNIaLFPedjVw5pvbCD5w,11103
30
+ machineconfig/scripts/python/cloud_repo_sync.py,sha256=MLK2EvCwJ4gHS--bpBTQDsud7GboM6rolySzieNLpiM,10402
31
+ machineconfig/scripts/python/cloud_sync.py,sha256=B57tLfnYOEBz25jXiSaiZ4uxgiNk4djtWxv-W-gpm-E,11730
32
32
  machineconfig/scripts/python/croshell.py,sha256=qWdIAQF3rsDaVVoU9Iq855zKnS9vYGsEPRL6EvWwFEk,6457
33
- machineconfig/scripts/python/devops.py,sha256=jYOUsdBy9zsrxibklBVE9_vVR_oo09m20ccSWoCKQlc,5384
33
+ machineconfig/scripts/python/devops.py,sha256=v9OrZHzsZrcd4MCGa4eqOnDtaeV1ntz4-bVjkYOSR_A,5481
34
34
  machineconfig/scripts/python/devops_add_identity.py,sha256=q0DjXowg0dr5nDVrMdyViF_OQdeTN_fDXTVcVPgddfk,1549
35
- machineconfig/scripts/python/devops_add_ssh_key.py,sha256=RoHO_lP1DuyKrPl_wYfAJuliRP7CVKssygy3cK2eJXo,3308
35
+ machineconfig/scripts/python/devops_add_ssh_key.py,sha256=LX9h0Sa-U_G3adKlz2rJRS8WKVZzJy1knRpUL5QXv-c,3307
36
36
  machineconfig/scripts/python/devops_backup_retrieve.py,sha256=jAdnWZPj0wWKCZdKOrbh_ocP_mq4Qe9Go9MSsne_2MM,2825
37
37
  machineconfig/scripts/python/devops_devapps_install.py,sha256=cMCkZPiqgAhp8eopw6Ig5-zE7e2Vq0EJ3jP8EahwqYM,6461
38
38
  machineconfig/scripts/python/devops_update_repos.py,sha256=tT20CEGT7419BLYJGLF_tzMig49roBC8n2H8Pv3S6TU,2756
39
39
  machineconfig/scripts/python/dotfile.py,sha256=_-YhGv1aX2BvePfMS0NKuKVc62I6e8FnJWcoJgxGT-k,1572
40
- machineconfig/scripts/python/fire_jobs.py,sha256=LEJAFejj7uz5E38GWKQi1ih7JWkltgZQmUwD4PuTHfc,21090
40
+ machineconfig/scripts/python/fire_jobs.py,sha256=y5BURxWUwi-pHx_x1ZlMLkLGZffACRMvQ9vOrhU3XlI,20967
41
41
  machineconfig/scripts/python/ftpx.py,sha256=PQ7ktw6O4Y9Mv3rdRy8rBPDQQLoEafojTBr5IpLDXW8,4643
42
- machineconfig/scripts/python/gh_models.py,sha256=IZ9fxb4PevUAsG3zclLGBXABda67R3mmVnUPc8Bp_wU,1841
42
+ machineconfig/scripts/python/gh_models.py,sha256=ez_1ngamoDo9tAZq6Ur5F7marNJz6w9JWmkYRkpEI48,1924
43
43
  machineconfig/scripts/python/mount_nfs.py,sha256=WR75U_WVYHibiC2DNxEncy7x273zH8EoUjhikcVERoM,2484
44
44
  machineconfig/scripts/python/mount_nw_drive.py,sha256=YggJOZayVfj2lthQOw68Sq9pgLltXdJ83o8KCRIRjcY,1002
45
45
  machineconfig/scripts/python/mount_ssh.py,sha256=zXGHnNPN-PKD364lWN9ucOilVH3eW2WDqjwX0wXBzOY,1402
46
46
  machineconfig/scripts/python/onetimeshare.py,sha256=tveeuE_PmRuk7hwJy5c53b2eL0lvxR_MACX5X_4syy8,1881
47
47
  machineconfig/scripts/python/pomodoro.py,sha256=lb-JqrFrcuIlnWNAJGlcBYRVnaT5OyDLmNWJllz5b7M,1979
48
- machineconfig/scripts/python/repos.py,sha256=6X6BmOMZnK8L5v4GYLv8uQdymDxE3s6xjkpFi1SYmdQ,10333
48
+ machineconfig/scripts/python/repos.py,sha256=YjSnQ9THvojzdrkhPj8-26cbWckEo8SGbhyuD9nsw1Y,10365
49
49
  machineconfig/scripts/python/scheduler.py,sha256=z2xEQc_XkWy3viLoyVh5Eqz7SS0U0EI7MSCxa3Zsyv8,2310
50
50
  machineconfig/scripts/python/snapshot.py,sha256=XxnGc8bOb7vgx-TpJVBzgkzQf9Fcz6VyQ3LH7sOsLDI,622
51
- machineconfig/scripts/python/start_slidev.py,sha256=9pw7YsSkHXsjscPP3W-IjqzdEHDifWVeU3wwaZwoz6E,4693
51
+ machineconfig/scripts/python/start_slidev.py,sha256=LKYDWHc6hElIDrG-4iuws-HXDE_IxDDWbsMCt2wX2Fo,4757
52
52
  machineconfig/scripts/python/start_terminals.py,sha256=_iKn_L9FeAxiDr_srmwJm0Slq4LxTYHV7LP5eF-m5T8,5446
53
53
  machineconfig/scripts/python/wifi_conn.py,sha256=Zst2qB5AZ0q2BsO4xl_8kiBDrQDiHn_QkSqEPVAoi_Q,2930
54
54
  machineconfig/scripts/python/wsl_windows_transfer.py,sha256=f-rHdoC2aN-CfVEJogKfhni_N1lL68P4roeFeghWlgU,2197
55
+ machineconfig/settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
56
  machineconfig/setup_windows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
57
  machineconfig/setup_windows/wt_and_pwsh/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
58
  machineconfig/setup_windows/wt_and_pwsh/set_pwsh_theme.py,sha256=7bgzIKxjeBptvR_MAabkPaGvM-RtwjkCQl5fXiO8Jks,1616
58
59
  machineconfig/setup_windows/wt_and_pwsh/set_wt_settings.py,sha256=Vot104GT-skjx294XcYjgk-rvCf6ibqtJBFcRDtgA18,6251
59
60
  machineconfig/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
- machineconfig/utils/installer.py,sha256=dbAi-z1RNZ5s2_Pnw_DHr0NdNpggJ7AfToC3IDu-67s,19627
61
+ machineconfig/utils/installer.py,sha256=lfMinC_Va4CwDsx46BViFO7K1XstCezP8SxzbIY79Kg,19888
61
62
  machineconfig/utils/procs.py,sha256=2l2nR86RqtUUrHzrj3YzyVD2TPwwaDAMgSweljU5fuY,5176
62
63
  machineconfig/utils/scheduling.py,sha256=EetPS2TKlb_3J3LPZSsGzMaPykEycNczCqukYwEP_NE,7342
63
- machineconfig/utils/utils.py,sha256=R4Q4IAAhGOT0FAVQ9GoY7hCHUlUWNSXkZDfDV0SHr6A,22841
64
+ machineconfig/utils/utils.py,sha256=llwHwk25Zs4dde3mecwMxEn5obAmNQQVqoiZNGiJGmA,23006
64
65
  machineconfig/utils/ve.py,sha256=zjXsWM7_ijty8Iz9SnUG3dPydr3sFtwakghQY-8oRlI,12655
65
- machineconfig-1.91.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
66
- machineconfig-1.91.dist-info/METADATA,sha256=y_rnijmr8n1wptiAb_LZLsMge3_aWN9usF15DYJmYOM,6662
67
- machineconfig-1.91.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
68
- machineconfig-1.91.dist-info/top_level.txt,sha256=porRtB8qms8fOIUJgK-tO83_FeH6Bpe12oUVC670teA,14
69
- machineconfig-1.91.dist-info/RECORD,,
66
+ machineconfig-1.92.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
67
+ machineconfig-1.92.dist-info/METADATA,sha256=SuGcK0KfTNA5yXk5gcOunMBDVI1kwbS7zNGYKR-MKYA,6662
68
+ machineconfig-1.92.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
69
+ machineconfig-1.92.dist-info/top_level.txt,sha256=porRtB8qms8fOIUJgK-tO83_FeH6Bpe12oUVC670teA,14
70
+ machineconfig-1.92.dist-info/RECORD,,