passing lint

This commit is contained in:
Tyler Levy Conde 2024-09-20 10:37:15 -06:00 committed by Daniel Wozniak
parent b5b5fb4f5c
commit b95855edf5
2 changed files with 22 additions and 12 deletions

View file

@ -1,5 +1,4 @@
"""
Create ssh executor system
"""
@ -196,7 +195,7 @@ EOF'''.format(
SSH_SH_SHIM_RELENV = "\n".join(
[
s.strip()
for s in '''
for s in """
/bin/sh << 'EOF'
set -e
set -u
@ -240,7 +239,9 @@ echo "{RSTR}" >&2
exec $SUDO "$SALT_CALL_BIN" --retcode-passthrough --local --metadata --out=json -lquiet -c "$RELENV_DIR" {ARGS}
EOF
'''.split("\n")
""".split(
"\n"
)
]
)
@ -1131,7 +1132,9 @@ class Single:
if self.opts.get("relenv"):
kernel, os_arch = self.detect_os_arch()
self.thin = salt.utils.relenv.gen_relenv(opts["cachedir"], kernel=kernel, os_arch=os_arch)
self.thin = salt.utils.relenv.gen_relenv(
opts["cachedir"], kernel=kernel, os_arch=os_arch
)
else:
self.thin = thin if thin else salt.utils.thin.thin_path(opts["cachedir"])
@ -1186,13 +1189,14 @@ class Single:
kernel = "windows"
else:
# Neither Unix nor Windows detection succeeded
raise ValueError(f"Failed to detect OS and architecture. Commands failed with output: {stdout}, {stderr}")
raise ValueError(
f"Failed to detect OS and architecture. Commands failed with output: {stdout}, {stderr}"
)
log.info(f'Detected kernel "{kernel}" and architecture "{os_arch}" on target')
return kernel, os_arch
def __arg_comps(self):
"""
Return the function name and the arg list
@ -1619,7 +1623,6 @@ ARGS = {arguments}\n'''.format(
py_code = SSH_PY_SHIM.replace("#%%OPTS", arg_str)
py_code_enc = base64.encodebytes(py_code.encode("utf-8")).decode("utf-8")
if not self.winrm:
cmd = SSH_SH_SHIM.format(
DEBUG=debug,

View file

@ -1,14 +1,17 @@
import os
import logging
import os
import re
import requests
import salt.utils.files
import salt.utils.hashutils
import salt.utils.http
import salt.utils.thin
import salt.utils.hashutils
log = logging.getLogger(__name__)
def gen_relenv(
cachedir,
kernel,
@ -38,6 +41,7 @@ def gen_relenv(
return tarball_path
def get_tarball(kernel, arch):
"""
Get the latest Salt onedir tarball URL for the specified kernel and architecture.
@ -66,19 +70,22 @@ def get_tarball(kernel, arch):
latest_tarball = matches[-1]
return base_url + latest_tarball
def download(cachedir, url, destination):
if not os.path.exists(destination):
log.info(f"Downloading from {url} to {destination}")
try:
with salt.utils.files.fopen(destination, 'wb+') as dest_file:
with salt.utils.files.fopen(destination, "wb+") as dest_file:
def stream_callback(chunk):
dest_file.write(chunk)
result = salt.utils.http.query(
url=url,
method='GET',
method="GET",
stream=True,
streaming_callback=stream_callback,
raise_error=True
raise_error=True,
)
if result.get("status") != 200:
log.error(f"Failed to download file from {url}")