mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
passing pylint
This commit is contained in:
parent
3bf8dda2e5
commit
fa61bc361b
3 changed files with 20 additions and 27 deletions
|
@ -1192,7 +1192,7 @@ class Single:
|
|||
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')
|
||||
log.info('Detected kernel "{}" and architecture "{}" on target'.format(kernel, os_arch))
|
||||
|
||||
return kernel, os_arch
|
||||
|
||||
|
@ -1510,6 +1510,7 @@ class Single:
|
|||
self.args = mine_args
|
||||
self.kwargs = {}
|
||||
|
||||
retcode = 0
|
||||
try:
|
||||
if self.mine:
|
||||
result = wrapper[mine_fun](*self.args, **self.kwargs)
|
||||
|
|
|
@ -3227,7 +3227,7 @@ class SaltSSHOptionParser(
|
|||
"custom grains/modules/states have been added or updated."
|
||||
),
|
||||
)
|
||||
self.add_option(
|
||||
_ = self.add_option(
|
||||
"--relenv",
|
||||
dest="relenv",
|
||||
default=False,
|
||||
|
|
|
@ -32,7 +32,7 @@ def gen_relenv(
|
|||
os.makedirs(relenv_dir)
|
||||
|
||||
relenv_url = get_tarball(kernel, os_arch)
|
||||
tarball_path = os.path.join(relenv_dir, f"salt-relenv.tar.xz")
|
||||
tarball_path = os.path.join(relenv_dir, "salt-relenv.tar.xz")
|
||||
|
||||
# Download the tarball if it doesn't exist or overwrite is True
|
||||
if overwrite or not os.path.exists(tarball_path):
|
||||
|
@ -52,18 +52,18 @@ def get_tarball(kernel, arch):
|
|||
base_url = "https://repo.saltproject.io/salt/py3/onedir/latest/"
|
||||
try:
|
||||
# Request the page listing
|
||||
response = requests.get(base_url)
|
||||
response = requests.get(base_url, timeout=60)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as e:
|
||||
log.error(f"Failed to retrieve tarball listing: {e}")
|
||||
log.error("Failed to retrieve tarball listing: {}".format(e))
|
||||
raise ValueError("Unable to fetch tarball list from repository")
|
||||
|
||||
# Search for tarball filenames that match the kernel and arch
|
||||
pattern = re.compile(rf'href="(salt-.*-onedir-{kernel}-{arch}\.tar\.xz)"')
|
||||
matches = pattern.findall(response.text)
|
||||
if not matches:
|
||||
log.error(f"No tarballs found for {kernel} and {arch}")
|
||||
raise ValueError(f"No tarball found for {kernel} {arch}")
|
||||
log.error("No tarballs found for {} and {}".format(kernel, arch))
|
||||
raise ValueError("No tarball found for {} {}".format(kernel, arch))
|
||||
|
||||
# Return the latest tarball URL
|
||||
matches.sort()
|
||||
|
@ -76,24 +76,16 @@ def download(cachedir, url, destination):
|
|||
Download the salt artifact from the given destination to the cache.
|
||||
"""
|
||||
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:
|
||||
|
||||
def stream_callback(chunk):
|
||||
dest_file.write(chunk)
|
||||
|
||||
result = salt.utils.http.query(
|
||||
url=url,
|
||||
method="GET",
|
||||
stream=True,
|
||||
streaming_callback=stream_callback,
|
||||
raise_error=True,
|
||||
)
|
||||
if result.get("status") != 200:
|
||||
log.error(f"Failed to download file from {url}")
|
||||
return False
|
||||
except Exception as e:
|
||||
log.error(f"Error during file download: {e}")
|
||||
return False
|
||||
log.info("Downloading from {} to {}".format(url, destination))
|
||||
with salt.utils.files.fopen(destination, "wb+") as dest_file:
|
||||
result = salt.utils.http.query(
|
||||
url=url,
|
||||
method="GET",
|
||||
stream=True,
|
||||
streaming_callback=dest_file.write,
|
||||
raise_error=True,
|
||||
)
|
||||
if result.get("status") != 200:
|
||||
log.error("Failed to download file from {}".format(url))
|
||||
return False
|
||||
return True
|
||||
|
|
Loading…
Add table
Reference in a new issue