From 3a0837b74b1dc37363627f6a2f1ed2026ab933fa Mon Sep 17 00:00:00 2001 From: Alvin Wong Date: Thu, 25 Jul 2024 23:14:51 +0800 Subject: [PATCH] Windows/detect.py: Simplify try_cmd function --- platform/windows/detect.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 40a80670004..92b7a09278b 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -21,10 +21,14 @@ def get_name(): def try_cmd(test, prefix, arch): + archs = ["x86_64", "x86_32", "arm64", "arm32"] if arch: + archs = [arch] + + for a in archs: try: out = subprocess.Popen( - get_mingw_bin_prefix(prefix, arch) + test, + get_mingw_bin_prefix(prefix, a) + test, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE, @@ -34,20 +38,6 @@ def try_cmd(test, prefix, arch): return True except Exception: pass - else: - for a in ["x86_64", "x86_32", "arm64", "arm32"]: - try: - out = subprocess.Popen( - get_mingw_bin_prefix(prefix, a) + test, - shell=True, - stderr=subprocess.PIPE, - stdout=subprocess.PIPE, - ) - out.communicate() - if out.returncode == 0: - return True - except Exception: - pass return False