| Home | Trees | Indices | Help |
|
|---|
|
|
1 # Copyright 1983-2016 Keysight Technologies, Inc 814011 import empro 12 self._debugData = iDebugData 13 self._continueEvent = self._debugData.continuationEvent 14 self.debugToolBar = empro.gui.ToolBar("Debugger Tools","Debug") 15 self.debugAction = self.getAction("Debug") 16 self.resumeAction = self.getAction("Rerun") 17 self.pauseAction = self.getAction("Pause") 18 self.stopAction = self.getAction("Stop") 19 self.muteBreakPointsAction = self.getAction("Mute BreakPoints") 20 self.stepInAction = self.getAction("Step-In") 21 self.stepOutAction = self.getAction("Step-Out") 22 controlActions = [self.resumeAction,self.pauseAction,self.stopAction,self.muteBreakPointsAction] 23 stepActions = [self.stepInAction,self.stepOutAction] 24 self.debuggerActions = [self.debugAction]+controlActions + stepActions 25 self.debugToolBar.addAction(self.debugAction) 26 self.debugToolBar.addSeparator() 27 for action in controlActions: 28 self.debugToolBar.addAction(action) 29 self.debugToolBar.addSeparator() 30 for action in stepActions: 31 self.debugToolBar.addAction(action)3234 import empro 35 getActionandIconDict={ 36 "Debug":[_debugCurrentFile,empro.gui.Icon(":/debugger/debug_exc.png")], 37 "Rerun":[self._debugContinue,empro.gui.Icon(":/application/Redo.ico")], 38 "Pause":[self._debugPause,empro.gui.Icon(":/application/SequencePause.ico")], 39 "Stop":[self._debugStop,empro.gui.Icon(":/debugger/debug_stop.png")], 40 "Mute BreakPoints":[self._debugMuteBreakPoints,empro.gui.Icon(":/debugger/muteBreakPoints.ico")], 41 "Step-In":[self._debugStepIn,empro.gui.Icon(":/application/ArrowDown.ico")], 42 "Step-Out":[self._debugStepOut,empro.gui.Icon(":/application/ArrowUp.ico")] 43 } 44 defaultAction = empro.gui.Action(value) 45 defaultAction.enabled = False 46 if value == "Mute BreakPoints": 47 defaultAction.checkable = True 48 defaultAction.checked = False 49 defaultAction.enabled = True 50 if value == "Debug": 51 defaultAction.enabled = True 52 defaultAction.onTriggered = getActionandIconDict[value][0] 53 defaultAction.icon = getActionandIconDict[value][1] 54 return defaultAction5557 import empro 58 empro.internal.presentDebugger._debug_pause = False 59 if empro.internal.presentDebugger._isDebugging: 60 sw = empro.gui.activeScriptWindow() 61 currentScript = sw.currentScript() 62 if not currentScript == self._debugData.debugScriptName: 63 scriptListObj = empro.activeProject.scriptList() 64 sw.makeTab(scriptListObj.at(self._debugData.debugScriptName),True) 65 sw.removeHighlightMarkFromAllEditors() 66 sw.activateWindow() 67 ###Buttons########################## 68 self.resumeAction.enabled = False 69 self.pauseAction.enabled = True 70 self.stepInAction.enabled = False 71 self.stepOutAction.enabled = False 72 ###Buttons########################## 73 empro.internal.presentDebugger._debuggerWidget.variablesColumn.clear() 74 empro.internal.presentDebugger._debuggerWidget.framesColumn.clear() 75 empro.internal.presentDebugger._debuggerWidget.refreshListWidget(empro.internal.presentDebugger._debuggerWidget.framesColumn) 76 empro.internal.presentDebugger._debuggerWidget.refreshListWidget(empro.internal.presentDebugger._debuggerWidget.variablesColumn) 77 empro.internal.presentDebugger._activateDebugger(False) 78 self._continueEvent.set() 79 else: 80 scriptName = self._debugData.debugScriptName 81 scriptFileName = self._debugData.debugScriptFileName 82 empro.internal.presentDebugger._breaks = _updatedBreakPoints() 83 empro.internal.presentDebugger._initialize(scriptName,scriptFileName) 84 empro.internal.presentDebugger._debugScript(scriptName,scriptFileName)8587 import empro 88 if empro.internal.presentDebugger._isDebugging: 89 empro.internal.presentDebugger._debug_pause = True9092 import empro 93 if empro.internal.presentDebugger._isDebugging: 94 self._continueEvent.set() 95 empro.internal.presentDebugger._debug_pause = False 96 empro.internal.presentDebugger._debug_stop = True9799 import empro 100 sw = empro.gui.activeScriptWindow() 101 value = self.muteBreakPointsAction.checked 102 if value : 103 sw._muteBreakPoints() 104 sw.activateWindow() 105 empro.internal.presentDebugger._stop_at_breakPoints = False 106 self.muteBreakPointsAction.text = "Unmute Breakpoints" 107 else: 108 sw._unmuteBreakPoints() 109 sw.activateWindow() 110 empro.internal.presentDebugger._stop_at_breakPoints = True 111 self.muteBreakPointsAction.text = "Mute Breakpoints"112114 import empro 115 if empro.internal.presentDebugger._isDebugging: 116 self._continueEvent.set() 117 ###Buttons########################## 118 self.resumeAction.enabled = False 119 self.pauseAction.enabled = True 120 self.stepInAction.enabled = False 121 self.stepOutAction.enabled = False 122 ###Buttons########################## 123 empro.internal.presentDebugger._debug_pause = True 124 empro.internal.presentDebugger._debug_step_in = True125127 import empro 128 if empro.internal.presentDebugger._isDebugging: 129 self._continueEvent.set() 130 ###Buttons########################## 131 self.resumeAction.enabled = False 132 self.pauseAction.enabled = True 133 self.stepInAction.enabled = False 134 self.stepOutAction.enabled = False 135 ###Buttons########################## 136 empro.internal.presentDebugger._debug_step_out = True137402143 import empro 144 debuggerFrames = self._framesBox() 145 debuggerFrames.setSizePolicy (empro.gui.SizePolicy(empro.gui.Fixed, empro.gui.Preferred) ) 146 debuggerVariables = self._variablesBox() 147 debuggerVariables.setSizePolicy (empro.gui.SizePolicy(empro.gui.Preferred, empro.gui.Preferred) ) 148 debuggerBreakPointsBox = self._breakPointsBox() 149 debuggerBreakPointsBox.setSizePolicy (empro.gui.SizePolicy(empro.gui.Fixed, empro.gui.Preferred) ) 150 self.debuggerWidgetsList =[debuggerFrames,debuggerVariables,debuggerBreakPointsBox] 151 ###### PreSets ####### 152 self.framesNames = [] 153 self.varsList = []154156 import empro 157 framesBox = empro.gui.Widget() 158 framesBox.layout = empro.gui.VBoxLayout() 159 framesBox.layout.contentsMargin = [0,0,0,0] 160 framesBox.layout.spacing = 0 161 self.framesLabel = empro.gui.Label("Frames") 162 self.framesLabel.frameStyle = empro.gui.Frame.StyledPanel 163 self.framesLabel.addStyleSheet('QLabel {background-color: rgb(36,75,130); color: rgb(255,255,255)}') 164 self.framesColumn = empro.gui.TableView() 165 self.framesColumn.showGrid = False 166 self.framesColumn.alternatingRowColors = False 167 self.framesColumn.hideHorizontalHeader() 168 self.framesColumn.hideVerticalHeader() 169 self.framesColumn.selectionMode = empro.gui.TableView.SingleSelection 170 self.framesColumn.setSortingEnabled(False) 171 self.framesColumn.onClicked = self.onFramesClick 172 framesBox.layout.addWidget(self.framesLabel) 173 framesBox.layout.addWidget(self.framesColumn) 174 return framesBox175177 import empro 178 data = self.framesColumn.data(iRow,iColumn) 179 if data: 180 fields = self.varsList[iRow] 181 self.variablesColumn.clear() 182 for index,row in enumerate(fields): 183 self.variablesColumn.setRow(index,row) 184 for i in range(len(row)): 185 self.variablesColumn.setTooltip(index,i,row[i]) 186 if i == 0: 187 self.variablesColumn.setBoldFont(index,i) 188 if i == 1: 189 self.variablesColumn.setItalicFont(index,i) 190 self.variablesColumn.resizeRowsToContents() 191 self.variablesColumn.resizeColumnsToContents() 192 self.refreshListWidget(self.variablesColumn) 193 sw = empro.gui.activeScriptWindow() 194 scriptListObj = empro.activeProject.scriptList() 195 scriptList =[scriptListObj[i].name for i in range(scriptListObj.size())] 196 fnBaseName,lineno = data.split(",")[1].split(":") 197 fnBaseName = fnBaseName.strip() 198 sw.makeTab(scriptListObj.at(fnBaseName),True) 199 sw.removeHighlightMarkFromAllEditors() 200 sw.highlightScriptLine(fnBaseName,int(lineno)) 201 sw.activateWindow()202204 import empro 205 variablesBox = empro.gui.Widget() 206 variablesBox.layout = empro.gui.VBoxLayout() 207 variablesBox.layout.contentsMargin = [0,0,0,0] 208 variablesBox.layout.spacing = 0 209 self.variablesLabel = empro.gui.Label("Variables") 210 self.variablesLabel.frameStyle = empro.gui.Frame.StyledPanel 211 self.variablesLabel.addStyleSheet('QLabel {background-color: rgb(36,75,130); color: rgb(255,255,255)}') 212 self.variablesColumn = empro.gui.TableView() 213 self.variablesColumn.onSelectionChanged = self._onVariablesColumnSelectionChanged 214 self.variablesColumn.showGrid = False 215 self.variablesColumn.alternatingRowColors = False 216 self.variablesColumn.hideHorizontalHeader() 217 self.variablesColumn.hideVerticalHeader() 218 self.variablesColumn.selectionBehavior = empro.gui.TableView.SelectRows 219 self.variablesColumn.selectionMode = empro.gui.TableView.SingleSelection 220 self.variablesColumn.setSortingEnabled(False) 221 variablesBox.layout.addWidget(self.variablesLabel) 222 variablesBox.layout.addWidget(self.variablesColumn) 223 return variablesBox224226 self.refreshListWidget(self.variablesColumn)227229 textToBeFound = self.variablesSearchBar.text 230 self.variablesColumn.findInColumn(textToBeFound,0)231233 textToBeFound = self.variablesSearchBar.text 234 textAvailable = self.variablesColumn.find(textToBeFound) 235 if textAvailable: 236 self.forwardVariablesSearchButton.enabled = True 237 self.backwardVariablesSearchButton.enabled = True 238 else: 239 self.forwardVariablesSearchButton.enabled = False 240 self.backwardVariablesSearchButton.enabled = False241243 textToBeFound = self.variablesSearchBar.text 244 self.variablesColumn.findForward(textToBeFound)245247 textToBeFound = self.variablesSearchBar.text 248 self.variablesColumn.findBackward(textToBeFound)249251 import empro 252 breakPointsBox = empro.gui.Widget() 253 breakPointsBox.layout = empro.gui.VBoxLayout() 254 breakPointsBox.layout.contentsMargin = [0,0,0,0] 255 breakPointsBox.layout.spacing = 0 256 self.breakPointsLabel = empro.gui.Label("Break Points") 257 self.breakPointsLabel.frameStyle = empro.gui.Frame.StyledPanel 258 self.breakPointsLabel.addStyleSheet('QLabel {background-color: rgb(36,75,130); color: rgb(255,255,255)}') 259 self.breakPointsColumn = empro.gui.TableView() 260 self.breakPointsColumn.showGrid = False 261 self.breakPointsColumn.alternatingRowColors = False 262 self.breakPointsColumn.hideHorizontalHeader() 263 self.breakPointsColumn.hideVerticalHeader() 264 self.breakPointsColumn.setSortingEnabled(False) 265 self.breakPointsColumn.onClicked = self.onBreakPointsClicked 266 deleteButtonWidget = self._deleteButtonWidget() 267 breakPointsBox.layout.addWidget(self.breakPointsLabel) 268 breakPointsBox.layout.addWidget(self.breakPointsColumn) 269 breakPointsBox.layout.addWidget(deleteButtonWidget) 270 return breakPointsBox271273 import empro 274 deleteButtonWidget = empro.gui.Widget() 275 deleteButtonWidget.layout = empro.gui.HBoxLayout() 276 deleteButtonWidget.layout.contentsMargin = [0,0,0,0] 277 deleteButtonWidget.layout.spacing = 0 278 self.removeBreakPointButton = empro.gui.ToolButton() 279 self.removeBreakPointButton.autoRaise = True 280 self.removeBreakPointButton.toolTip = "Remove the selected Break Point" 281 self.removeBreakPointButton.icon = empro.gui.Icon(":/application/Delete.ico") 282 self.removeBreakPointButton.onClicked = self._debugRemoveBreakPoint 283 deleteButtonWidget.layout.addStretch(1) 284 deleteButtonWidget.layout.addWidget(self.removeBreakPointButton) 285 return deleteButtonWidget286288 import empro 289 sw = empro.gui.activeScriptWindow() 290 selectedCells = self.breakPointsColumn.selectedCells() 291 for row,column in selectedCells: 292 data = self.breakPointsColumn.data(row,column) 293 if data: 294 data = data.split(" ",3) 295 lineno = int(data[1]) 296 fnBaseName = data[-1] 297 sw.removeBreakPoint(fnBaseName,lineno) 298 sw.activateWindow() 299 self.updateBreakPointsColumn()300302 import empro 303 data = self.breakPointsColumn.data(iRow,iColumn) 304 if data : 305 data = data.split(" ") 306 lineno = int( data[1]) 307 fnBaseName = data[3] 308 sw = empro.gui.activeScriptWindow() 309 sw.showScriptLine(fnBaseName,lineno) 310 sw.activateWindow()311313 import empro 314 fields =[] 315 data = _updatedBreakPoints() 316 items = data.items() 317 for i in items: 318 for x in i[1]: 319 fields.append("Line %d in %s"%(x,i[0])) 320 self.breakPointsColumn.clear() 321 self.breakPointsColumn.setColumn(0,fields) 322 for i in range(len(fields)): 323 self.breakPointsColumn.setTooltip(i,0,fields[i]) 324 self.breakPointsColumn.resizeRowsToContents() 325 self.breakPointsColumn.resizeColumnsToContents() 326 self.refreshListWidget(self.breakPointsColumn)327329 import os 330 import inspect 331 import empro 332 ###Buttons########################## 333 empro.internal.presentDebugger._debugToolBar.resumeAction.enabled = True 334 empro.internal.presentDebugger._debugToolBar.pauseAction.enabled = False 335 empro.internal.presentDebugger._debugToolBar.stepInAction.enabled = True 336 empro.internal.presentDebugger._debugToolBar.stepOutAction.enabled = True 337 ###Buttons########################## 338 self.varsList = [] 339 self.framesNames =[] 340 self.variablesColumn.clear() 341 self.framesColumn.clear() 342 framesStack = inspect.getouterframes(frame) 343 framesList = [i[0]for i in framesStack] 344 framesList = framesList[:-2] 345 for f in framesList: 346 info = inspect.getframeinfo(f) 347 if not os.path.basename(info.filename) in['<string>','bdb.py',]: 348 fn = info.filename 349 fnBaseName = os.path.basename(fn) 350 sw = empro.gui.activeScriptWindow() 351 scriptListObj = empro.activeProject.scriptList() 352 scriptList =[scriptListObj[i].name for i in range(scriptListObj.size())] 353 if not fnBaseName in scriptList: 354 sw.createEditorTabFor(fn,False) 355 name = "%s , %s : %s"%(info.function,fnBaseName,info.lineno) 356 self.framesNames.append(name) 357 fields = [] 358 for key,value in f.f_locals.items(): 359 if not key in ['__builtins__']: 360 valueType = str(type(value)).split("'")[1] 361 value = str(value) 362 field = [str(key),"{%s}"%(valueType),value,""] 363 fields.append(field) 364 self.varsList.append(fields) 365 self.framesColumn.setColumn(0,self.framesNames) 366 for i in range(len(self.framesNames)): 367 self.framesColumn.setTooltip(i,0,self.framesNames[i]) 368 self.framesColumn.setColumn(0,self.framesNames) 369 self.framesColumn.resizeRowsToContents() 370 self.framesColumn.resizeColumnsToContents() 371 self.refreshListWidget(self.framesColumn) 372 self.framesColumn.selectRow(0) 373 for index,row in enumerate(self.varsList[0]): 374 self.variablesColumn.setRow(index,row) 375 for i in range(len(row)): 376 self.variablesColumn.setTooltip(index,i,row[i]) 377 if i == 0: 378 self.variablesColumn.setBoldFont(index,i) 379 if i == 1: 380 self.variablesColumn.setItalicFont(index,i) 381 self.variablesColumn.resizeRowsToContents() 382 self.variablesColumn.resizeColumnsToContents() 383 self.refreshListWidget(self.variablesColumn) 384 sw = empro.gui.activeScriptWindow() 385 scriptListObj = empro.activeProject.scriptList() 386 scriptList =[scriptListObj[i].name for i in range(scriptListObj.size())] 387 fnBaseName,lineno = self.framesNames[0].split(",")[1].split(":") 388 fnBaseName = fnBaseName.strip() 389 sw.makeTab(scriptListObj.at(fnBaseName),True) 390 sw.removeHighlightMarkFromAllEditors() 391 sw.highlightScriptLine(fnBaseName,int(lineno)) 392 sw.activateWindow()393 398 399468405 import os 406 import empro 407 self.choice = None 408 self.data = listOfDict 409 self.dialog = empro.gui.SimpleDialog(empro.gui.Ok) 410 self.dialog.title = funcName 411 self.dialog.resize(400, 200) 412 self.dialog.maximumWidth = 400 413 subjectText = "More than one instance of the <strong> %s</strong> function definition has be found in the loaded scripts.<br> Please select the script which has the required function definition."%(funcName) 414 fields = [os.path.basename(x['_fileName']) for x in self.data] 415 self.subject = empro.gui.Label(subjectText) 416 self.listWidget = empro.gui.TableView() 417 self.listWidget.alternatingRowColors = False 418 self.listWidget.hideHorizontalHeader() 419 self.listWidget.hideVerticalHeader() 420 self.listWidget.selectionMode = empro.gui.TableView.SingleSelection 421 self.listWidget.setColumn(0,fields) 422 self.listWidget.resizeColumnsToContents() 423 self.listWidget.resizeRowsToContents() 424 self.refreshListWidget() 425 self.listWidget.onClicked = self.listWidgetClicked 426 listBox = empro.gui.HBoxLayout() 427 listBox.addWidget(self.listWidget) 428 listBox.addStretch(1) 429 w = empro.gui.Widget() 430 w.layout = empro.gui.VBoxLayout() 431 w.layout.contentsMargin = [0,0,0,0] 432 w.layout.addWidget(self.subject) 433 w.layout.addStretch(1) 434 w.layout.addLayout(listBox) 435 self.dialog.layout.add(w) 436 self.dialog.onClicked = self.onClicked 437 self.dialog.show(True)438440 w, h = self.listWidget.size() 441 self.listWidget.resize(w + 1, h) 442 self.listWidget.resize(w, h)443445 import os 446 import empro 447 data = self.data[iRow] 448 fileName = os.path.basename(data['_fileName']) 449 sw = empro.gui.activeScriptWindow() 450 sw.removeHighlightMarkFromAllEditors() 451 sw.activateWindow() 452 for n in range(data['_firstLineNo'],data['_lastLineNo']+1): 453 sw.highlightScriptLine(fileName,n) 454 sw.activateWindow()455457 if (iButton.text == "OK"): 458 import empro 459 sw = empro.gui.activeScriptWindow() 460 sw.removeHighlightMarkFromAllEditors() 461 sw.activateWindow() 462 selectedRow = self.listWidget.selectedRows() 463 if selectedRow : 464 self.choice = selectedRow[0]465557 562471 import empro 472 self.dialog = empro.gui.SimpleDialog(empro.gui.Ok) 473 self.dialog.resize(800,100) 474 self.dialog.maximumWidth = 800 475 self.dialog.minimumWidth = 800 476 self.dialog.maximumHeight= 400 477 self.dialog.title = "Error" 478 w = empro.gui.Widget() 479 w.layout = empro.gui.HBoxLayout() 480 w.layout.contentsMargin =[0,0,0,0] 481 w.layout.spacing = 0 482 typeBox = self. _typeBox(excInfo) 483 descriptionBox = self._descriptionBox(excInfo) 484 foundBox = self._foundBox(excInfo) 485 w.layout.addLayout(typeBox) 486 w.layout.addLayout(descriptionBox) 487 if foundBox: 488 w.layout.addLayout(foundBox) 489 self.dialog.layout.add(w)490492 import empro 493 typeLayout = empro.gui.VBoxLayout() 494 typeLayout.contentsMargin =[0,0,0,0] 495 self.typeLabel = empro.gui.Label("Type") 496 self.typeLabel.frameStyle = empro.gui.Frame.StyledPanel 497 self.typeLabel.addStyleSheet('QLabel {background-color: rgb(36,75,130); color: rgb(255,255,255)}') 498 type = str(excInfo[0]).split("'")[1].split('.')[1] 499 self.typeColumn = empro.gui.TextEdit(type) 500 self.typeColumn.text = type 501 self.typeColumn.readOnly = True 502 typeLayout.addWidget(self.typeLabel) 503 typeLayout.addWidget(self.typeColumn) 504 return typeLayout505507 import empro 508 descriptionLayout = empro.gui.VBoxLayout() 509 descriptionLayout.contentsMargin =[0,0,0,0] 510 self.descriptionLabel= empro.gui.Label("Description") 511 self.descriptionLabel.frameStyle = empro.gui.Frame.StyledPanel 512 self.descriptionLabel.addStyleSheet('QLabel {background-color: rgb(36,75,130); color: rgb(255,255,255)}') 513 description = str(excInfo[1]) 514 self.descriptionColumn = empro.gui.TextEdit(description) 515 self.descriptionColumn.readOnly = True 516 descriptionLayout.addWidget(self.descriptionLabel) 517 descriptionLayout.addWidget(self.descriptionColumn) 518 return descriptionLayout519 521 import os 522 import traceback 523 import empro 524 foundLayout = empro.gui.VBoxLayout() 525 foundLayout.contentsMargin =[0,0,0,0] 526 self.foundLabel = empro.gui.Label("Found at") 527 self.foundLabel.frameStyle = empro.gui.Frame.StyledPanel 528 self.foundLabel.addStyleSheet('QLabel {background-color: rgb(36,75,130); color: rgb(255,255,255)}') 529 self.foundColumn = empro.gui.TableView() 530 self.foundColumn.alternatingRowColors = False 531 self.foundColumn.hideVerticalHeader() 532 self.foundColumn.hideHorizontalHeader() 533 self.foundColumn.selectionMode = empro.gui.TableView.NoSelection 534 tb = excInfo[2] 535 errorLines = traceback.format_tb(tb) 536 errorLines = errorLines[2:] 537 errorLines = errorLines[::-1] 538 lineInfo = [] 539 for line in errorLines: 540 errorLineFileName = line.split('"',2)[1] 541 errorLineFileName = os.path.basename(errorLineFileName) 542 errorLineNo = line.split('"',2)[-1].split(",")[1].strip() 543 sw = empro.gui.activeScriptWindow() 544 lineNo = errorLineNo.split(" ")[1] 545 sw.showErrorMark(errorLineFileName,int(lineNo),True) 546 sw.activateWindow() 547 info ="%s in %s "%(errorLineNo, errorLineFileName) 548 lineInfo.append(info) 549 self.foundColumn.setColumn(0,lineInfo) 550 self.foundColumn.resizeRowsToContents() 551 self.foundColumn.resizeColumnsToContents() 552 self.refreshListWidget(self.foundColumn) 553 self.foundColumn.onClicked = self.foundColumnClicked 554 foundLayout.addWidget(self.foundLabel) 555 foundLayout.addWidget(self.foundColumn) 556 return foundLayout564 import empro 565 data = self.foundColumn.data(row,column) 566 if data: 567 data = data.split(" ",3) 568 lineno = int(data[1]) 569 fileName = data[-1] 570 fileName = fileName.strip() 571 sw = empro.gui.activeScriptWindow() 572 sw.removeHighlightMarkFromAllEditors() 573 sw.highlightScriptLine(fileName,lineno) 574 sw.activateWindow()575577 self.dialog.show(True)578 579 import bdb as _bdb836 837582 import empro 583 import threading 584 self.skip = None 585 self._debugData= iDebugData 586 self._isDebugging = False 587 self._associatedFileNames = [] 588 self._breaks = self._debugData.breakPointsDict 589 self._continueEvent = threading.Event() 590 self._continueEvent.clear() 591 self._debugData.continuationEvent = self._continueEvent 592 self._debugToolBar = DebuggerToolBar(self._debugData) 593 self._debuggerWidget = DebuggerWidget()594596 import empro 597 self._debugData.debugScriptName = scriptName 598 self._debugData.debugScriptFileName = scriptFileName 599 self._associatedFileNames = [] 600 self._isDebugging = False 601 self._debug_pause = False 602 self._debug_stop = False 603 self._debug_step_out = False 604 self._debug_step_in= False 605 ###rerun to resume########################## 606 self._debugToolBar.resumeAction.icon = empro.gui.Icon(":/scripting/ExecuteMacro.ico") 607 self._debugToolBar.resumeAction.enabled = True 608 ###rerun to resume########################## 609 ########### BP Senario################ 610 if self._debugToolBar.muteBreakPointsAction.checked: 611 self._stop_at_breakPoints = False 612 self._debugToolBar.muteBreakPointsAction.text = "Unmute Breakpoints" 613 else: 614 self._stop_at_breakPoints = True 615 self._debugToolBar.muteBreakPointsAction.text = "Mute Breakpoints"616618 import empro 619 sw = empro.gui.activeScriptWindow() 620 menu = empro.gui.Menu() 621 menu.title = "Debug" 622 menu.icon = empro.gui.Icon(":/debugger/debug_exc.png") 623 for action in self._debugToolBar.debuggerActions: 624 menu.addAction(action) 625 sw._addDebuggerMenu(menu)626628 import empro 629 debugToolBar = self._debugToolBar.getToolBar() 630 sw = empro.gui.activeScriptWindow() 631 sw.addToolBar(8,debugToolBar)632634 import empro 635 debuggerWidgets = self._debuggerWidget.getDebuggerWidgetsList() 636 sw = empro.gui.activeScriptWindow() 637 sw._addDebugger(debuggerWidgets) 638 self._setUpContextMenusForDebugger() 639 self._updateBreakPointsInDebuggerWidget()640642 import empro 643 self._debuggerWidget.breakPointsColumn.addAction(self._debugToolBar.muteBreakPointsAction)644 648 653 658660 import empro 661 import os 662 import sys 663 import ast 664 665 globals_ = {"__name__": "__main__", "__file__": scriptFileName} 666 locals_ = globals_ 667 self._isDebugging = True 668 self._associatedFileNames.append(scriptFileName) 669 self._addDebuggerWidget() 670 ###Buttons n ToolTips########################## 671 self._debugToolBar.resumeAction.enabled = False 672 self._debugToolBar.pauseAction.enabled = True 673 self._debugToolBar.stepInAction.enabled = False 674 self._debugToolBar.stepOutAction.enabled = False 675 self._debugToolBar.stopAction.enabled = True 676 self._debugToolBar.stopAction.text = "Stop '%s'"%(self._debugData.debugScriptName) 677 self._debugToolBar.pauseAction.text = "Pause '%s'"%(self._debugData.debugScriptName) 678 self._debugToolBar.resumeAction.text = "Resume '%s'"%(self._debugData.debugScriptName) 679 self._debugToolBar.stepInAction.text = "Step-In '%s'"%(self._debugData.debugScriptName) 680 self._debugToolBar.stepOutAction.text = "Step-Out '%s'"%(self._debugData.debugScriptName) 681 ###Buttons n ToolTips########################## 682 emproCodeObj = compile("import empro","<string>","single") 683 self.run(emproCodeObj,globals=globals_,locals=locals_) 684 try_again = True 685 while try_again: 686 try: 687 try_again = False 688 sw = empro.gui.activeScriptWindow() 689 scriptListObj = empro.activeProject.scriptList() 690 sw.makeTab(scriptListObj.at(scriptName),True) 691 sw.activateWindow() 692 cmd = sw.scriptContent(scriptName) 693 scriptCodeObj = compile(cmd,scriptFileName,"exec") 694 self.run(scriptCodeObj,globals=globals_,locals=locals_) 695 except NameError as e: 696 actualErrorInfo = sys.exc_info() 697 try_again = True 698 try: 699 tempVar = str(e).split("'")[1] 700 except: 701 try_again = False 702 errorWindow = ErrorMessage(actualErrorInfo) 703 errorWindow.show() 704 break 705 sw = empro.gui.activeScriptWindow() 706 scriptNames = list(sw.loadedScripts()) 707 scriptNametoStoredNameDict = _generateScriptNametoStoredNameDict() 708 data ={} 709 for sName in scriptNames: 710 text = sw.scriptContent(sName) 711 try: 712 tree = ast.parse(text,scriptNametoStoredNameDict[sName],'exec') 713 except: 714 continue 715 for func in tree.body: 716 if isinstance(func,ast.FunctionDef): 717 lastBody = func.body[-1] 718 while isinstance(lastBody,(ast.For,ast.While,ast.If)) : 719 lastBody = lastBody.body[-1] 720 lastLine = lastBody.lineno 721 data.setdefault(func.name,[]).append({'_func':func,'_fileName':sName,'_firstLineNo':func.lineno,'_lastLineNo':lastLine}) 722 if tempVar in data.keys(): 723 i = 0 724 if len (data[tempVar]) > 1: 725 i = GetChoice(tempVar,data[tempVar]).getValue() 726 if i == None: 727 quitDebugger = empro.gui.MessageBox.question("Exit Debugger","No File Selected.\nDo you want to exit the Debugger?", 16384 + 65536, 16384) == 16384 728 if quitDebugger: 729 print "Debugger Stopped" 730 try_again = False 731 break 732 else: 733 continue 734 wrapped = ast.Interactive(body = [data[tempVar][i]['_func']]) 735 wrapped = ast.fix_missing_locations(wrapped) 736 codeObj = compile(wrapped,data[tempVar][i]['_fileName'],'single') 737 self.run(codeObj,globals = globals_,locals = locals_) 738 self._associatedFileNames.append(data[tempVar][i]['_fileName']) 739 else: 740 try_again = False 741 errorWindow = ErrorMessage(actualErrorInfo) 742 errorWindow.show() 743 except: 744 try_again = False 745 errorWindow = ErrorMessage(sys.exc_info()) 746 errorWindow.show() 747 finally: 748 if not try_again: 749 self._debuggerGuiRestore()750752 import empro 753 self._isDebugging = False 754 self._removeDebugWidget() 755 ###Buttons n ToolTips########################## 756 self._debugToolBar.resumeAction.enabled = True 757 self._debugToolBar.resumeAction.text = "Rerun '%s'"%(self._debugData.debugScriptName) 758 self._debugToolBar.resumeAction.icon = empro.gui.Icon(":/application/Redo.ico") 759 self._debugToolBar.pauseAction.enabled = False 760 self._debugToolBar.stepInAction.enabled = False 761 self._debugToolBar.stepOutAction.enabled = False 762 self._debugToolBar.stopAction.enabled = False 763 self._debugToolBar.stopAction.text = "Stop" 764 self._debugToolBar.pauseAction.text = "Pause" 765 self._debugToolBar.stepInAction.text = "Step-In" 766 self._debugToolBar.stepOutAction.text = "Step-Out" 767 ###Buttons n ToolTips########################## 768 self._debuggerWidget.variablesColumn.clear() 769 self._debuggerWidget.framesColumn.clear() 770 sw = empro.gui.activeScriptWindow() 771 sw.removeHighlightMarkFromAllEditors() 772 sw.activateWindow()773 777 778 ############## bdb Methods #######################780 import empro 781 import os 782 if not self._breaks or self._debug_step_in: 783 return 784 if os.path.basename(frame.f_code.co_filename) in self._breaks.keys(): 785 if frame.f_lineno in self._breaks[os.path.basename(frame.f_code.co_filename)]: 786 self._continueEvent.clear() 787 self._enterBreakMode(frame) 788 while not self._continueEvent.isSet(): 789 empro.gui.processEvents() 790 import time 791 time.sleep(0.01) # we should probably throttle this one based on timing 792 self._continueEvent.clear()793795 import empro 796 if frame.f_code.co_filename in self._associatedFileNames: 797 empro.gui.processEvents() 798 if self._debug_step_out: 799 callerFileName = frame.f_back.f_code.co_filename 800 currentFileName= self._debugData.debugScriptFileName 801 if not callerFileName == currentFileName: 802 if self._debug_pause: 803 sw = empro.gui.activeScriptWindow() 804 sw.removeHighlightMarkFromAllEditors() 805 sName = sw.currentScript() 806 scriptName = self._debugData.debugScriptName 807 if not sName == scriptName: 808 scriptListObj = empro.activeProject.scriptList() 809 sw.makeTab(scriptListObj.at(scriptName),True) 810 sw.activateWindow() 811 self._debug_pause = False 812 else: 813 self._debug_pause = True 814 self._debug_step_out = False 815 else: 816 self._debug_pause = False 817 if self._debug_pause: 818 if self._debug_step_in: 819 self._debug_step_in = False 820 self._continueEvent.clear() 821 self._enterBreakMode(frame) 822 while not self._continueEvent.isSet(): 823 empro.gui.processEvents() 824 import time 825 time.sleep(0.01) # we should probably throttle this one based on timing 826 self._continueEvent.clear() 827 828 if self._debug_stop: 829 print "Stopped Debugging %s"%(self._debugData.debugScriptName) 830 raise _bdb.BdbQuit 831 832 if self._stop_at_breakPoints: 833 self.user_line(frame) 834 835 return self.trace_dispatch839 import empro 840 sw = empro.gui.activeScriptWindow() 841 scriptName = sw.currentScript() 842 if scriptName: 843 empro.internal.presentDebugger._debugToolBar.debugAction.text = "Debug '%s'"%(scriptName) 844 else: 845 empro.internal.presentDebugger._debugToolBar.debugAction.text = "Debug" 846 if empro.internal.presentProfiler: 847 empro.toolkit.profiler._updateProfileToolTip()848850 import empro 851 data = _updatedBreakPoints() 852 if empro.internal.presentDebugger: 853 empro.internal.presentDebugger._breaks = data 854 empro.internal.presentDebugger._debuggerWidget.updateBreakPointsColumn()855857 import empro 858 sw = empro.gui.activeScriptWindow() 859 sw.recomputeBreakPoints() 860 breakPoints = empro.internal.__breakPoints() 861 data = {} 862 for b in breakPoints: 863 data.setdefault(b.fileName,[]).append(b.lineNo) 864 return data865867 import empro 868 sw = empro.gui.activeScriptWindow() 869 loadedScripts = sw.loadedScripts() 870 loadedScriptsStoredName = sw.loadedScriptsStoredName() 871 scriptNametoStoredNameDict = dict(zip(loadedScripts,loadedScriptsStoredName)) 872 return scriptNametoStoredNameDict873875 import empro 876 sw = empro.gui.activeScriptWindow() 877 sw.removeErrorMarkFromAllEditors() 878 sw.saveAllTabs() 879 sw.activateWindow() 880 scriptNametoStoredNameDict = _generateScriptNametoStoredNameDict() 881 scriptName = sw.currentScript() 882 scriptFileName = scriptNametoStoredNameDict[scriptName] 883 if empro.internal.presentDebugger._isDebugging: 884 empro.gui.MessageBox.information("Debug File","Debugger is still running.\nPlease stop it and then proceed.", 0,0) 885 else: 886 empro.internal.presentDebugger._breaks = _updatedBreakPoints() 887 empro.internal.presentDebugger._initialize(scriptName,scriptFileName) 888 empro.internal.presentDebugger._debugScript(scriptName,scriptFileName)889891 import empro 892 empro.internal.presentDebugger = None 893 empro.core.ApplicationPreferences.setPreference("PyEditor.debugger",1) 894 try: 895 empro.internal.debugToolBar.visible = False 896 del empro.internal.debugToolBar 897 except: 898 pass 899 finally: 900 debugData = DebuggerData() 901 debugData.breakPointsDict = _updatedBreakPoints() 902 empro.internal.presentDebugger = Debugger(debugData) 903 sw = empro.gui.activeScriptWindow() 904 sw._onBreakMarginClicked = empro.toolkit.debugger._updateBreakPoints 905 sw._onScriptEditorClosed = empro.toolkit.debugger._updateBreakPoints 906 sw._onActiveScriptChanged = empro.toolkit.debugger._updateDebugToolTip 907 sw.activateWindow() 908 empro.internal.presentDebugger._addDebugToolBar() 909 empro.internal.presentDebugger._addDebugMenuBar()910
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Wed Jun 26 10:16:58 2019 | http://epydoc.sourceforge.net |