src/eric7/DebugClients/Python/eric7dbgstub.py

branch
eric7-maintenance
changeset 9264
18a7312cfdb3
parent 9221
bf71ee032bb4
child 9448
ea215f7afab3
equal deleted inserted replaced
9241:d23e9854aea4 9264:18a7312cfdb3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2002 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a debugger stub for remote debugging.
8 """
9
10 import os
11 import sys
12 import sysconfig
13
14 from eric7config import getConfig
15
16 debugger = None
17 __scriptname = None
18
19 modDir = sysconfig.get_path("platlib")
20 ericpath = os.getenv("ERICDIR", getConfig("ericDir"))
21
22 if ericpath not in sys.path:
23 sys.path.insert(-1, ericpath)
24
25
26 def initDebugger(kind="standard"):
27 """
28 Module function to initialize a debugger for remote debugging.
29
30 @param kind type of debugger ("standard" or "threads")
31 @return flag indicating success (boolean)
32 @exception ValueError raised to indicate a wrong debugger kind
33 """
34 global debugger
35 res = True
36 try:
37 if kind == "standard":
38 import DebugClient
39
40 debugger = DebugClient.DebugClient()
41 else:
42 raise ValueError
43 except ImportError:
44 debugger = None
45 res = False
46
47 return res
48
49
50 def runcall(func, *args):
51 """
52 Module function mimicing the Pdb interface.
53
54 @param func function to be called (function object)
55 @param *args arguments being passed to func
56 @return the function result
57 """
58 global debugger, __scriptname
59 return debugger.run_call(__scriptname, func, *args)
60
61
62 def setScriptname(name):
63 """
64 Module function to set the scriptname to be reported back to the IDE.
65
66 @param name absolute pathname of the script (string)
67 """
68 global __scriptname
69 __scriptname = name
70
71
72 def startDebugger(enableTrace=True, exceptions=True, tracePython=False, redirect=True):
73 """
74 Module function used to start the remote debugger.
75
76 @param enableTrace flag to enable the tracing function (boolean)
77 @param exceptions flag to enable exception reporting of the IDE
78 (boolean)
79 @param tracePython flag to enable tracing into the Python library
80 (boolean)
81 @param redirect flag indicating redirection of stdin, stdout and
82 stderr (boolean)
83 """
84 global debugger
85 if debugger:
86 debugger.startDebugger(
87 enableTrace=enableTrace,
88 exceptions=exceptions,
89 tracePython=tracePython,
90 redirect=redirect,
91 )

eric ide

mercurial