Krita Source Code Documentation
Loading...
Searching...
No Matches
scripter.debugger_scripter.debugger.Debugger Class Reference
+ Inheritance diagram for scripter.debugger_scripter.debugger.Debugger:

Public Member Functions

 __init__ (self, scripter, cmd)
 
 display (self)
 
 start (self)
 
 step (self)
 
 stop (self)
 
 user_call (self, frame, args)
 
 user_exception (self, frame, exception)
 
 user_line (self, frame)
 
 user_return (self, frame, value)
 

Public Attributes

 application_data
 
 applicationq
 
 currentLine
 
 debugprocess
 
 debugq
 
 exception_data
 
 filePath
 
 mainpyfile
 
 quit
 
 scripter
 

Protected Member Functions

 _run (self, filename)
 

Detailed Description

Definition at line 12 of file debugger.py.

Constructor & Destructor Documentation

◆ __init__()

scripter.debugger_scripter.debugger.Debugger.__init__ ( self,
scripter,
cmd )

Definition at line 14 of file debugger.py.

14 def __init__(self, scripter, cmd):
15 bdb.Bdb.__init__(self)
16
17 self.quit = False
18 self.debugq = multiprocessing.Queue()
19 self.scripter = scripter
20 self.applicationq = multiprocessing.Queue()
21 self.filePath = self.scripter.documentcontroller.activeDocument.filePath
22 self.application_data = {}
23 self.exception_data = {}
24 self.debugprocess = multiprocessing.Process(target=self._run, args=(self.filePath,))
25 self.currentLine = 0
26
27 bdb.Bdb.reset(self)
28

Member Function Documentation

◆ _run()

scripter.debugger_scripter.debugger.Debugger._run ( self,
filename )
protected

Definition at line 29 of file debugger.py.

29 def _run(self, filename):
30 try:
31 self.mainpyfile = self.canonic(filename)
32 with open(filename, "rb") as fp:
33 statement = "exec(compile(%r, %r, 'exec'))" % \
34 (fp.read(), self.mainpyfile)
35 self.run(statement)
36 except Exception as e:
37 raise e
38

◆ display()

scripter.debugger_scripter.debugger.Debugger.display ( self)
Coroutine for updating the UI

Definition at line 82 of file debugger.py.

82 async def display(self):
83 """Coroutine for updating the UI"""
84
85 while True:
86 if self.applicationq.empty():
87 await asyncio.sleep(0.3)
88 else:
89 while not self.applicationq.empty():
90 self.application_data.update(self.applicationq.get())
91 self.scripter.uicontroller.repaintDebugArea()
92 return
93
VertexDescriptor get(PredecessorMap const &m, VertexDescriptor v)

References scripter.debugger_scripter.debugger.Debugger.application_data, scripter.debugger_scripter.debugger.Debugger.applicationq, get(), scripter.debugcontroller.DebugController.scripter, scripter.debugger_scripter.debugger.Debugger.scripter, scripter.ui_scripter.actions.closeaction.closeaction.CloseAction.scripter, scripter.ui_scripter.actions.debugaction.debugaction.DebugAction.scripter, scripter.ui_scripter.actions.newaction.newaction.NewAction.scripter, scripter.ui_scripter.actions.openaction.openaction.OpenAction.scripter, scripter.ui_scripter.actions.reloadaction.reloadaction.ReloadAction.scripter, scripter.ui_scripter.actions.runaction.runaction.RunAction.scripter, scripter.ui_scripter.actions.saveaction.saveaction.SaveAction.scripter, scripter.ui_scripter.actions.saveasaction.saveasaction.SaveAsAction.scripter, scripter.ui_scripter.actions.settingsaction.settingsaction.SettingsAction.scripter, scripter.ui_scripter.actions.settingsaction.settingsdialog.SettingsDialog.scripter, scripter.ui_scripter.editor.pythoneditor.CodeEditor.scripter, scripter.ui_scripter.tabwidgets.debuggerwidget.debuggerwidget.DebuggerWidget.scripter, scripter.ui_scripter.tabwidgets.debuggerwidget.stepaction.StepAction.scripter, scripter.ui_scripter.tabwidgets.debuggerwidget.stopaction.StopAction.scripter, scripter.ui_scripter.tabwidgets.outputwidget.clearaction.ClearAction.scripter, scripter.ui_scripter.tabwidgets.outputwidget.outputwidget.OutPutWidget.scripter, and scripter.uicontroller.UIController.scripter.

◆ start()

scripter.debugger_scripter.debugger.Debugger.start ( self)

Definition at line 94 of file debugger.py.

94 async def start(self):
95 await self.display()
96

References SvgGraphicsContext.display, and scripter.debugger_scripter.debugger.Debugger.display().

◆ step()

scripter.debugger_scripter.debugger.Debugger.step ( self)

Definition at line 97 of file debugger.py.

97 async def step(self):
98 self.debugq.put("step")
99 await self.display()
100
void put(PredecessorMap &m, VertexDescriptor key, VertexDescriptor value)

References scripter.debugger_scripter.debugger.Debugger.debugq, SvgGraphicsContext.display, scripter.debugger_scripter.debugger.Debugger.display(), and put().

◆ stop()

scripter.debugger_scripter.debugger.Debugger.stop ( self)

Definition at line 101 of file debugger.py.

101 async def stop(self):
102 self.debugq.put("stop")
103 self.applicationq.put({"quit": True})
104 await self.display()

References scripter.debugger_scripter.debugger.Debugger.applicationq, scripter.debugger_scripter.debugger.Debugger.debugq, SvgGraphicsContext.display, scripter.debugger_scripter.debugger.Debugger.display(), and put().

◆ user_call()

scripter.debugger_scripter.debugger.Debugger.user_call ( self,
frame,
args )

Definition at line 39 of file debugger.py.

39 def user_call(self, frame, args):
40 name = frame.f_code.co_name or "<unknown>"
41

◆ user_exception()

scripter.debugger_scripter.debugger.Debugger.user_exception ( self,
frame,
exception )

Definition at line 79 of file debugger.py.

79 def user_exception(self, frame, exception):
80 self.applicationq.put({"exception": str(exception[1])})
81

References scripter.debugger_scripter.debugger.Debugger.applicationq, and put().

◆ user_line()

scripter.debugger_scripter.debugger.Debugger.user_line ( self,
frame )
Handler that executes with every line of code

Definition at line 42 of file debugger.py.

42 def user_line(self, frame):
43 """Handler that executes with every line of code"""
44 co = frame.f_code
45
46 if self.filePath != co.co_filename:
47 return
48
49 self.currentLine = frame.f_lineno
50 self.applicationq.put({"code": {"file": co.co_filename,
51 "name": co.co_name,
52 "lineNumber": str(frame.f_lineno)
53 },
54 "frame": {"firstLineNumber": co.co_firstlineno,
55 "locals": debuggerformatter.format_data(frame.f_locals),
56 "globals": debuggerformatter.format_data(frame.f_globals)
57 },
58 "trace": "line"
59 })
60
61 if self.quit:
62 return self.set_quit()
63 if self.currentLine == 0:
64 return
65 else:
66 cmd = self.debugq.get()
67
68 if cmd == "step":
69 return
70 if cmd == "stop":
71 return self.set_quit()
72

References scripter.debugger_scripter.debugger.Debugger.applicationq, scripter.debugcontroller.DebugController.currentLine(), scripter.debugger_scripter.debugger.Debugger.currentLine, scripter.debugger_scripter.debugger.Debugger.debugq, KisPipeBrushParasite.dim, KisSpinBoxUnitManager.dim, FlattenSpec.dim, xcfLayer.dim, KoJsonTrader::PluginCacheEntry.filePath, KisSqlQueryLoader::FileException.filePath, KisSqlQueryLoader::SQLException.filePath, KritaUtils::ExportFileJob.filePath, scripter.debugger_scripter.debugger.Debugger.filePath, scripter.document_scripter.document.Document.filePath(), get(), put(), and scripter.debugger_scripter.debugger.Debugger.quit.

◆ user_return()

scripter.debugger_scripter.debugger.Debugger.user_return ( self,
frame,
value )

Definition at line 73 of file debugger.py.

73 def user_return(self, frame, value):
74 name = frame.f_code.co_name or "<unknown>"
75
76 if name == '<module>':
77 self.applicationq.put({"quit": True})
78

References scripter.debugger_scripter.debugger.Debugger.applicationq, and put().

Member Data Documentation

◆ application_data

scripter.debugger_scripter.debugger.Debugger.application_data

Definition at line 22 of file debugger.py.

◆ applicationq

scripter.debugger_scripter.debugger.Debugger.applicationq

Definition at line 20 of file debugger.py.

◆ currentLine

scripter.debugger_scripter.debugger.Debugger.currentLine

Definition at line 25 of file debugger.py.

◆ debugprocess

scripter.debugger_scripter.debugger.Debugger.debugprocess

Definition at line 24 of file debugger.py.

◆ debugq

scripter.debugger_scripter.debugger.Debugger.debugq

Definition at line 18 of file debugger.py.

◆ exception_data

scripter.debugger_scripter.debugger.Debugger.exception_data

Definition at line 23 of file debugger.py.

◆ filePath

scripter.debugger_scripter.debugger.Debugger.filePath

Definition at line 21 of file debugger.py.

◆ mainpyfile

scripter.debugger_scripter.debugger.Debugger.mainpyfile

Definition at line 31 of file debugger.py.

◆ quit

scripter.debugger_scripter.debugger.Debugger.quit

Definition at line 17 of file debugger.py.

◆ scripter

scripter.debugger_scripter.debugger.Debugger.scripter

Definition at line 19 of file debugger.py.


The documentation for this class was generated from the following file: