only fallback if return code isnt 0

This commit is contained in:
Yoink3000
2024-07-12 23:04:30 +08:00
parent 72bd998539
commit f151cdc78d
+2 -2
View File
@@ -249,8 +249,8 @@ def pip(arg: str, ignore: bool = False, quiet: bool = False, uv = True):
result = subprocess.run(f'"{sys.executable}" -m {pipCmd} {all_args}', shell=True, check=False, env=os.environ, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
txt = result.stdout.decode(encoding="utf8", errors="ignore")
if len(result.stderr) > 0:
if uv:
log.warning(f'Cannot install with uv, fallback to pip')
if uv and result.returncode != 0:
log.warning('Cannot install with uv, fallback to pip')
return pip(originalArg, ignore, quiet, uv=False)
else:
txt += ('\n' if len(txt) > 0 else '') + result.stderr.decode(encoding="utf8", errors="ignore")