src/eric7/DebugClients/Python/DebugUtilities.py

branch
eric7
changeset 11088
0299c9ba1c6f
parent 10551
d80184d38152
child 11090
f5f5f5803935
--- a/src/eric7/DebugClients/Python/DebugUtilities.py	Fri Dec 06 09:12:46 2024 +0100
+++ b/src/eric7/DebugClients/Python/DebugUtilities.py	Fri Dec 06 14:16:23 2024 +0100
@@ -9,6 +9,7 @@
 
 import json
 import os
+import shutil
 import sys
 import traceback
 
@@ -216,13 +217,16 @@
         return False
 
 
-def isPythonProgram(program):
+def isPythonProgram(program, withPath=False):
     """
     Function to check, if the given program is a Python interpreter or
     program.
 
     @param program program to be checked
     @type str
+    @param withPath flag indicating to search the program in the executable
+        search path (defaults to False)
+    @type bool (optional)
     @return flag indicating a Python interpreter or program
     @rtype bool
     """
@@ -233,6 +237,11 @@
     if any(pyname in prog for pyname in PYTHON_NAMES):
         return True
 
+    if withPath:
+        prog = shutil.which(program)
+        if prog:
+            program = prog
+
     return (
         not isWindowsPlatform() and isExecutable(program) and startsWithShebang(program)
     )
@@ -283,7 +292,7 @@
         return args
 
 
-def patchArguments(debugClient, arguments, noRedirect=False):
+def patchArguments(debugClient, arguments, noRedirect=False, isPythonProg=False):
     """
     Function to patch the arguments given to start a program in order to
     execute it in our debugger.
@@ -293,11 +302,14 @@
     @param arguments list of program arguments
     @type list of str
     @param noRedirect flag indicating to not redirect stdin and stdout
-    @type bool
+        (defaults to False)
+    @type bool (optional)
+    @param isPythonProg flag indicating a Python script (defaults to False)
+    @type bool (optional)
     @return modified argument list
     @rtype list of str
     """
-    if not isPythonProgram(arguments[0]):
+    if not (isPythonProg or isPythonProgram(arguments[0])):
         # it is not a Python program
         return arguments
 

eric ide

mercurial