abstract-utilities 0.2.2.448__py3-none-any.whl → 0.2.2.449__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 abstract-utilities might be problematic. Click here for more details.
- abstract_utilities/__init__.py +43 -17
- abstract_utilities/abstract_classes.py +0 -49
- abstract_utilities/class_utils.py +3 -39
- abstract_utilities/cmd_utils/user_utils.py +1 -1
- abstract_utilities/{compare_utils/compare_utils.py → compare_utils.py} +1 -1
- abstract_utilities/dynimport.py +15 -7
- abstract_utilities/json_utils.py +0 -35
- abstract_utilities/log_utils.py +3 -14
- abstract_utilities/path_utils.py +6 -90
- abstract_utilities/read_write_utils.py +156 -99
- abstract_utilities/robust_reader/__init__.py +1 -1
- abstract_utilities/{file_utils/file_utils → robust_reader}/file_reader.py +19 -5
- abstract_utilities/{file_utils/file_utils → robust_reader}/pdf_utils.py +9 -1
- abstract_utilities/robust_readers/__init__.py +1 -0
- abstract_utilities/{file_utils/file_utils/file_utils.py → robust_readers/file_filters.py} +1 -2
- abstract_utilities/{file_utils/file_utils → robust_readers}/filter_params.py +38 -1
- abstract_utilities/robust_readers/initFuncGen.py +74 -82
- abstract_utilities/type_utils.py +1 -0
- {abstract_utilities-0.2.2.448.dist-info → abstract_utilities-0.2.2.449.dist-info}/METADATA +4 -15
- abstract_utilities-0.2.2.449.dist-info/RECORD +49 -0
- {abstract_utilities-0.2.2.448.dist-info → abstract_utilities-0.2.2.449.dist-info}/WHEEL +1 -1
- abstract_utilities/cmd_utils/imports/__init__.py +0 -1
- abstract_utilities/cmd_utils/imports/imports.py +0 -10
- abstract_utilities/cmd_utils/pexpect_utils.py +0 -310
- abstract_utilities/compare_utils/__init__.py +0 -3
- abstract_utilities/compare_utils/best_match.py +0 -150
- abstract_utilities/compare_utils/find_value.py +0 -105
- abstract_utilities/env_utils/__init__.py +0 -3
- abstract_utilities/env_utils/abstractEnv.py +0 -129
- abstract_utilities/env_utils/envy_it.py +0 -33
- abstract_utilities/env_utils/imports/__init__.py +0 -2
- abstract_utilities/env_utils/imports/imports.py +0 -8
- abstract_utilities/env_utils/imports/utils.py +0 -122
- abstract_utilities/file_utils/__init__.py +0 -3
- abstract_utilities/file_utils/file_utils/__init__.py +0 -6
- abstract_utilities/file_utils/file_utils/file_filters.py +0 -104
- abstract_utilities/file_utils/file_utils/imports.py +0 -1
- abstract_utilities/file_utils/file_utils/map_utils.py +0 -29
- abstract_utilities/file_utils/imports/__init__.py +0 -5
- abstract_utilities/file_utils/imports/classes.py +0 -381
- abstract_utilities/file_utils/imports/constants.py +0 -39
- abstract_utilities/file_utils/imports/file_functions.py +0 -10
- abstract_utilities/file_utils/imports/imports.py +0 -14
- abstract_utilities/file_utils/imports/module_imports.py +0 -9
- abstract_utilities/file_utils/req.py +0 -329
- abstract_utilities/robust_reader/imports/__init__.py +0 -1
- abstract_utilities/robust_reader/imports/imports.py +0 -12
- abstract_utilities/robust_readers/imports.py +0 -8
- abstract_utilities/safe_utils.py +0 -133
- abstract_utilities/ssh_utils/__init__.py +0 -3
- abstract_utilities/ssh_utils/classes.py +0 -127
- abstract_utilities/ssh_utils/imports.py +0 -10
- abstract_utilities/ssh_utils/pexpect_utils.py +0 -315
- abstract_utilities/ssh_utils/utils.py +0 -188
- abstract_utilities/string_utils.py +0 -12
- abstract_utilities-0.2.2.448.dist-info/RECORD +0 -83
- {abstract_utilities-0.2.2.448.dist-info → abstract_utilities-0.2.2.449.dist-info}/top_level.txt +0 -0
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
from .classes import *
|
|
2
|
-
from .utils import *
|
|
3
|
-
from ..env_utils import *
|
|
4
|
-
# pexpect is optional; import lazily if you prefer
|
|
5
|
-
|
|
6
|
-
# keep your execute_cmd; add a thin wrapper that supports stdin text cleanly
|
|
7
|
-
def execute_cmd_input(
|
|
8
|
-
*args,
|
|
9
|
-
input_text: str | None = None,
|
|
10
|
-
outfile: str | None = None,
|
|
11
|
-
**kwargs
|
|
12
|
-
) -> str:
|
|
13
|
-
"""
|
|
14
|
-
Like execute_cmd, but lets you pass text to stdin (subprocess.run(input=...)).
|
|
15
|
-
"""
|
|
16
|
-
if input_text is not None:
|
|
17
|
-
kwargs["input"] = input_text
|
|
18
|
-
# ensure text mode so Python passes str not bytes
|
|
19
|
-
kwargs.setdefault("text", True)
|
|
20
|
-
return execute_cmd(*args, outfile=outfile, **kwargs)
|
|
21
|
-
|
|
22
|
-
# -------------------------
|
|
23
|
-
# Core: capture + printing
|
|
24
|
-
# -------------------------
|
|
25
|
-
def exec_sudo_capture(
|
|
26
|
-
cmd: str,
|
|
27
|
-
*,
|
|
28
|
-
password: str | None = None,
|
|
29
|
-
key: str | None = None,
|
|
30
|
-
user_at_host: str | None = None,
|
|
31
|
-
cwd: str | None = None,
|
|
32
|
-
print_output: bool = False,
|
|
33
|
-
) -> str:
|
|
34
|
-
"""
|
|
35
|
-
Run a sudo command and return its output (no temp file).
|
|
36
|
-
"""
|
|
37
|
-
if password is None:
|
|
38
|
-
password = get_env_value(key=key) if key else get_sudo_password()
|
|
39
|
-
password = f"{password}\n" if password else password
|
|
40
|
-
sudo_cmd = f"sudo -S -k {cmd}"
|
|
41
|
-
|
|
42
|
-
if user_at_host:
|
|
43
|
-
# build the remote command (bash -lc + optional cd)
|
|
44
|
-
remote = get_remote_cmd(cmd=sudo_cmd, user_at_host=user_at_host, cwd=cwd)
|
|
45
|
-
# feed password to remote's stdin (ssh forwards stdin)
|
|
46
|
-
out = execute_cmd_input(remote, input_text=password,
|
|
47
|
-
shell=True, text=True, capture_output=True)
|
|
48
|
-
else:
|
|
49
|
-
out = execute_cmd_input(sudo_cmd, input_text=password,
|
|
50
|
-
shell=True, text=True, capture_output=True, cwd=cwd)
|
|
51
|
-
|
|
52
|
-
if print_output:
|
|
53
|
-
print_cmd(cmd, out or "")
|
|
54
|
-
return out or ""
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
# ---------------------------------------------------
|
|
59
|
-
# SUDO helpers (local + SSH) with env/password options
|
|
60
|
-
# ---------------------------------------------------
|
|
61
|
-
def exec_sudo(
|
|
62
|
-
cmd: str,
|
|
63
|
-
*,
|
|
64
|
-
password: Optional[str] = None,
|
|
65
|
-
key: Optional[str] = None,
|
|
66
|
-
user_at_host: Optional[str] = None,
|
|
67
|
-
cwd: Optional[str] = None,
|
|
68
|
-
outfile: Optional[str] = None,
|
|
69
|
-
print_output: bool = False,
|
|
70
|
-
) -> str:
|
|
71
|
-
"""
|
|
72
|
-
Execute `cmd` via sudo either locally or on remote.
|
|
73
|
-
Password order of precedence:
|
|
74
|
-
1) `password` arg
|
|
75
|
-
2) `key` -> get_env_value(key)
|
|
76
|
-
3) get_sudo_password()
|
|
77
|
-
|
|
78
|
-
Uses: sudo -S -k (-S read password from stdin, -k invalidate cached timestamp)
|
|
79
|
-
"""
|
|
80
|
-
if password is None:
|
|
81
|
-
if key:
|
|
82
|
-
password = get_env_value(key=key)
|
|
83
|
-
else:
|
|
84
|
-
password = get_sudo_password()
|
|
85
|
-
|
|
86
|
-
# Compose the sudo command that reads from stdin
|
|
87
|
-
sudo_cmd = f"sudo -S -k {cmd}"
|
|
88
|
-
|
|
89
|
-
if user_at_host:
|
|
90
|
-
# For remote: the password is piped to SSH stdin, which flows to remote sudo's stdin.
|
|
91
|
-
remote = get_remote_cmd(cmd=sudo_cmd, user_at_host=user_at_host, cwd=cwd)
|
|
92
|
-
full = f"printf %s {shlex.quote(password)} | {remote}"
|
|
93
|
-
out = execute_cmd(full, shell=True, text=True, capture_output=True, outfile=outfile)
|
|
94
|
-
else:
|
|
95
|
-
# Local
|
|
96
|
-
full = f"printf %s {shlex.quote(password)} | {sudo_cmd}"
|
|
97
|
-
out = execute_cmd(full, shell=True, text=True, capture_output=True, outfile=outfile)
|
|
98
|
-
|
|
99
|
-
if print_output:
|
|
100
|
-
print_cmd(cmd, out or "")
|
|
101
|
-
return out or ""
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
# -------------------------------------------------
|
|
105
|
-
# Fire-and-forget (file-backed) compatible runner
|
|
106
|
-
# -------------------------------------------------
|
|
107
|
-
def cmd_run(
|
|
108
|
-
cmd: str,
|
|
109
|
-
output_text: str | None = None,
|
|
110
|
-
print_output: bool = False,
|
|
111
|
-
*,
|
|
112
|
-
user_at_host: str | None = None,
|
|
113
|
-
cwd: str | None = None,
|
|
114
|
-
) -> str | None:
|
|
115
|
-
"""
|
|
116
|
-
If output_text is None → capture+return output (no file).
|
|
117
|
-
If output_text is provided → legacy file-backed behavior.
|
|
118
|
-
"""
|
|
119
|
-
if output_text is None:
|
|
120
|
-
# capture mode
|
|
121
|
-
if user_at_host:
|
|
122
|
-
remote = get_remote_cmd(cmd=cmd, user_at_host=user_at_host, cwd=cwd)
|
|
123
|
-
out = execute_cmd(remote, shell=True, text=True, capture_output=True)
|
|
124
|
-
else:
|
|
125
|
-
out = execute_cmd(cmd, shell=True, text=True, capture_output=True, cwd=cwd)
|
|
126
|
-
## if print_output:
|
|
127
|
-
## print_cmd(cmd, out or "")
|
|
128
|
-
return out or ""
|
|
129
|
-
|
|
130
|
-
# ---- legacy file-backed path (unchanged in spirit) ----
|
|
131
|
-
# Clear output file
|
|
132
|
-
with open(output_text, 'w'):
|
|
133
|
-
pass
|
|
134
|
-
|
|
135
|
-
# Append redirection + sentinel
|
|
136
|
-
full_cmd = f'{cmd} >> {output_text}; echo END_OF_CMD >> {output_text}'
|
|
137
|
-
|
|
138
|
-
# Execute local/remote
|
|
139
|
-
if user_at_host:
|
|
140
|
-
remote_line = get_remote_cmd(cmd=full_cmd, user_at_host=user_at_host, cwd=cwd)
|
|
141
|
-
subprocess.call(remote_line, shell=True)
|
|
142
|
-
else:
|
|
143
|
-
subprocess.call(full_cmd, shell=True, cwd=cwd)
|
|
144
|
-
|
|
145
|
-
# Wait for sentinel
|
|
146
|
-
while True:
|
|
147
|
-
get_sleep(sleep_timer=0.5)
|
|
148
|
-
with open(output_text, 'r') as f:
|
|
149
|
-
lines = f.readlines()
|
|
150
|
-
if lines and lines[-1].strip() == 'END_OF_CMD':
|
|
151
|
-
break
|
|
152
|
-
|
|
153
|
-
## if print_output:
|
|
154
|
-
## print(full_cmd)
|
|
155
|
-
## with open(output_text, 'r') as f:
|
|
156
|
-
## print_cmd(full_cmd, f.read().strip())
|
|
157
|
-
|
|
158
|
-
try:
|
|
159
|
-
os.remove(output_text)
|
|
160
|
-
except OSError:
|
|
161
|
-
pass
|
|
162
|
-
|
|
163
|
-
return None
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
# ----------------------------------------------------
|
|
167
|
-
# pexpect wrappers (local + SSH) for interactive flows
|
|
168
|
-
# ----------------------------------------------------
|
|
169
|
-
def exec_expect(
|
|
170
|
-
command: str,
|
|
171
|
-
child_runs: List[Dict[str, Any]],
|
|
172
|
-
*,
|
|
173
|
-
user_at_host: Optional[str] = None,
|
|
174
|
-
cwd: Optional[str] = None,
|
|
175
|
-
print_output: bool = False,
|
|
176
|
-
) -> int:
|
|
177
|
-
"""
|
|
178
|
-
Run `command` and answer interactive prompts.
|
|
179
|
-
|
|
180
|
-
child_runs: list of dicts like:
|
|
181
|
-
{ "prompt": r"Password:", "pass": "xyz" }
|
|
182
|
-
{ "prompt": r"Enter passphrase:", "key": "MY_KEY", "env_path": "/path/for/.env" }
|
|
183
|
-
If "pass" is None, we resolve via get_env_value(key=..., start_path=env_path).
|
|
184
|
-
|
|
185
|
-
Returns exitstatus (0=success).
|
|
186
|
-
"""
|
|
187
|
-
if user_at_host:
|
|
188
|
-
# Wrap command for remote execution
|
|
189
|
-
remote_line = get_remote_cmd(cmd=command, user_at_host=user_at_host, cwd=cwd)
|
|
190
|
-
spawn_cmd = f"{remote_line}"
|
|
191
|
-
else:
|
|
192
|
-
spawn_cmd = f"bash -lc {shlex.quote((f'cd {shlex.quote(cwd)} && {command}') if cwd else command)}"
|
|
193
|
-
|
|
194
|
-
child = pexpect.spawn(spawn_cmd)
|
|
195
|
-
|
|
196
|
-
for each in child_runs:
|
|
197
|
-
child.expect(each["prompt"])
|
|
198
|
-
|
|
199
|
-
if each.get("pass") is not None:
|
|
200
|
-
pass_phrase = each["pass"]
|
|
201
|
-
else:
|
|
202
|
-
args = {}
|
|
203
|
-
if "key" in each and each["key"] is not None:
|
|
204
|
-
args["key"] = each["key"]
|
|
205
|
-
if "env_path" in each and each["env_path"] is not None:
|
|
206
|
-
args["start_path"] = each["env_path"]
|
|
207
|
-
pass_phrase = get_env_value(**args)
|
|
208
|
-
|
|
209
|
-
child.sendline(pass_phrase)
|
|
210
|
-
if print_output:
|
|
211
|
-
print("Answered prompt:", each["prompt"])
|
|
212
|
-
|
|
213
|
-
child.expect(pexpect.EOF)
|
|
214
|
-
out = child.before.decode("utf-8", errors="ignore")
|
|
215
|
-
## if print_output:
|
|
216
|
-
## print_cmd(command, out)
|
|
217
|
-
|
|
218
|
-
return child.exitstatus if child.exitstatus is not None else 0
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
# ---------------------------------------
|
|
222
|
-
# Convenience shims to mirror your names
|
|
223
|
-
# ---------------------------------------
|
|
224
|
-
def cmd_run_sudo(
|
|
225
|
-
cmd: str,
|
|
226
|
-
password: str | None = None,
|
|
227
|
-
key: str | None = None,
|
|
228
|
-
output_text: str | None = None,
|
|
229
|
-
*,
|
|
230
|
-
user_at_host: str | None = None,
|
|
231
|
-
cwd: str | None = None,
|
|
232
|
-
print_output: bool = False,
|
|
233
|
-
) -> str | None:
|
|
234
|
-
"""
|
|
235
|
-
If output_text is None → capture sudo output and return it.
|
|
236
|
-
If output_text is provided → legacy file-backed behavior feeding sudo via stdin.
|
|
237
|
-
"""
|
|
238
|
-
if output_text is None:
|
|
239
|
-
return exec_sudo_capture(
|
|
240
|
-
cmd,
|
|
241
|
-
password=password,
|
|
242
|
-
key=key,
|
|
243
|
-
user_at_host=user_at_host,
|
|
244
|
-
cwd=cwd,
|
|
245
|
-
print_output=print_output,
|
|
246
|
-
)
|
|
247
|
-
|
|
248
|
-
# ---- legacy file-backed path ----
|
|
249
|
-
# build the underlying sudo command
|
|
250
|
-
sudo_cmd = f"sudo -S -k {cmd}"
|
|
251
|
-
pw = password if password is not None else (get_env_value(key=key) if key else get_sudo_password())
|
|
252
|
-
|
|
253
|
-
# We need to feed password to stdin in the same shell that runs sudo.
|
|
254
|
-
# For file-backed mode we’ll inline a small shell that reads from a here-string.
|
|
255
|
-
# Local:
|
|
256
|
-
if not user_at_host:
|
|
257
|
-
full = f'bash -lc {shlex.quote((f"cd {shlex.quote(cwd)} && " if cwd else "") + f"printf %s {shlex.quote(pw)} | {sudo_cmd}")}'
|
|
258
|
-
return cmd_run(full, output_text=output_text, print_output=print_output)
|
|
259
|
-
# Remote:
|
|
260
|
-
# On remote, do the same in the remote bash -lc
|
|
261
|
-
remote_sudo_line = f'printf %s {shlex.quote(pw)} | {sudo_cmd}'
|
|
262
|
-
remote_full = get_remote_cmd(cmd=remote_sudo_line, user_at_host=user_at_host, cwd=cwd)
|
|
263
|
-
return cmd_run(remote_full, output_text=output_text, print_output=print_output)
|
|
264
|
-
|
|
265
|
-
def pexpect_cmd_with_args(
|
|
266
|
-
command: str,
|
|
267
|
-
child_runs: list,
|
|
268
|
-
output_text: str | None = None,
|
|
269
|
-
*,
|
|
270
|
-
user_at_host: str | None = None,
|
|
271
|
-
cwd: str | None = None,
|
|
272
|
-
print_output: bool = False
|
|
273
|
-
) -> int:
|
|
274
|
-
"""
|
|
275
|
-
If output_text is None → return output string via print_output, else write to file then remove (legacy).
|
|
276
|
-
"""
|
|
277
|
-
if user_at_host:
|
|
278
|
-
spawn_cmd = get_remote_cmd(cmd=command, user_at_host=user_at_host, cwd=cwd)
|
|
279
|
-
else:
|
|
280
|
-
spawn_cmd = f"bash -lc {shlex.quote((f'cd {shlex.quote(cwd)} && {command}') if cwd else command)}"
|
|
281
|
-
|
|
282
|
-
child = pexpect.spawn(spawn_cmd)
|
|
283
|
-
|
|
284
|
-
for each in child_runs:
|
|
285
|
-
child.expect(each["prompt"])
|
|
286
|
-
if each.get("pass") is not None:
|
|
287
|
-
pass_phrase = each["pass"]
|
|
288
|
-
else:
|
|
289
|
-
args = {}
|
|
290
|
-
if "key" in each and each["key"] is not None:
|
|
291
|
-
args["key"] = each["key"]
|
|
292
|
-
if "env_path" in each and each["env_path"] is not None:
|
|
293
|
-
args["start_path"] = each["env_path"]
|
|
294
|
-
pass_phrase = get_env_value(**args)
|
|
295
|
-
child.sendline(pass_phrase)
|
|
296
|
-
if print_output:
|
|
297
|
-
print("Answered prompt:", each["prompt"])
|
|
298
|
-
|
|
299
|
-
child.expect(pexpect.EOF)
|
|
300
|
-
out = child.before.decode("utf-8", errors="ignore")
|
|
301
|
-
|
|
302
|
-
if output_text:
|
|
303
|
-
with open(output_text, "w") as f:
|
|
304
|
-
f.write(out)
|
|
305
|
-
if print_output:
|
|
306
|
-
print_cmd(command, out)
|
|
307
|
-
# keep legacy? your old code removed the file; here we’ll keep it (safer).
|
|
308
|
-
# If you want the old behavior, uncomment:
|
|
309
|
-
# os.remove(output_text)
|
|
310
|
-
else:
|
|
311
|
-
if print_output:
|
|
312
|
-
print_cmd(command, out)
|
|
313
|
-
|
|
314
|
-
return child.exitstatus if child.exitstatus is not None else 0
|
|
315
|
-
cmd_input = execute_cmd_input
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
from .imports import *
|
|
2
|
-
def get_pass_from_key(key=None,env_path=None):
|
|
3
|
-
if key:
|
|
4
|
-
return get_env_value(key=key,path=env_path)
|
|
5
|
-
def get_password(password=None,key=None,env_path=None):
|
|
6
|
-
password = password or get_pass_from_key(key=key,env_path=env_path)
|
|
7
|
-
return password
|
|
8
|
-
|
|
9
|
-
def get_print_sudo_cmd(
|
|
10
|
-
cmd: str,
|
|
11
|
-
password=None,
|
|
12
|
-
key=None,
|
|
13
|
-
env_path=None
|
|
14
|
-
):
|
|
15
|
-
password = get_password(password=password,key=key,env_path=env_path)
|
|
16
|
-
if password != None:
|
|
17
|
-
|
|
18
|
-
cmd = get_password_cmd(password=password,cmd=cmd)
|
|
19
|
-
return cmd
|
|
20
|
-
def get_password_cmd(password:str,cmd:str):
|
|
21
|
-
sudo_cmd = get_sudo_cmd(cmd)
|
|
22
|
-
password_sudo_cmd = get_raw_password_sudo_cmd(password=password,sudo_cmd=sudo_cmd)
|
|
23
|
-
return password_sudo_cmd
|
|
24
|
-
def get_sudo_cmd(cmd: str):
|
|
25
|
-
return f"sudo -S -k {cmd}"
|
|
26
|
-
def get_raw_password_sudo_cmd(password:str,sudo_cmd:str):
|
|
27
|
-
return f"printf %s {shlex.quote(password)} | {sudo_cmd}"
|
|
28
|
-
def get_remote_bash(
|
|
29
|
-
cmd: str,
|
|
30
|
-
cwd: str | None = None
|
|
31
|
-
):
|
|
32
|
-
return f"bash -lc {shlex.quote((f'cd {shlex.quote(cwd)} && {cmd}') if cwd else cmd)}"
|
|
33
|
-
def get_remote_ssh(
|
|
34
|
-
user_at_host: str=None,
|
|
35
|
-
remote:str=None
|
|
36
|
-
):
|
|
37
|
-
return f"ssh {shlex.quote(user_at_host)} {shlex.quote(remote)}"
|
|
38
|
-
def get_remote_cmd(
|
|
39
|
-
cmd: str,
|
|
40
|
-
user_at_host: str,
|
|
41
|
-
cwd: str | None = None,
|
|
42
|
-
password=None,
|
|
43
|
-
key=None,
|
|
44
|
-
env_path=None
|
|
45
|
-
|
|
46
|
-
):
|
|
47
|
-
cmd = get_print_sudo_cmd(
|
|
48
|
-
cmd=cmd,
|
|
49
|
-
password=password,
|
|
50
|
-
key=key,
|
|
51
|
-
env_path=env_path
|
|
52
|
-
)
|
|
53
|
-
remote = get_remote_bash(
|
|
54
|
-
cmd=cmd,
|
|
55
|
-
cwd=cwd
|
|
56
|
-
)
|
|
57
|
-
full = get_remote_ssh(
|
|
58
|
-
user_at_host=user_at_host,
|
|
59
|
-
remote=remote
|
|
60
|
-
)
|
|
61
|
-
return full
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def execute_cmd(
|
|
65
|
-
*args,
|
|
66
|
-
outfile=None,
|
|
67
|
-
**kwargs
|
|
68
|
-
) -> str:
|
|
69
|
-
proc = subprocess.run(*args, **kwargs)
|
|
70
|
-
output = (proc.stdout or "") + (proc.stderr or "")
|
|
71
|
-
if outfile:
|
|
72
|
-
try:
|
|
73
|
-
with open(outfile, "w", encoding="utf-8", errors="ignore") as f:
|
|
74
|
-
f.write(output)
|
|
75
|
-
except Exception:
|
|
76
|
-
pass
|
|
77
|
-
return output
|
|
78
|
-
|
|
79
|
-
def run_local_cmd(
|
|
80
|
-
cmd: str,
|
|
81
|
-
cwd: str | None = None,
|
|
82
|
-
outfile: Optional[str] = None,
|
|
83
|
-
shell=True,
|
|
84
|
-
text=True,
|
|
85
|
-
capture_output=True,
|
|
86
|
-
user_at_host: str=None,
|
|
87
|
-
password=None,
|
|
88
|
-
key=None,
|
|
89
|
-
env_path=None
|
|
90
|
-
) -> str:
|
|
91
|
-
cmd = get_print_sudo_cmd(
|
|
92
|
-
cmd=cmd,
|
|
93
|
-
password=password,
|
|
94
|
-
key=key,
|
|
95
|
-
env_path=env_path
|
|
96
|
-
)
|
|
97
|
-
return execute_cmd(
|
|
98
|
-
cmd,
|
|
99
|
-
outfile=outfile,
|
|
100
|
-
shell=shell,
|
|
101
|
-
cwd=cwd,
|
|
102
|
-
text=text,
|
|
103
|
-
capture_output=capture_output
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
def run_remote_cmd(
|
|
107
|
-
user_at_host: str,
|
|
108
|
-
cmd: str,
|
|
109
|
-
cwd: str | None = None,
|
|
110
|
-
outfile: Optional[str] = None,
|
|
111
|
-
shell=True,
|
|
112
|
-
text=True,
|
|
113
|
-
capture_output=True,
|
|
114
|
-
password=None,
|
|
115
|
-
key=None,
|
|
116
|
-
env_path=None
|
|
117
|
-
) -> str:
|
|
118
|
-
"""
|
|
119
|
-
Run on remote via SSH; capture stdout+stderr locally; write to local outfile.
|
|
120
|
-
NOTE: we do *not* try to write the file on the remote to avoid later scp.
|
|
121
|
-
"""
|
|
122
|
-
cmd = get_print_sudo_cmd(
|
|
123
|
-
cmd=cmd,
|
|
124
|
-
password=password,
|
|
125
|
-
key=key,
|
|
126
|
-
env_path=env_path
|
|
127
|
-
)
|
|
128
|
-
# wrap in bash -lc for PATH/profile + allow 'cd && ...'
|
|
129
|
-
cmd = get_remote_cmd(
|
|
130
|
-
cmd=cmd,
|
|
131
|
-
user_at_host=user_at_host,
|
|
132
|
-
cwd=cwd
|
|
133
|
-
)
|
|
134
|
-
return execute_cmd(
|
|
135
|
-
cmd,
|
|
136
|
-
outfile=outfile,
|
|
137
|
-
shell=shell,
|
|
138
|
-
text=text,
|
|
139
|
-
capture_output=capture_output
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
def run_cmd(
|
|
143
|
-
cmd: str=None,
|
|
144
|
-
cwd: str | None = None,
|
|
145
|
-
outfile: Optional[str] = None,
|
|
146
|
-
shell=True,
|
|
147
|
-
text=True,
|
|
148
|
-
capture_output=True,
|
|
149
|
-
user_at_host: str=None,
|
|
150
|
-
password=None,
|
|
151
|
-
key=None,
|
|
152
|
-
env_path=None
|
|
153
|
-
) -> str:
|
|
154
|
-
|
|
155
|
-
if user_at_host:
|
|
156
|
-
return run_ssh_cmd(
|
|
157
|
-
user_at_host=user_at_host,
|
|
158
|
-
cmd=cmd,
|
|
159
|
-
cwd=cwd,
|
|
160
|
-
outfile=outfile,
|
|
161
|
-
shell=shell,
|
|
162
|
-
text=text,
|
|
163
|
-
capture_output=capture_output,
|
|
164
|
-
password=password,
|
|
165
|
-
key=key,
|
|
166
|
-
env_path=env_path
|
|
167
|
-
)
|
|
168
|
-
return run_local_cmd(
|
|
169
|
-
cmd=cmd,
|
|
170
|
-
cwd=cwd,
|
|
171
|
-
outfile=outfile,
|
|
172
|
-
shell=shell,
|
|
173
|
-
text=text,
|
|
174
|
-
capture_output=capture_output,
|
|
175
|
-
password=password,
|
|
176
|
-
key=key,
|
|
177
|
-
env_path=env_path
|
|
178
|
-
)
|
|
179
|
-
run_ssh_cmd = run_remote_cmd
|
|
180
|
-
remote_cmd = run_remote_cmd
|
|
181
|
-
ssh_cmd = run_remote_cmd
|
|
182
|
-
|
|
183
|
-
local_cmd = run_local_cmd
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
run_any_cmd = run_cmd
|
|
187
|
-
any_cmd = run_cmd
|
|
188
|
-
cmd_run = run_cmd
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
def get_lines(string,strip=True):
|
|
2
|
-
lines = string.split('\n')
|
|
3
|
-
if strip:
|
|
4
|
-
lines = [line for line in lines if line]
|
|
5
|
-
return lines
|
|
6
|
-
def get_alpha():
|
|
7
|
-
return 'abcdefghijklmnopqrstuvwxyz'
|
|
8
|
-
def is_alpha(char,case_sensative=False):
|
|
9
|
-
alphas = get_alpha()
|
|
10
|
-
if not case_sensative:
|
|
11
|
-
alphas+=alphas.upper()
|
|
12
|
-
return char in alphas
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
abstract_utilities/__init__.py,sha256=aLWUTfocuGa7qoz3Czzvuz0xUNoy7DojHhp2MN5vyPk,5198
|
|
2
|
-
abstract_utilities/abstract_classes.py,sha256=A6-FNDQb2P_jcyt01Kc5SuY2QawLVKNjQ-rDGfsn4rA,2461
|
|
3
|
-
abstract_utilities/class_utils.py,sha256=YMQgeTHSMo2C13G0JRgQIgbx131jb-PHdDrIqt71FsE,13664
|
|
4
|
-
abstract_utilities/collator_utils.py,sha256=9exNoZAr9rABGYTwZOn7hdLbpnMtRd2AgfU7yjZrXGw,2348
|
|
5
|
-
abstract_utilities/doit.py,sha256=a1zkyMJbSGPvE-OmCQcH_dQyLME392UfvQmGztOWyhE,1646
|
|
6
|
-
abstract_utilities/dynimport.py,sha256=BTX33OXfUq4LAuT1RAzLhbtxqf7CTm5WHYdvVAH83nc,6584
|
|
7
|
-
abstract_utilities/error_utils.py,sha256=dSMIM3TKe4e9i_akObyjDwy3Zu4fnoWRK9hucg_ryZo,890
|
|
8
|
-
abstract_utilities/global_utils.py,sha256=UkCS1nE561bVbxWsH-YQdFPSeZFMYXV7xg-DAtGUvrI,2204
|
|
9
|
-
abstract_utilities/hash_utils.py,sha256=u7t209ERD9aGONZHqmkYtiQRRadD2qG5ICSTxlYlZMc,206
|
|
10
|
-
abstract_utilities/history_utils.py,sha256=2bG8hMSRzLWMae4mpd2sf1esYtqT2D_3MDxeJnAE2Jw,1633
|
|
11
|
-
abstract_utilities/json_utils.py,sha256=YA4zoBRAsVjdU-BjFd1L5z81Y5X-NuwKrQW5L992EY4,27609
|
|
12
|
-
abstract_utilities/list_utils.py,sha256=i1fZ_kZ0mf_ei6w0MOkuEieRiyF-ReeAXzIdoRI1cvo,6298
|
|
13
|
-
abstract_utilities/log_utils.py,sha256=W74Y-CmdQP4Kj88HmAgejVxWgyWlvgCKMwLvOfyFf9c,9393
|
|
14
|
-
abstract_utilities/math_utils.py,sha256=0o1ls1En03UAkYmxTBildCCJDfHygmNuvVnrNrLYtK0,6578
|
|
15
|
-
abstract_utilities/parse_utils.py,sha256=Z5OGRwHuzCzY91fz0JJojk1BPAo1XF2quNNLuBF4_Vk,18602
|
|
16
|
-
abstract_utilities/path_utils.py,sha256=X_U9cPBbNu5Wi0F3hQE0gXQX1gfhzxhxALbairTEOZU,19252
|
|
17
|
-
abstract_utilities/read_write_utils.py,sha256=oPmY0UZSuEkV_ox8inZiSG_adYGm6J9n6-lgFNytdi0,4470
|
|
18
|
-
abstract_utilities/safe_utils.py,sha256=_uoZny6dJjopVakOiaf0UIZcvRRXMh51FpfDUooe0xY,3733
|
|
19
|
-
abstract_utilities/string_clean.py,sha256=-gY9i2yqjX5UClvSaKsSrzA4GjR7eaNI3GnFjZpt2bo,5923
|
|
20
|
-
abstract_utilities/string_utils.py,sha256=02xdIEDySWEexrtY3skBYOdeDmr3XgE5j1nqAeAv7w8,352
|
|
21
|
-
abstract_utilities/tetsts.py,sha256=PrejTUew5dAAqNb4erMJwfdSHxDyuuHGWY2fMlWk5hk,21
|
|
22
|
-
abstract_utilities/thread_utils.py,sha256=LhE1ylSuOKkkMErBf6SjZprjO_vfh3IKfvNKJQiCxho,5460
|
|
23
|
-
abstract_utilities/time_utils.py,sha256=yikMjn7i-OBKfmOujfNtDz4R0VTMgi3dfQNrCIZUbQU,13052
|
|
24
|
-
abstract_utilities/type_utils.py,sha256=1gpwfG5ze8dTUi7IXnMc65vHrw8XgI0F8m6x4esZavI,26977
|
|
25
|
-
abstract_utilities/utils.py,sha256=SCa_-x_wsWrcokQXKwlhalxndxLn5Wg25-zqRdJUmag,185049
|
|
26
|
-
abstract_utilities/cmd_utils/__init__.py,sha256=StTaaB9uzJexvr4TFGVqp_o0_s9T6rQlE3fOZtb_y_0,51
|
|
27
|
-
abstract_utilities/cmd_utils/cmd_utils.py,sha256=n2DEo91J8LWuIJoSoDkWdApUY_8mHrUW3kjEjjF34Io,7876
|
|
28
|
-
abstract_utilities/cmd_utils/pexpect_utils.py,sha256=u33BkeyQAiGlP81569a-iH95znRBmURM_cbN-nLlFAQ,10357
|
|
29
|
-
abstract_utilities/cmd_utils/user_utils.py,sha256=e1s-VPucZ_Ldg2LsXH-W3OQdh_X5vV8gU_-ARF2khsM,1829
|
|
30
|
-
abstract_utilities/cmd_utils/imports/__init__.py,sha256=mp6T1rBZdOzj0IDkvlteTqtyKJiOZaJTlgrjTdHO1Qw,23
|
|
31
|
-
abstract_utilities/cmd_utils/imports/imports.py,sha256=TmvKQJb02_bZBo4ANNtCADl42LSWaYaU-6nml51Tt9o,362
|
|
32
|
-
abstract_utilities/compare_utils/__init__.py,sha256=ay_tktzoXtj85IdVCGR6Pc6fLX_DR4Mg_Y_-sS5qcmY,120
|
|
33
|
-
abstract_utilities/compare_utils/best_match.py,sha256=XVf0cypM8u4Tp595k7r9jxeOkAXWjXrcGwcNFLEseMk,5160
|
|
34
|
-
abstract_utilities/compare_utils/compare_utils.py,sha256=1Bu8pQEOwLIzDpEmqfeBO7BDxMdcXuG2sVHqdd1IeK8,14034
|
|
35
|
-
abstract_utilities/compare_utils/find_value.py,sha256=_Jss3AvmwQMDLVlkgDPcp6tAXD4KnUbXjCR370sb1Xo,3349
|
|
36
|
-
abstract_utilities/env_utils/__init__.py,sha256=VIihpuDHrrI0CBj3kGN0ZcgxaGgoqBe4Be7q2Ks8IEw,73
|
|
37
|
-
abstract_utilities/env_utils/abstractEnv.py,sha256=01W7jkvZMmvdrcYIrZFd1-WFdcOULKc-SNAPF6FdyLM,6027
|
|
38
|
-
abstract_utilities/env_utils/envy_it.py,sha256=lGkTB3AOY1KTRfQgtJji_yjSVVt0FV9YTETZD7vhnM4,1353
|
|
39
|
-
abstract_utilities/env_utils/imports/__init__.py,sha256=LVIEQXKiAmaKKWxPxfSJKe7JGWi4RDt4eatm_VG-WUI,44
|
|
40
|
-
abstract_utilities/env_utils/imports/imports.py,sha256=ZrGEf-J2lyVbb4MrNBX3DwHR0o-frba52RbPkypNvao,355
|
|
41
|
-
abstract_utilities/env_utils/imports/utils.py,sha256=oB7WhIm_-cHLrUHRXypZGCdWUtNRyePaVO5_kq5Cv84,4490
|
|
42
|
-
abstract_utilities/file_utils/__init__.py,sha256=I4md5xU5nuBuKyxumvKmnrR0-UgBePX9QfY-QNS-Zso,101
|
|
43
|
-
abstract_utilities/file_utils/req.py,sha256=CsdGHAWIHOLqjzyoOSZ7XYbNciVYnTgaUs5qOCHttE0,11837
|
|
44
|
-
abstract_utilities/file_utils/file_utils/__init__.py,sha256=fm_uNRnfKfZOIg7e1HXhWbHac5VoUgRD2iTO5cxLkA0,160
|
|
45
|
-
abstract_utilities/file_utils/file_utils/file_filters.py,sha256=khfbonAPEAhW1wxfFo0I4dawYPCrIKEjNc7VKb1RvzA,3437
|
|
46
|
-
abstract_utilities/file_utils/file_utils/file_reader.py,sha256=2MRj2PGKq4C-iKL8dmhHwWnhmA8GPVsNaWkTREOF9vo,24545
|
|
47
|
-
abstract_utilities/file_utils/file_utils/file_utils.py,sha256=2aVuD0sB-P2gmo_kUsE11aHc6WzLvHUAerMkmy3y9vk,7751
|
|
48
|
-
abstract_utilities/file_utils/file_utils/filter_params.py,sha256=NF692W0cBhEsbtmaVzb8EKMAasasHDElSRaC9fnzYwE,3382
|
|
49
|
-
abstract_utilities/file_utils/file_utils/imports.py,sha256=SXCMBuHUwqXbfRBk4LjKehsBKZa8-Po5UfEcNTwn4Es,24
|
|
50
|
-
abstract_utilities/file_utils/file_utils/map_utils.py,sha256=B_MlkLP8s-o0yU0R3Y2LcTpBntBzysJO18qq181xz9c,1043
|
|
51
|
-
abstract_utilities/file_utils/file_utils/pdf_utils.py,sha256=D_wg8h-SapCvqinxRIKxMri1jWZNpr5jGvKq9EJePfY,10335
|
|
52
|
-
abstract_utilities/file_utils/imports/__init__.py,sha256=VWN_3t0gRSYCalXI0nRLEUB3O2kbqA_Y8wnFq_m5F7A,131
|
|
53
|
-
abstract_utilities/file_utils/imports/classes.py,sha256=zw16D_h5AxJiks4ydbqkWkXVfvgmE-BpiC4eKInY_KI,12259
|
|
54
|
-
abstract_utilities/file_utils/imports/constants.py,sha256=eIeSj48vtfa8CTYKuuZXbgJQepBrMracfVguaSuN41U,1626
|
|
55
|
-
abstract_utilities/file_utils/imports/file_functions.py,sha256=25yta20DDsdgenXYjpm4Ma3Fd6WK9Q16EjyhcZubDFg,291
|
|
56
|
-
abstract_utilities/file_utils/imports/imports.py,sha256=mrXR2rEpb12Wve91eQehSxwR-gqc_UxJnqBKTrf7hjU,538
|
|
57
|
-
abstract_utilities/file_utils/imports/module_imports.py,sha256=MD07dbYcES_M3vjBlgi-ltKNlaLnEBnIn0t0MpbRqOE,385
|
|
58
|
-
abstract_utilities/robust_reader/__init__.py,sha256=4i6qW4lwhdYuoO5-p9Xbt8Lpmr3hzCh9Rgb9y19QJwk,28
|
|
59
|
-
abstract_utilities/robust_reader/file_reader2.py,sha256=U-5opkLu-bct091Eb-5CiNBTf0UFoSITYi8zR-Sz38w,25077
|
|
60
|
-
abstract_utilities/robust_reader/file_readers.py,sha256=U-5opkLu-bct091Eb-5CiNBTf0UFoSITYi8zR-Sz38w,25077
|
|
61
|
-
abstract_utilities/robust_reader/sadfsad.py,sha256=gH2ebI9KfiYFv78jzPGk8WPST_FGtojnd_yDwrcvQoM,25282
|
|
62
|
-
abstract_utilities/robust_reader/imports/__init__.py,sha256=mp6T1rBZdOzj0IDkvlteTqtyKJiOZaJTlgrjTdHO1Qw,23
|
|
63
|
-
abstract_utilities/robust_reader/imports/imports.py,sha256=Dw5k9nPfDalmSZmt5mNfV38soBIsLJtsH5wmnQ6sbTI,459
|
|
64
|
-
abstract_utilities/robust_readers/__init__.py,sha256=_1vhOG1FJnfrRK0ubkT1v6U6udHMIk3qiy1qajL1IiM,55
|
|
65
|
-
abstract_utilities/robust_readers/imports.py,sha256=FtNxdPoLeeNycDnl-6rBGxBfYjhQ7VhmI5guj8XKFcU,355
|
|
66
|
-
abstract_utilities/robust_readers/initFuncGen.py,sha256=D3_JEJgSiMFPNAMVMcml6hceydTCYnvu_rG_z6n_Nd8,5217
|
|
67
|
-
abstract_utilities/robust_readers/import_utils/__init__.py,sha256=hKYj8irPXAN-gIm0frFd0_8fnUNQraWEVugRUrSjcLw,166
|
|
68
|
-
abstract_utilities/robust_readers/import_utils/dot_utils.py,sha256=pmwnY461mOnDjIjgHD6H9MhQXFaF-q8kWerJDgJ1DuI,2364
|
|
69
|
-
abstract_utilities/robust_readers/import_utils/function_utils.py,sha256=Q9NKvRov3uAaz2Aal3d6fb_opWNXHF9C8GSKOjgfO8Y,1622
|
|
70
|
-
abstract_utilities/robust_readers/import_utils/import_utils.py,sha256=l0GYdtj5FEYX2yknL-8ru7_U2Sp9Hi1NpegqWPLRMc8,11705
|
|
71
|
-
abstract_utilities/robust_readers/import_utils/impot_functions.py,sha256=1_pzkfgixRAzTzGnICcZi-4ocdkjpB0ENPCx96ET3LM,2499
|
|
72
|
-
abstract_utilities/robust_readers/import_utils/safe_import_utils.py,sha256=L-pwmWkV6eOkYNKA9c4QLTJ5v0DoWQu_v5HukCOo95w,2414
|
|
73
|
-
abstract_utilities/robust_readers/import_utils/sysroot_utils.py,sha256=f8hj20VA9yvvYkqQ9ecuBlzmTOaT5G7ni14QesDtdL0,2098
|
|
74
|
-
abstract_utilities/robust_readers/import_utils/utils.py,sha256=xyMObkdyvQAzAIv_kagLhFdkwSaPd4h0bCjTCYyfGhY,722
|
|
75
|
-
abstract_utilities/ssh_utils/__init__.py,sha256=-DxUpOmfMi5zdG3lu93uT9MziZ-I_anwWOg1XduBH6o,73
|
|
76
|
-
abstract_utilities/ssh_utils/classes.py,sha256=3Q9BfLpyagNFYyiF4bt-5UCezeUJv9NK9YAFdTsLCV0,4802
|
|
77
|
-
abstract_utilities/ssh_utils/imports.py,sha256=oX8WAv-pkhizzko_h3fIUp9Vhsse4nR7RN2vwONxIx0,317
|
|
78
|
-
abstract_utilities/ssh_utils/pexpect_utils.py,sha256=JBdOIXBTXAqE5TrsFjmPWJgwSaWyRJN8rbJ6y3_zKPY,10556
|
|
79
|
-
abstract_utilities/ssh_utils/utils.py,sha256=smUWAx3nW1h0etTndJ_te9bkUX5YzQ8kYd9_gD1TXLk,4882
|
|
80
|
-
abstract_utilities-0.2.2.448.dist-info/METADATA,sha256=6wUhVOtgJAuZaVwbOYO4pk5KFR0__I2q2qDfGt0QU50,28108
|
|
81
|
-
abstract_utilities-0.2.2.448.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
82
|
-
abstract_utilities-0.2.2.448.dist-info/top_level.txt,sha256=BF0GZ0xVFfN1K-hFIWPO3viNsOs1sSF86n1vHBg39FM,19
|
|
83
|
-
abstract_utilities-0.2.2.448.dist-info/RECORD,,
|
{abstract_utilities-0.2.2.448.dist-info → abstract_utilities-0.2.2.449.dist-info}/top_level.txt
RENAMED
|
File without changes
|