Fix sudo 2 (#18738)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Glenn Jocher 2025-01-17 14:56:47 +01:00 committed by GitHub
parent 3672cb160e
commit 09a34b19ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -787,11 +787,12 @@ def is_sudo_available() -> bool:
Check if the sudo command is available in the environment.
Returns:
bool: True if the sudo command is available, False otherwise.
(bool): True if the sudo command is available, False otherwise.
"""
if WINDOWS:
return False
subprocess.run("sudo --version", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0
cmd = "sudo --version"
return subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0
# Run checks and define constants