eric6/DebugClients/Python/eric6dbgstub.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7360
9190402e4505
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2002 - 2019 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 distutils.sysconfig
13
14 from eric6config import getConfig
15
16 debugger = None
17 __scriptname = None
18
19 modDir = distutils.sysconfig.get_python_lib(True)
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 debugger = DebugClient.DebugClient()
40 else:
41 raise ValueError
42 except ImportError:
43 debugger = None
44 res = False
45
46 return res
47
48
49 def runcall(func, *args):
50 """
51 Module function mimicing the Pdb interface.
52
53 @param func function to be called (function object)
54 @param *args arguments being passed to func
55 @return the function result
56 """
57 global debugger, __scriptname
58 return debugger.run_call(__scriptname, func, *args)
59
60
61 def setScriptname(name):
62 """
63 Module function to set the scriptname to be reported back to the IDE.
64
65 @param name absolute pathname of the script (string)
66 """
67 global __scriptname
68 __scriptname = name
69
70
71 def startDebugger(enableTrace=True, exceptions=True,
72 tracePython=False, redirect=True):
73 """
74 Module function used to start the remote debugger.
75
76 @keyparam enableTrace flag to enable the tracing function (boolean)
77 @keyparam exceptions flag to enable exception reporting of the IDE
78 (boolean)
79 @keyparam tracePython flag to enable tracing into the Python library
80 (boolean)
81 @keyparam redirect flag indicating redirection of stdin, stdout and
82 stderr (boolean)
83 """
84 global debugger
85 if debugger:
86 debugger.startDebugger(enableTrace=enableTrace, exceptions=exceptions,
87 tracePython=tracePython, redirect=redirect)
88
89 #
90 # eflag: noqa = M702

eric ide

mercurial