本文整理汇总了Python中pydev_log.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: patch_args
def patch_args(args):
try:
pydev_log.debug("Patching args: %s"% str(args))
import sys
new_args = []
i = 0
if len(args) == 0:
return args
if is_python(args[0]):
try:
indC = args.index('-c')
except ValueError:
indC = -1
if indC != -1:
import pydevd
host, port = pydevd.dispatch()
if port is not None:
new_args.extend(args)
new_args[indC + 1] = ("import sys; sys.path.append(r'%s'); import pydevd; "
"pydevd.settrace(host='%s', port=%s, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True); %s") % (
pydev_src_dir, host, port, args[indC + 1])
return new_args
else:
new_args.append(args[0])
else:
pydev_log.debug("Process is not python, returning.")
return args
i = 1
while i < len(args):
if args[i].startswith('-'):
new_args.append(args[i])
else:
break
i += 1
if args[i].endswith('pydevd.py'): #no need to add pydevd twice
return args
for x in sys.original_argv:
if sys.platform == "win32" and not x.endswith('"'):
arg = '"%s"' % x
else:
arg = x
new_args.append(arg)
if x == '--file':
break
while i < len(args):
new_args.append(args[i])
i += 1
return new_args
except:
traceback.print_exc()
return args
示例2: _excepthook
def _excepthook(exctype, value, tb):
global _handle_exceptions
if _handle_exceptions:
exception_breakpoint = get_exception_breakpoint(exctype, _handle_exceptions)
else:
exception_breakpoint = None
#Always call the original excepthook before going on to call the debugger post mortem to show it.
_original_excepthook(exctype, value, tb)
if not exception_breakpoint:
return
if tb is None: #sometimes it can be None, e.g. with GTK
return
frames = []
while tb:
frames.append(tb.tb_frame)
tb = tb.tb_next
thread = threadingCurrentThread()
frames_byid = dict([(id(frame),frame) for frame in frames])
frame = frames[-1]
thread.additionalInfo.exception = (exctype, value, tb)
thread.additionalInfo.pydev_force_stop_at_exception = (frame, frames_byid)
thread.additionalInfo.message = exception_breakpoint.qname
debugger = GetGlobalDebugger()
pydevd_tracing.SetTrace(None) #no tracing from here
pydev_log.debug('Handling post-mortem stop on exception breakpoint %s'% exception_breakpoint.qname)
debugger.handle_post_mortem_stop(thread.additionalInfo, thread)
示例3: patch_arg_str_win
def patch_arg_str_win(arg_str):
args = str_to_args_windows(arg_str)
if not is_python(args[0]):
return arg_str
arg_str = args_to_str(patch_args(args))
pydev_log.debug("New args: %s" % arg_str)
return arg_str
示例4: patch_arg_str_win
def patch_arg_str_win(arg_str):
new_arg_str = arg_str.replace('\\', '/')
args = str_to_args(new_arg_str)
if not is_python(args[0]):
return arg_str
arg_str = args_to_str(patch_args(args))
pydev_log.debug("New args: %s"% arg_str)
return arg_str
示例5: _get_project_roots
def _get_project_roots(project_roots_cache=[]):
# Note: the project_roots_cache is the same instance among the many calls to the method
if not project_roots_cache:
roots = os.getenv('IDE_PROJECT_ROOTS', '').split(os.pathsep)
pydev_log.debug("IDE_PROJECT_ROOTS %s\n" % roots)
new_roots = []
for root in roots:
new_roots.append(os.path.normcase(root))
project_roots_cache.append(new_roots)
return project_roots_cache[-1] # returns the project roots with case normalized
示例6: get_source
def get_source(frame):
try:
node = frame.f_locals['self']
if hasattr(node, 'source'):
return node.source
else:
pydev_log.error_once("WARNING: Template path is not available. Please set TEMPLATE_DEBUG=True in your settings.py to make django template breakpoints working")
return None
except:
pydev_log.debug(traceback.format_exc())
return None
示例7: should_stop_on_django_breakpoint
def should_stop_on_django_breakpoint(self, frame, event, arg):
mainDebugger = self._args[0]
thread = self._args[3]
flag = False
template_frame_file = get_template_file_name(frame)
#pydev_log.debug("Django is rendering a template: %s\n" % template_frame_file)
django_breakpoints_for_file = mainDebugger.django_breakpoints.get(template_frame_file)
if django_breakpoints_for_file:
#pydev_log.debug("Breakpoints for that file: %s\n" % django_breakpoints_for_file)
template_frame_line = get_template_line(frame, template_frame_file)
#pydev_log.debug("Tracing template line: %d\n" % template_frame_line)
if DictContains(django_breakpoints_for_file, template_frame_line):
django_breakpoint = django_breakpoints_for_file[template_frame_line]
if django_breakpoint.is_triggered(template_frame_file, template_frame_line):
#pydev_log.debug("Breakpoint is triggered.\n")
flag = True
new_frame = DjangoTemplateFrame(
frame,
template_frame_file=template_frame_file,
template_frame_line=template_frame_line,
)
if django_breakpoint.condition is not None:
try:
val = eval(django_breakpoint.condition, new_frame.f_globals, new_frame.f_locals)
if not val:
flag = False
pydev_log.debug("Condition '%s' is evaluated to %s. Not suspending.\n" % (django_breakpoint.condition, val))
except:
pydev_log.info(
'Error while evaluating condition \'%s\': %s\n' % (django_breakpoint.condition, sys.exc_info()[1]))
if django_breakpoint.expression is not None:
try:
try:
val = eval(django_breakpoint.expression, new_frame.f_globals, new_frame.f_locals)
except:
val = sys.exc_info()[1]
finally:
if val is not None:
thread.additionalInfo.message = val
if flag:
frame = suspend_django(self, mainDebugger, thread, frame)
return flag, frame
示例8: patch_args
def patch_args(args):
try:
pydev_log.debug("Patching args: %s"% str(args))
import sys
new_args = []
i = 0
if len(args) == 0:
return args
if is_python(args[0]):
if '-c' == args[1]:
import pydevd
host, port = pydevd.dispatch()
if port is not None:
args[2] = "import sys; sys.path.append('%s'); import pydevd; pydevd.settrace(host='%s', port=%s, suspend=False); %s"%(helpers, host, port, args[2])
return args
else:
new_args.append(args[0])
else:
pydev_log.debug("Process is not python, returning.")
return args
i = 1
while i < len(args):
if args[i].startswith('-'):
new_args.append(args[i])
else:
break
i+=1
if args[i].endswith('pydevd.py'): #no need to add pydevd twice
return args
for x in sys.original_argv:
if sys.platform == "win32" and not x.endswith('"'):
arg = '"%s"'%x
else:
arg = x
new_args.append(arg)
if x == '--file':
break
while i < len(args):
new_args.append(args[i])
i+=1
return new_args
except:
traceback.print_exc()
return args
示例9: OnRun
def OnRun(self):
self.stopTrace()
buffer = ""
try:
while not self.killReceived:
try:
r = self.sock.recv(1024)
except:
if not self.killReceived:
self.handleExcept()
return #Finished communication.
#Note: the java backend is always expected to pass utf-8 encoded strings. We now work with unicode
#internally and thus, we may need to convert to the actual encoding where needed (i.e.: filenames
#on python 2 may need to be converted to the filesystem encoding).
if hasattr(r, 'decode'):
r = r.decode('utf-8')
buffer += r
if DebugInfoHolder.DEBUG_RECORD_SOCKET_READS:
pydev_log.debug('received >>%s<<\n' % (buffer,))
if len(buffer) == 0:
self.handleExcept()
break
while buffer.find('\n') != -1:
command, buffer = buffer.split('\n', 1)
args = command.split('\t', 2)
try:
cmd_id = int(args[0])
pydev_log.debug('Received command: %s %s\n' % (ID_TO_MEANING.get(str(cmd_id), '???'), command,))
self.processCommand(cmd_id, int(args[1]), args[2])
except:
traceback.print_exc()
sys.stderr.write("Can't process net command: %s\n" % command)
sys.stderr.flush()
except:
traceback.print_exc()
self.handleExcept()
示例10: get_breakpoint
def get_breakpoint(plugin, mainDebugger, pydb_frame, frame, event, args):
mainDebugger, filename, info, thread = args
flag = False
django_breakpoint = None
new_frame = None
type = "django"
if (
event == "call"
and info.pydev_state != STATE_SUSPEND
and mainDebugger.django_breakpoints
and _is_django_render_call(frame)
):
filename = _get_template_file_name(frame)
pydev_log.debug("Django is rendering a template: %s\n" % filename)
django_breakpoints_for_file = mainDebugger.django_breakpoints.get(filename)
if django_breakpoints_for_file:
pydev_log.debug("Breakpoints for that file: %s\n" % django_breakpoints_for_file)
template_line = _get_template_line(frame)
pydev_log.debug("Tracing template line: %d\n" % template_line)
if DictContains(django_breakpoints_for_file, template_line):
django_breakpoint = django_breakpoints_for_file[template_line]
flag = True
new_frame = DjangoTemplateFrame(frame)
return flag, django_breakpoint, new_frame, type
示例11: _get_template_file_name
def _get_template_file_name(frame):
try:
if IS_DJANGO19:
# The Node source was removed since Django 1.9
if DictContains(frame.f_locals, "context"):
context = frame.f_locals["context"]
if (
hasattr(context, "template")
and hasattr(context.template, "origin")
and hasattr(context.template.origin, "name")
):
return context.template.origin.name
return None
source = _get_source(frame)
if source is None:
pydev_log.debug("Source is None\n")
return None
fname = source[0].name
if fname == "<unknown source>":
pydev_log.debug("Source name is %s\n" % fname)
return None
else:
filename, base = GetFileNameAndBaseFromFile(fname)
return filename
except:
pydev_log.debug(traceback.format_exc())
return None
示例12: _get_source
def _get_source(frame):
# This method is usable only for the Django <= 1.8
try:
node = frame.f_locals["self"]
if hasattr(node, "source"):
return node.source
else:
if IS_DJANGO18:
# The debug setting was changed since Django 1.8
pydev_log.error_once(
"WARNING: Template path is not available. Set the 'debug' option in the OPTIONS of a DjangoTemplates "
"backend."
)
else:
# The debug setting for Django < 1.8
pydev_log.error_once(
"WARNING: Template path is not available. Please set TEMPLATE_DEBUG=True in your settings.py to make "
"django template breakpoints working"
)
return None
except:
pydev_log.debug(traceback.format_exc())
return None
示例13: OnRun
def OnRun(self):
self.stopTrace()
buffer = ""
try:
while not self.killReceived:
try:
r = self.sock.recv(1024)
except:
if not self.killReceived:
self.handleExcept()
return #Finished communication.
if IS_PY3K:
r = r.decode('utf-8')
buffer += r
if DebugInfoHolder.DEBUG_RECORD_SOCKET_READS:
pydev_log.debug('received >>%s<<\n' % (buffer,))
if len(buffer) == 0:
self.handleExcept()
break
while buffer.find('\n') != -1:
command, buffer = buffer.split('\n', 1)
pydev_log.debug('Received command: >>%s<<\n' % (command,))
args = command.split('\t', 2)
try:
self.processCommand(int(args[0]), int(args[1]), args[2])
except:
traceback.print_exc()
sys.stderr.write("Can't process net command: %s\n" % command)
sys.stderr.flush()
except:
traceback.print_exc()
self.handleExcept()
示例14: get_template_file_name
def get_template_file_name(frame):
try:
source = get_source(frame)
if source is None:
pydev_log.debug("Source is None\n")
return None
fname = source[0].name
pydev_log.debug("Source name is %s\n" % fname)
filename, base = GetFileNameAndBaseFromFile(fname)
return filename
except:
pydev_log.debug(traceback.format_exc())
return None
示例15: trace
def trace(self, file, line, func_name):
if DebugInfoHolder.DEBUG_TRACE_BREAKPOINTS > 0:
pydev_log.debug("Added breakpoint:%s - line:%s - func_name:%s\n" % (file, line, func_name))
sys.stderr.flush()