src/eric7/DebugClients/Python/DebugUtilities.py

branch
eric7-maintenance
changeset 11118
967a88a16a21
parent 11090
f5f5f5803935
diff -r c2cb561a39b0 -r 967a88a16a21 src/eric7/DebugClients/Python/DebugUtilities.py
--- a/src/eric7/DebugClients/Python/DebugUtilities.py	Sat Nov 30 11:09:02 2024 +0100
+++ b/src/eric7/DebugClients/Python/DebugUtilities.py	Tue Jan 14 17:29:56 2025 +0100
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2015 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
+# Copyright (c) 2015 - 2025 Detlev Offenbach <detlev@die-offenbachs.de>
 #
 
 """
@@ -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