14 from eric7config import getConfig |
14 from eric7config import getConfig |
15 |
15 |
16 debugger = None |
16 debugger = None |
17 __scriptname = None |
17 __scriptname = None |
18 |
18 |
19 modDir = sysconfig.get_path('platlib') |
19 modDir = sysconfig.get_path("platlib") |
20 ericpath = os.getenv('ERICDIR', getConfig('ericDir')) |
20 ericpath = os.getenv("ERICDIR", getConfig("ericDir")) |
21 |
21 |
22 if ericpath not in sys.path: |
22 if ericpath not in sys.path: |
23 sys.path.insert(-1, ericpath) |
23 sys.path.insert(-1, ericpath) |
24 |
24 |
25 |
25 |
26 def initDebugger(kind="standard"): |
26 def initDebugger(kind="standard"): |
27 """ |
27 """ |
28 Module function to initialize a debugger for remote debugging. |
28 Module function to initialize a debugger for remote debugging. |
29 |
29 |
30 @param kind type of debugger ("standard" or "threads") |
30 @param kind type of debugger ("standard" or "threads") |
31 @return flag indicating success (boolean) |
31 @return flag indicating success (boolean) |
32 @exception ValueError raised to indicate a wrong debugger kind |
32 @exception ValueError raised to indicate a wrong debugger kind |
33 """ |
33 """ |
34 global debugger |
34 global debugger |
35 res = True |
35 res = True |
36 try: |
36 try: |
37 if kind == "standard": |
37 if kind == "standard": |
38 import DebugClient |
38 import DebugClient |
|
39 |
39 debugger = DebugClient.DebugClient() |
40 debugger = DebugClient.DebugClient() |
40 else: |
41 else: |
41 raise ValueError |
42 raise ValueError |
42 except ImportError: |
43 except ImportError: |
43 debugger = None |
44 debugger = None |
44 res = False |
45 res = False |
45 |
46 |
46 return res |
47 return res |
47 |
48 |
48 |
49 |
49 def runcall(func, *args): |
50 def runcall(func, *args): |
50 """ |
51 """ |
51 Module function mimicing the Pdb interface. |
52 Module function mimicing the Pdb interface. |
52 |
53 |
53 @param func function to be called (function object) |
54 @param func function to be called (function object) |
54 @param *args arguments being passed to func |
55 @param *args arguments being passed to func |
55 @return the function result |
56 @return the function result |
56 """ |
57 """ |
57 global debugger, __scriptname |
58 global debugger, __scriptname |
58 return debugger.run_call(__scriptname, func, *args) |
59 return debugger.run_call(__scriptname, func, *args) |
59 |
60 |
60 |
61 |
61 def setScriptname(name): |
62 def setScriptname(name): |
62 """ |
63 """ |
63 Module function to set the scriptname to be reported back to the IDE. |
64 Module function to set the scriptname to be reported back to the IDE. |
64 |
65 |
65 @param name absolute pathname of the script (string) |
66 @param name absolute pathname of the script (string) |
66 """ |
67 """ |
67 global __scriptname |
68 global __scriptname |
68 __scriptname = name |
69 __scriptname = name |
69 |
70 |
70 |
71 |
71 def startDebugger(enableTrace=True, exceptions=True, |
72 def startDebugger(enableTrace=True, exceptions=True, tracePython=False, redirect=True): |
72 tracePython=False, redirect=True): |
|
73 """ |
73 """ |
74 Module function used to start the remote debugger. |
74 Module function used to start the remote debugger. |
75 |
75 |
76 @param enableTrace flag to enable the tracing function (boolean) |
76 @param enableTrace flag to enable the tracing function (boolean) |
77 @param exceptions flag to enable exception reporting of the IDE |
77 @param exceptions flag to enable exception reporting of the IDE |
78 (boolean) |
78 (boolean) |
79 @param tracePython flag to enable tracing into the Python library |
79 @param tracePython flag to enable tracing into the Python library |
80 (boolean) |
80 (boolean) |
81 @param redirect flag indicating redirection of stdin, stdout and |
81 @param redirect flag indicating redirection of stdin, stdout and |
82 stderr (boolean) |
82 stderr (boolean) |
83 """ |
83 """ |
84 global debugger |
84 global debugger |
85 if debugger: |
85 if debugger: |
86 debugger.startDebugger(enableTrace=enableTrace, exceptions=exceptions, |
86 debugger.startDebugger( |
87 tracePython=tracePython, redirect=redirect) |
87 enableTrace=enableTrace, |
|
88 exceptions=exceptions, |
|
89 tracePython=tracePython, |
|
90 redirect=redirect, |
|
91 ) |