machineconfig 6.62__py3-none-any.whl → 6.63__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/utils/ssh.py +13 -10
- {machineconfig-6.62.dist-info → machineconfig-6.63.dist-info}/METADATA +1 -1
- {machineconfig-6.62.dist-info → machineconfig-6.63.dist-info}/RECORD +6 -6
- {machineconfig-6.62.dist-info → machineconfig-6.63.dist-info}/WHEEL +0 -0
- {machineconfig-6.62.dist-info → machineconfig-6.63.dist-info}/entry_points.txt +0 -0
- {machineconfig-6.62.dist-info → machineconfig-6.63.dist-info}/top_level.txt +0 -0
machineconfig/utils/ssh.py
CHANGED
|
@@ -112,10 +112,11 @@ class SSH:
|
|
|
112
112
|
from machineconfig.scripts.python.helpers_devops.cli_utils import get_machine_specs
|
|
113
113
|
self.local_specs: MachineSpecs = get_machine_specs()
|
|
114
114
|
resp = self.run_shell(command=f"""~/.local/bin/utils get-machine-specs """, verbose_output=False, description="Getting remote machine specs", strict_stderr=False, strict_return_code=False)
|
|
115
|
-
import json
|
|
115
|
+
# import json
|
|
116
116
|
json_str = resp.op
|
|
117
|
-
print(f"Remote machine specs JSON: {resp}")
|
|
118
|
-
|
|
117
|
+
print(f"Remote machine specs JSON: {resp.op}")
|
|
118
|
+
import ast
|
|
119
|
+
self.remote_specs: MachineSpecs = cast(MachineSpecs, ast.literal_eval(json_str))
|
|
119
120
|
self.terminal_responses: list[Response] = []
|
|
120
121
|
|
|
121
122
|
def __enter__(self) -> "SSH":
|
|
@@ -181,7 +182,7 @@ class SSH:
|
|
|
181
182
|
uv_cmd = f"""{UV_RUN_CMD} {with_clause} python {py_path.relative_to(Path.home())}"""
|
|
182
183
|
return self.run_shell(command=uv_cmd, verbose_output=verbose_output, description=description or f"run_py on {self.get_remote_repr(add_machine=False)}", strict_stderr=strict_stderr, strict_return_code=strict_return_code)
|
|
183
184
|
|
|
184
|
-
def
|
|
185
|
+
def run_lambda_function(self, func: Callable[..., Any], uv_with: Optional[list[str]], uv_project_dir: Optional[str]) -> Response:
|
|
185
186
|
command = lambda_to_python_script(lmb=func, in_global=True)
|
|
186
187
|
return self.run_py(python_code=command, uv_with=uv_with, uv_project_dir=uv_project_dir,
|
|
187
188
|
description=f"run_py_func {func.__name__} on {self.get_remote_repr(add_machine=False)}",
|
|
@@ -196,7 +197,7 @@ class SSH:
|
|
|
196
197
|
|
|
197
198
|
def create_dir(self, path_rel2home: str, overwrite_existing: bool) -> None:
|
|
198
199
|
"""Helper to create a directory on remote machine and return its path."""
|
|
199
|
-
def create_target_dir(target_rel2home: str, overwrite: bool)
|
|
200
|
+
def create_target_dir(target_rel2home: str, overwrite: bool):
|
|
200
201
|
from pathlib import Path
|
|
201
202
|
import shutil
|
|
202
203
|
directory_path = Path(target_rel2home).expanduser()
|
|
@@ -206,13 +207,15 @@ class SSH:
|
|
|
206
207
|
else:
|
|
207
208
|
directory_path.unlink()
|
|
208
209
|
directory_path.parent.mkdir(parents=True, exist_ok=True)
|
|
209
|
-
return
|
|
210
210
|
command = lambda_to_python_script(lmb=lambda: create_target_dir(target_rel2home=path_rel2home, overwrite=overwrite_existing), in_global=True)
|
|
211
211
|
tmp_py_file = Path.home().joinpath(f"{DEFAULT_PICKLE_SUBDIR}/create_target_dir_{randstr()}.py")
|
|
212
212
|
tmp_py_file.parent.mkdir(parents=True, exist_ok=True)
|
|
213
213
|
tmp_py_file.write_text(command, encoding="utf-8")
|
|
214
|
-
self.copy_from_here(source_path=str(tmp_py_file), target_rel2home=
|
|
215
|
-
self.
|
|
214
|
+
# self.copy_from_here(source_path=str(tmp_py_file), target_rel2home=".tmp_file.py", compress_with_zip=False, recursive=False, overwrite_existing=True)
|
|
215
|
+
assert self.sftp is not None
|
|
216
|
+
tmp_remote_path = ".tmp_pyfile.py"
|
|
217
|
+
self.sftp.put(localpath=str(tmp_py_file), remotepath=str(Path(self.remote_specs["home_dir"]).joinpath(tmp_remote_path)))
|
|
218
|
+
self.run_shell(command=f"""{UV_RUN_CMD} python {tmp_remote_path}""", verbose_output=False, description=f"Creating target dir {path_rel2home}", strict_stderr=True, strict_return_code=True)
|
|
216
219
|
|
|
217
220
|
def copy_from_here(self, source_path: str, target_rel2home: Optional[str], compress_with_zip: bool, recursive: bool, overwrite_existing: bool) -> None:
|
|
218
221
|
if self.sftp is None: raise RuntimeError(f"SFTP connection not available for {self.hostname}. Cannot transfer files.")
|
|
@@ -226,7 +229,7 @@ class SSH:
|
|
|
226
229
|
if not recursive:
|
|
227
230
|
raise RuntimeError(f"SSH Error: source `{source_obj}` is a directory! Set `recursive=True` for recursive sending or `compress_with_zip=True` to zip it first.")
|
|
228
231
|
file_paths_to_upload: list[Path] = [file_path for file_path in source_obj.rglob("*") if file_path.is_file()]
|
|
229
|
-
|
|
232
|
+
self.create_dir(path_rel2home=target_rel2home, overwrite_existing=overwrite_existing)
|
|
230
233
|
for idx, file_path in enumerate(file_paths_to_upload):
|
|
231
234
|
print(f" {idx + 1:03d}. {file_path}")
|
|
232
235
|
for file_path in file_paths_to_upload:
|
|
@@ -243,7 +246,7 @@ class SSH:
|
|
|
243
246
|
shutil.make_archive(str(zip_path), "zip", source_obj.parent, source_obj.name)
|
|
244
247
|
source_obj = Path(str(zip_path) + ".zip")
|
|
245
248
|
if not target_rel2home.endswith(".zip"): target_rel2home = target_rel2home + ".zip"
|
|
246
|
-
|
|
249
|
+
self.create_dir(path_rel2home=target_rel2home, overwrite_existing=overwrite_existing)
|
|
247
250
|
print(f"""📤 [SFTP UPLOAD] Sending file: {repr(source_obj)} ==> Remote Path: {target_rel2home}""")
|
|
248
251
|
try:
|
|
249
252
|
with self.tqdm_wrap(ascii=True, unit="b", unit_scale=True) as pbar:
|
|
@@ -407,7 +407,7 @@ machineconfig/utils/procs.py,sha256=YPA_vEYQGwPd_o_Lc6nOTBo5BrB1tSs8PJ42XiGpenM,
|
|
|
407
407
|
machineconfig/utils/scheduler.py,sha256=44CASABJg3epccxhAwv2CX7TVgZh6zVy3K4vqHKTuf4,14228
|
|
408
408
|
machineconfig/utils/scheduling.py,sha256=6x5zLA7sY5gohrEtN6zGrXIqNFasMoyBfwLcOjrjiME,11109
|
|
409
409
|
machineconfig/utils/source_of_truth.py,sha256=ZAnCRltiM07ig--P6g9_6nEAvNFC4X4ERFTVcvpIYsE,764
|
|
410
|
-
machineconfig/utils/ssh.py,sha256=
|
|
410
|
+
machineconfig/utils/ssh.py,sha256=Y_n9KKf40VvKAT677B8bMNB0Qs1uIivcFlIQ9xuqo5o,36001
|
|
411
411
|
machineconfig/utils/terminal.py,sha256=VDgsjTjBmMGgZN0YIc0pJ8YksLDrBtiXON1EThy7_is,4264
|
|
412
412
|
machineconfig/utils/tst.py,sha256=6u1GI49NdcpxH2BYGAusNfY5q9G_ytCGVzFM5b6HYpM,674
|
|
413
413
|
machineconfig/utils/upgrade_packages.py,sha256=mSFyKvB3JhHte_x1dtmEgrJZCAXgTUQoaJUSx1OXQ3Y,4145
|
|
@@ -436,8 +436,8 @@ machineconfig/utils/schemas/installer/installer_types.py,sha256=QClRY61QaduBPJoS
|
|
|
436
436
|
machineconfig/utils/schemas/layouts/layout_types.py,sha256=TcqlZdGVoH8htG5fHn1KWXhRdPueAcoyApppZsPAPto,2020
|
|
437
437
|
machineconfig/utils/schemas/repos/repos_types.py,sha256=ECVr-3IVIo8yjmYmVXX2mnDDN1SLSwvQIhx4KDDQHBQ,405
|
|
438
438
|
machineconfig/utils/ssh_utils/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
439
|
-
machineconfig-6.
|
|
440
|
-
machineconfig-6.
|
|
441
|
-
machineconfig-6.
|
|
442
|
-
machineconfig-6.
|
|
443
|
-
machineconfig-6.
|
|
439
|
+
machineconfig-6.63.dist-info/METADATA,sha256=i_pMCNUzi-v7pZWWUl96i4R5aU1H6JSwVRZr9A3-LbQ,2928
|
|
440
|
+
machineconfig-6.63.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
441
|
+
machineconfig-6.63.dist-info/entry_points.txt,sha256=NTW7hbUlpt5Vx9DdQrONLkYMCuBXpvYh1dt0AtlGxeI,466
|
|
442
|
+
machineconfig-6.63.dist-info/top_level.txt,sha256=porRtB8qms8fOIUJgK-tO83_FeH6Bpe12oUVC670teA,14
|
|
443
|
+
machineconfig-6.63.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|