File tree 1 file changed +12
-15
lines changed
1 file changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -311,21 +311,18 @@ def VerTuple(version_str):
311
311
return ver
312
312
313
313
def CmdExists (cmd ):
314
- import platform
315
-
316
- cmd_list = cmd .split (' ' )
317
- cmd = cmd_list [0 ]
314
+ # Check if the path directly points to an existing file.
318
315
if os .path .isfile (cmd ):
319
316
return True
320
317
else :
321
- # check cmd(.exe|.bat|.ps1) under Windows
322
- if platform . system () == 'Windows' :
323
- if cmd . find ( 'exe' ) != - 1 or cmd . find ( 'bat' ) != - 1 or cmd . find ( 'ps1' ) != - 1 :
324
- return False
325
-
326
- # add .exe then check whether the cmd exists
327
- cmd = cmd + '.exe'
328
- if os . path . isfile ( cmd ):
329
- return True
330
-
331
- return False
318
+ # On Windows systems, check for common script file extensions
319
+ # if the file does not exist as specified.
320
+ if sys . platform . startswith ( 'win' ) :
321
+ # Loop through possible extensions to cover cases where the extension is omitted in the input.
322
+ for ext in [ '.exe' , '.bat' , '.ps1' ]:
323
+ # Append the extension to the command path and check if this file exists.
324
+ if os . path . isfile ( cmd + ext ):
325
+ return True
326
+
327
+ # If none of the checks confirm the file exists, return False.
328
+ return False
You can’t perform that action at this time.
0 commit comments