mirror of
https://github.com/aykhans/AzSuicideDataVisualization.git
synced 2025-07-03 14:49:07 +00:00
first commit
This commit is contained in:
137
.venv/Lib/site-packages/pythonwin/pywin/debugger/__init__.py
Normal file
137
.venv/Lib/site-packages/pythonwin/pywin/debugger/__init__.py
Normal file
@ -0,0 +1,137 @@
|
||||
import sys
|
||||
|
||||
# Some cruft to deal with the Pythonwin GUI booting up from a non GUI app.
|
||||
def _MakeDebuggerGUI():
|
||||
app.InitInstance()
|
||||
|
||||
|
||||
isInprocApp = -1
|
||||
|
||||
|
||||
def _CheckNeedGUI():
|
||||
global isInprocApp
|
||||
if isInprocApp == -1:
|
||||
import win32ui
|
||||
|
||||
isInprocApp = win32ui.GetApp().IsInproc()
|
||||
if isInprocApp:
|
||||
# MAY Need it - may already have one
|
||||
need = "pywin.debugger.dbgpyapp" not in sys.modules
|
||||
else:
|
||||
need = 0
|
||||
if need:
|
||||
import pywin.framework.app
|
||||
from . import dbgpyapp
|
||||
|
||||
pywin.framework.app.CreateDefaultGUI(dbgpyapp.DebuggerPythonApp)
|
||||
|
||||
else:
|
||||
# Check we have the appropriate editor
|
||||
# No longer necessary!
|
||||
pass
|
||||
return need
|
||||
|
||||
|
||||
# Inject some methods in the top level name-space.
|
||||
currentDebugger = None # Wipe out any old one on reload.
|
||||
|
||||
|
||||
def _GetCurrentDebugger():
|
||||
global currentDebugger
|
||||
if currentDebugger is None:
|
||||
_CheckNeedGUI()
|
||||
from . import debugger
|
||||
|
||||
currentDebugger = debugger.Debugger()
|
||||
return currentDebugger
|
||||
|
||||
|
||||
def GetDebugger():
|
||||
# An error here is not nice - as we are probably trying to
|
||||
# break into the debugger on a Python error, any
|
||||
# error raised by this is usually silent, and causes
|
||||
# big problems later!
|
||||
try:
|
||||
rc = _GetCurrentDebugger()
|
||||
rc.GUICheckInit()
|
||||
return rc
|
||||
except:
|
||||
print("Could not create the debugger!")
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
return None
|
||||
|
||||
|
||||
def close():
|
||||
if currentDebugger is not None:
|
||||
currentDebugger.close()
|
||||
|
||||
|
||||
def run(cmd, globals=None, locals=None, start_stepping=1):
|
||||
_GetCurrentDebugger().run(cmd, globals, locals, start_stepping)
|
||||
|
||||
|
||||
def runeval(expression, globals=None, locals=None):
|
||||
return _GetCurrentDebugger().runeval(expression, globals, locals)
|
||||
|
||||
|
||||
def runcall(*args):
|
||||
return _GetCurrentDebugger().runcall(*args)
|
||||
|
||||
|
||||
def set_trace():
|
||||
import sys
|
||||
|
||||
d = _GetCurrentDebugger()
|
||||
|
||||
if d.frameShutdown:
|
||||
return # App closing
|
||||
|
||||
if d.stopframe != d.botframe:
|
||||
# If im not "running"
|
||||
return
|
||||
|
||||
sys.settrace(None) # May be hooked
|
||||
d.reset()
|
||||
d.set_trace()
|
||||
|
||||
|
||||
# "brk" is an alias for "set_trace" ("break" is a reserved word :-(
|
||||
brk = set_trace
|
||||
|
||||
# Post-Mortem interface
|
||||
|
||||
|
||||
def post_mortem(t=None):
|
||||
if t is None:
|
||||
t = sys.exc_info()[2] # Will be valid if we are called from an except handler.
|
||||
if t is None:
|
||||
try:
|
||||
t = sys.last_traceback
|
||||
except AttributeError:
|
||||
print(
|
||||
"No traceback can be found from which to perform post-mortem debugging!"
|
||||
)
|
||||
print("No debugging can continue")
|
||||
return
|
||||
p = _GetCurrentDebugger()
|
||||
if p.frameShutdown:
|
||||
return # App closing
|
||||
# No idea why I need to settrace to None - it should have been reset by now?
|
||||
sys.settrace(None)
|
||||
p.reset()
|
||||
while t.tb_next != None:
|
||||
t = t.tb_next
|
||||
p.bAtPostMortem = 1
|
||||
p.prep_run(None)
|
||||
try:
|
||||
p.interaction(t.tb_frame, t)
|
||||
finally:
|
||||
t = None
|
||||
p.bAtPostMortem = 0
|
||||
p.done_run()
|
||||
|
||||
|
||||
def pm(t=None):
|
||||
post_mortem(t)
|
33
.venv/Lib/site-packages/pythonwin/pywin/debugger/configui.py
Normal file
33
.venv/Lib/site-packages/pythonwin/pywin/debugger/configui.py
Normal file
@ -0,0 +1,33 @@
|
||||
from . import dbgcon
|
||||
from pywin.mfc import dialog
|
||||
import win32ui
|
||||
|
||||
|
||||
class DebuggerOptionsPropPage(dialog.PropertyPage):
|
||||
def __init__(self):
|
||||
dialog.PropertyPage.__init__(self, win32ui.IDD_PP_DEBUGGER)
|
||||
|
||||
def OnInitDialog(self):
|
||||
options = self.options = dbgcon.LoadDebuggerOptions()
|
||||
self.AddDDX(win32ui.IDC_CHECK1, dbgcon.OPT_HIDE)
|
||||
self[dbgcon.OPT_STOP_EXCEPTIONS] = options[dbgcon.OPT_STOP_EXCEPTIONS]
|
||||
self.AddDDX(win32ui.IDC_CHECK2, dbgcon.OPT_STOP_EXCEPTIONS)
|
||||
self[dbgcon.OPT_HIDE] = options[dbgcon.OPT_HIDE]
|
||||
return dialog.PropertyPage.OnInitDialog(self)
|
||||
|
||||
def OnOK(self):
|
||||
self.UpdateData()
|
||||
dirty = 0
|
||||
for key, val in list(self.items()):
|
||||
if key in self.options:
|
||||
if self.options[key] != val:
|
||||
self.options[key] = val
|
||||
dirty = 1
|
||||
if dirty:
|
||||
dbgcon.SaveDebuggerOptions(self.options)
|
||||
# If there is a debugger open, then set its options.
|
||||
import pywin.debugger
|
||||
|
||||
if pywin.debugger.currentDebugger is not None:
|
||||
pywin.debugger.currentDebugger.options = self.options
|
||||
return 1
|
31
.venv/Lib/site-packages/pythonwin/pywin/debugger/dbgcon.py
Normal file
31
.venv/Lib/site-packages/pythonwin/pywin/debugger/dbgcon.py
Normal file
@ -0,0 +1,31 @@
|
||||
# General constants for the debugger
|
||||
|
||||
DBGSTATE_NOT_DEBUGGING = 0
|
||||
DBGSTATE_RUNNING = 1
|
||||
DBGSTATE_BREAK = 2
|
||||
DBGSTATE_QUITTING = 3 # Attempting to back out of the debug session.
|
||||
|
||||
LINESTATE_CURRENT = 0x1 # This line is where we are stopped
|
||||
LINESTATE_BREAKPOINT = 0x2 # This line is a breakpoint
|
||||
LINESTATE_CALLSTACK = 0x4 # This line is in the callstack.
|
||||
|
||||
OPT_HIDE = "hide"
|
||||
OPT_STOP_EXCEPTIONS = "stopatexceptions"
|
||||
|
||||
import win32api, win32ui
|
||||
|
||||
|
||||
def DoGetOption(optsDict, optName, default):
|
||||
optsDict[optName] = win32ui.GetProfileVal("Debugger Options", optName, default)
|
||||
|
||||
|
||||
def LoadDebuggerOptions():
|
||||
opts = {}
|
||||
DoGetOption(opts, OPT_HIDE, 0)
|
||||
DoGetOption(opts, OPT_STOP_EXCEPTIONS, 1)
|
||||
return opts
|
||||
|
||||
|
||||
def SaveDebuggerOptions(opts):
|
||||
for key, val in opts.items():
|
||||
win32ui.WriteProfileVal("Debugger Options", key, val)
|
49
.venv/Lib/site-packages/pythonwin/pywin/debugger/dbgpyapp.py
Normal file
49
.venv/Lib/site-packages/pythonwin/pywin/debugger/dbgpyapp.py
Normal file
@ -0,0 +1,49 @@
|
||||
# dbgpyapp.py - Debugger Python application class
|
||||
#
|
||||
import win32con
|
||||
import win32ui
|
||||
import sys
|
||||
import string
|
||||
import os
|
||||
from pywin.framework import intpyapp
|
||||
|
||||
version = "0.3.0"
|
||||
|
||||
|
||||
class DebuggerPythonApp(intpyapp.InteractivePythonApp):
|
||||
def LoadMainFrame(self):
|
||||
"Create the main applications frame"
|
||||
self.frame = self.CreateMainFrame()
|
||||
self.SetMainFrame(self.frame)
|
||||
self.frame.LoadFrame(win32ui.IDR_DEBUGGER, win32con.WS_OVERLAPPEDWINDOW)
|
||||
self.frame.DragAcceptFiles() # we can accept these.
|
||||
self.frame.ShowWindow(win32con.SW_HIDE)
|
||||
self.frame.UpdateWindow()
|
||||
|
||||
# but we do rehook, hooking the new code objects.
|
||||
self.HookCommands()
|
||||
|
||||
def InitInstance(self):
|
||||
# Use a registry path of "Python\Pythonwin Debugger
|
||||
win32ui.SetAppName(win32ui.LoadString(win32ui.IDR_DEBUGGER))
|
||||
win32ui.SetRegistryKey("Python %s" % (sys.winver,))
|
||||
# We _need_ the Scintilla color editor.
|
||||
# (and we _always_ get it now :-)
|
||||
|
||||
numMRU = win32ui.GetProfileVal("Settings", "Recent File List Size", 10)
|
||||
win32ui.LoadStdProfileSettings(numMRU)
|
||||
|
||||
self.LoadMainFrame()
|
||||
|
||||
# Display the interactive window if the user wants it.
|
||||
from pywin.framework import interact
|
||||
|
||||
interact.CreateInteractiveWindowUserPreference()
|
||||
|
||||
# Load the modules we use internally.
|
||||
self.LoadSystemModules()
|
||||
# Load additional module the user may want.
|
||||
self.LoadUserModules()
|
||||
|
||||
# win32ui.CreateDebuggerThread()
|
||||
win32ui.EnableControlContainer()
|
1104
.venv/Lib/site-packages/pythonwin/pywin/debugger/debugger.py
Normal file
1104
.venv/Lib/site-packages/pythonwin/pywin/debugger/debugger.py
Normal file
File diff suppressed because it is too large
Load Diff
54
.venv/Lib/site-packages/pythonwin/pywin/debugger/fail.py
Normal file
54
.venv/Lib/site-packages/pythonwin/pywin/debugger/fail.py
Normal file
@ -0,0 +1,54 @@
|
||||
# NOTE NOTE - This module is designed to fail!
|
||||
#
|
||||
# The ONLY purpose for this script is testing/demoing the
|
||||
# Pythonwin debugger package.
|
||||
|
||||
# It does nothing useful, and it even doesnt do that!
|
||||
|
||||
import pywin.debugger, sys, time
|
||||
import traceback
|
||||
|
||||
|
||||
def a():
|
||||
a = 1
|
||||
try:
|
||||
b()
|
||||
except:
|
||||
# Break into the debugger with the exception information.
|
||||
pywin.debugger.post_mortem(sys.exc_info()[2])
|
||||
a = 1
|
||||
a = 2
|
||||
a = 3
|
||||
a = 4
|
||||
pass
|
||||
|
||||
|
||||
def b():
|
||||
b = 1
|
||||
pywin.debugger.set_trace()
|
||||
# After importing or running this module, you are likely to be
|
||||
# sitting at the next line. This is because we explicitely
|
||||
# broke into the debugger using the "set_trace() function
|
||||
# "pywin.debugger.brk()" is a shorter alias for this.
|
||||
c()
|
||||
pass
|
||||
|
||||
|
||||
def c():
|
||||
c = 1
|
||||
d()
|
||||
|
||||
|
||||
def d():
|
||||
d = 1
|
||||
e(d)
|
||||
raise ValueError("Hi")
|
||||
|
||||
|
||||
def e(arg):
|
||||
e = 1
|
||||
time.sleep(1)
|
||||
return e
|
||||
|
||||
|
||||
a()
|
Reference in New Issue
Block a user