_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q271700 | Model.delete | test | def delete(self, **kwargs):
'''
Deletes the entity immediately. Also performs any on_delete operations
specified as part of column definitions.
'''
if kwargs.get('skip_on_delete_i_really_mean_it') is not SKIP_ON_DELETE:
# handle the pre-commit hook
self._b... | python | {
"resource": ""
} |
q271701 | Model.get | test | def get(cls, ids):
'''
Will fetch one or more entities of this type from the session or
Redis.
Used like::
MyModel.get(5)
MyModel.get([1, 6, 2, 4])
Passing a list or a tuple will return multiple entities, in the same
order that the ids were pass... | python | {
"resource": ""
} |
q271702 | _ReducerRegistry.register | test | def register(cls, type, reduce_func):
"""Attach a reducer function to a given type in the dispatch table."""
if sys.version_info < (3,):
# Python 2 pickler dispatching is not explicitly customizable.
# Let us use a closure to workaround this limitation.
def dispatcher... | python | {
"resource": ""
} |
q271703 | _sem_open | test | def _sem_open(name, value=None):
""" Construct or retrieve a semaphore with the given name
If value is None, try to retrieve an existing named semaphore.
Else create a new semaphore with the given value
"""
if value is None:
handle = pthread.sem_open(ctypes.c_char_p(name), 0)
else:
... | python | {
"resource": ""
} |
q271704 | cpu_count | test | def cpu_count():
"""Return the number of CPUs the current process can use.
The returned number of CPUs accounts for:
* the number of CPUs in the system, as given by
``multiprocessing.cpu_count``;
* the CPU affinity settings of the current process
(available with Python 3.4+ on some Unix... | python | {
"resource": ""
} |
q271705 | _sendback_result | test | def _sendback_result(result_queue, work_id, result=None, exception=None):
"""Safely send back the given result or exception"""
try:
result_queue.put(_ResultItem(work_id, result=result,
exception=exception))
except BaseException as e:
exc = _ExceptionWithT... | python | {
"resource": ""
} |
q271706 | _process_worker | test | def _process_worker(call_queue, result_queue, initializer, initargs,
processes_management_lock, timeout, worker_exit_lock,
current_depth):
"""Evaluates calls from call_queue and places the results in result_queue.
This worker is run in a separate process.
Args:
... | python | {
"resource": ""
} |
q271707 | _add_call_item_to_queue | test | def _add_call_item_to_queue(pending_work_items,
running_work_items,
work_ids,
call_queue):
"""Fills call_queue with _WorkItems from pending_work_items.
This function never blocks.
Args:
pending_work_items: A dict m... | python | {
"resource": ""
} |
q271708 | ProcessPoolExecutor._ensure_executor_running | test | def _ensure_executor_running(self):
"""ensures all workers and management thread are running
"""
with self._processes_management_lock:
if len(self._processes) != self._max_workers:
self._adjust_process_count()
self._start_queue_management_thread() | python | {
"resource": ""
} |
q271709 | wrap_non_picklable_objects | test | def wrap_non_picklable_objects(obj, keep_wrapper=True):
"""Wrapper for non-picklable object to use cloudpickle to serialize them.
Note that this wrapper tends to slow down the serialization process as it
is done with cloudpickle which is typically slower compared to pickle. The
proper way to solve seri... | python | {
"resource": ""
} |
q271710 | LokyManager.start | test | def start(self, initializer=None, initargs=()):
'''Spawn a server process for this manager object'''
assert self._state.value == State.INITIAL
if (initializer is not None
and not hasattr(initializer, '__call__')):
raise TypeError('initializer must be a callable')
... | python | {
"resource": ""
} |
q271711 | DupFd | test | def DupFd(fd):
'''Return a wrapper for an fd.'''
popen_obj = get_spawning_popen()
if popen_obj is not None:
return popen_obj.DupFd(popen_obj.duplicate_for_child(fd))
elif HAVE_SEND_HANDLE and sys.version_info[:2] > (3, 3):
from multiprocessing import resource_sharer
return resour... | python | {
"resource": ""
} |
q271712 | get_reusable_executor | test | def get_reusable_executor(max_workers=None, context=None, timeout=10,
kill_workers=False, reuse="auto",
job_reducers=None, result_reducers=None,
initializer=None, initargs=()):
"""Return the current ReusableExectutor instance.
Start ... | python | {
"resource": ""
} |
q271713 | _ReusablePoolExecutor._wait_job_completion | test | def _wait_job_completion(self):
"""Wait for the cache to be empty before resizing the pool."""
# Issue a warning to the user about the bad effect of this usage.
if len(self._pending_work_items) > 0:
warnings.warn("Trying to resize an executor with running jobs: "
... | python | {
"resource": ""
} |
q271714 | get_preparation_data | test | def get_preparation_data(name, init_main_module=True):
'''
Return info about parent needed by child to unpickle process object
'''
_check_not_importing_main()
d = dict(
log_to_stderr=util._log_to_stderr,
authkey=bytes(process.current_process().authkey),
)
if util._logger is ... | python | {
"resource": ""
} |
q271715 | prepare | test | def prepare(data):
'''
Try to get current process ready to unpickle process object
'''
if 'name' in data:
process.current_process().name = data['name']
if 'authkey' in data:
process.current_process().authkey = data['authkey']
if 'log_to_stderr' in data and data['log_to_stderr']... | python | {
"resource": ""
} |
q271716 | close_fds | test | def close_fds(keep_fds): # pragma: no cover
"""Close all the file descriptors except those in keep_fds."""
# Make sure to keep stdout and stderr open for logging purpose
keep_fds = set(keep_fds).union([1, 2])
# We try to retrieve all the open fds
try:
open_fds = set(int(fd) for fd in os.l... | python | {
"resource": ""
} |
q271717 | _recursive_terminate_without_psutil | test | def _recursive_terminate_without_psutil(process):
"""Terminate a process and its descendants.
"""
try:
_recursive_terminate(process.pid)
except OSError as e:
warnings.warn("Failed to kill subprocesses on this platform. Please"
"install psutil: https://github.com/gia... | python | {
"resource": ""
} |
q271718 | _recursive_terminate | test | def _recursive_terminate(pid):
"""Recursively kill the descendants of a process before killing it.
"""
if sys.platform == "win32":
# On windows, the taskkill function with option `/T` terminate a given
# process pid and its children.
try:
subprocess.check_output(
... | python | {
"resource": ""
} |
q271719 | get_exitcodes_terminated_worker | test | def get_exitcodes_terminated_worker(processes):
"""Return a formated string with the exitcodes of terminated workers.
If necessary, wait (up to .25s) for the system to correctly set the
exitcode of one terminated worker.
"""
patience = 5
# Catch the exitcode of the terminated workers. There sh... | python | {
"resource": ""
} |
q271720 | _format_exitcodes | test | def _format_exitcodes(exitcodes):
"""Format a list of exit code with names of the signals if possible"""
str_exitcodes = ["{}({})".format(_get_exitcode_name(e), e)
for e in exitcodes if e is not None]
return "{" + ", ".join(str_exitcodes) + "}" | python | {
"resource": ""
} |
q271721 | main | test | def main(fd, verbose=0):
'''Run semaphore tracker.'''
# protect the process from ^C and "killall python" etc
signal.signal(signal.SIGINT, signal.SIG_IGN)
signal.signal(signal.SIGTERM, signal.SIG_IGN)
if _HAVE_SIGMASK:
signal.pthread_sigmask(signal.SIG_UNBLOCK, _IGNORED_SIGNALS)
for f i... | python | {
"resource": ""
} |
q271722 | SemaphoreTracker.ensure_running | test | def ensure_running(self):
'''Make sure that semaphore tracker process is running.
This can be run from any process. Usually a child process will use
the semaphore created by its parent.'''
with self._lock:
if self._fd is not None:
# semaphore tracker was lau... | python | {
"resource": ""
} |
q271723 | PrintProcessor.event_processor | test | def event_processor(self, frame, event, arg):
'A simple event processor that prints out events.'
out = self.debugger.intf[-1].output
lineno = frame.f_lineno
filename = self.core.canonic_filename(frame)
filename = self.core.filename(filename)
if not out:
print(... | python | {
"resource": ""
} |
q271724 | InfoPC.run | test | def run(self, args):
"""Program counter."""
mainfile = self.core.filename(None)
if self.core.is_running():
curframe = self.proc.curframe
if curframe:
line_no = inspect.getlineno(curframe)
offset = curframe.f_lasti
self.msg(... | python | {
"resource": ""
} |
q271725 | interact | test | def interact(banner=None, readfunc=None, my_locals=None, my_globals=None):
"""Almost a copy of code.interact
Closely emulate the interactive Python interpreter.
This is a backwards compatible interface to the InteractiveConsole
class. When readfunc is not specified, it attempts to import the
readl... | python | {
"resource": ""
} |
q271726 | arg_split | test | def arg_split(s, posix=False):
"""Split a command line's arguments in a shell-like manner returned
as a list of lists. Use ';;' with white space to indicate separate
commands.
This is a modified version of the standard library's shlex.split()
function, but with a default of posix=False for splittin... | python | {
"resource": ""
} |
q271727 | get_stack | test | def get_stack(f, t, botframe, proc_obj=None):
"""Return a stack of frames which the debugger will use for in
showing backtraces and in frame switching. As such various frame
that are really around may be excluded unless we are debugging the
sebugger. Also we will add traceback frame on top if that
e... | python | {
"resource": ""
} |
q271728 | run_hooks | test | def run_hooks(obj, hooks, *args):
"""Run each function in `hooks' with args"""
for hook in hooks:
if hook(obj, *args): return True
pass
return False | python | {
"resource": ""
} |
q271729 | CommandProcessor.forget | test | def forget(self):
""" Remove memory of state variables set in the command processor """
self.stack = []
self.curindex = 0
self.curframe = None
self.thread_name = None
self.frame_thread_name = None
return | python | {
"resource": ""
} |
q271730 | CommandProcessor.get_int_noerr | test | def get_int_noerr(self, arg):
"""Eval arg and it is an integer return the value. Otherwise
return None"""
if self.curframe:
g = self.curframe.f_globals
l = self.curframe.f_locals
else:
g = globals()
l = locals()
pass
try... | python | {
"resource": ""
} |
q271731 | CommandProcessor.get_int | test | def get_int(self, arg, min_value=0, default=1, cmdname=None,
at_most=None):
"""If no argument use the default. If arg is a an integer between
least min_value and at_most, use that. Otherwise report an error.
If there's a stack frame use that in evaluation."""
if arg is N... | python | {
"resource": ""
} |
q271732 | CommandProcessor.process_commands | test | def process_commands(self):
"""Handle debugger commands."""
if self.core.execution_status != 'No program':
self.setup()
self.location()
pass
leave_loop = run_hooks(self, self.preloop_hooks)
self.continue_running = False
while not leave_loop:
... | python | {
"resource": ""
} |
q271733 | CommandProcessor.queue_startfile | test | def queue_startfile(self, cmdfile):
"""Arrange for file of debugger commands to get read in the
process-command loop."""
expanded_cmdfile = os.path.expanduser(cmdfile)
is_readable = Mfile.readable(expanded_cmdfile)
if is_readable:
self.cmd_queue.append('source ' + exp... | python | {
"resource": ""
} |
q271734 | next_token | test | def next_token(str, start_pos):
"""Find the next token in str string from start_pos, we return
the token and the next blank position after the token or
str.size if this is the last token. Tokens are delimited by
white space."""
look_at = str[start_pos:]
match = re.search('\S', look_at)
if ma... | python | {
"resource": ""
} |
q271735 | ScriptInterface.errmsg | test | def errmsg(self, msg, prefix="** "):
"""Common routine for reporting debugger error messages.
"""
# self.verbose shows lines so we don't have to duplicate info
# here. Perhaps there should be a 'terse' mode to never show
# position info.
if not self.verbose:
... | python | {
"resource": ""
} |
q271736 | ScriptInterface.read_command | test | def read_command(self, prompt=''):
'''Script interface to read a command. `prompt' is a parameter for
compatibilty and is ignored.'''
self.input_lineno += 1
line = self.readline()
if self.verbose:
location = "%s line %s" % (self.script_name, self.input_lineno)
... | python | {
"resource": ""
} |
q271737 | FIFOClient.close | test | def close(self):
""" Closes both input and output """
self.state = 'closing'
if self.input:
self.input.close()
pass
if self.output:
self.output.close()
pass
self.state = 'disconnnected'
return | python | {
"resource": ""
} |
q271738 | disassemble | test | def disassemble(msg, msg_nocr, section, co, lasti=-1, start_line=-1,
end_line=None, relative_pos=False, highlight='light',
start_offset=0, end_offset=None):
"""Disassemble a code object."""
return disassemble_bytes(msg, msg_nocr, co.co_code, lasti, co.co_firstlineno,
... | python | {
"resource": ""
} |
q271739 | disassemble_bytes | test | def disassemble_bytes(orig_msg, orig_msg_nocr, code, lasti=-1, cur_line=0,
start_line=-1, end_line=None, relative_pos=False,
varnames=(), names=(), constants=(), cells=(),
freevars=(), linestarts={}, highlight='light',
start_offset=... | python | {
"resource": ""
} |
q271740 | count_frames | test | def count_frames(frame, count_start=0):
"Return a count of the number of frames"
count = -count_start
while frame:
count += 1
frame = frame.f_back
return count | python | {
"resource": ""
} |
q271741 | get_call_function_name | test | def get_call_function_name(frame):
"""If f_back is looking at a call function, return
the name for it. Otherwise return None"""
f_back = frame.f_back
if not f_back: return None
if 'CALL_FUNCTION' != Mbytecode.op_at_frame(f_back): return None
co = f_back.f_code
code = co.co_cod... | python | {
"resource": ""
} |
q271742 | print_stack_trace | test | def print_stack_trace(proc_obj, count=None, color='plain', opts={}):
"Print count entries of the stack trace"
if count is None:
n=len(proc_obj.stack)
else:
n=min(len(proc_obj.stack), count)
try:
for i in range(n):
print_stack_entry(proc_obj, i, color=color, opts=opts)... | python | {
"resource": ""
} |
q271743 | Subcmd.lookup | test | def lookup(self, subcmd_prefix):
"""Find subcmd in self.subcmds"""
for subcmd_name in list(self.subcmds.keys()):
if subcmd_name.startswith(subcmd_prefix) \
and len(subcmd_prefix) >= \
self.subcmds[subcmd_name].__class__.min_abbrev:
return self.su... | python | {
"resource": ""
} |
q271744 | Subcmd.short_help | test | def short_help(self, subcmd_cb, subcmd_name, label=False):
"""Show short help for a subcommand."""
entry = self.lookup(subcmd_name)
if entry:
if label:
prefix = entry.name
else:
prefix = ''
pass
if hasattr(entry,... | python | {
"resource": ""
} |
q271745 | Subcmd.add | test | def add(self, subcmd_cb):
"""Add subcmd to the available subcommands for this object.
It will have the supplied docstring, and subcmd_cb will be called
when we want to run the command. min_len is the minimum length
allowed to abbreviate the command. in_list indicates with the
sho... | python | {
"resource": ""
} |
q271746 | Subcmd.run | test | def run(self, subcmd_name, arg):
"""Run subcmd_name with args using obj for the environent"""
entry=self.lookup(subcmd_name)
if entry:
entry['callback'](arg)
else:
self.cmdproc.undefined_cmd(entry.__class__.name, subcmd_name)
pass
return | python | {
"resource": ""
} |
q271747 | debug | test | def debug(dbg_opts=None, start_opts=None, post_mortem=True,
step_ignore=1, level=0):
"""
Enter the debugger.
Parameters
----------
level : how many stack frames go back. Usually it will be
the default 0. But sometimes though there may be calls in setup to the debugger
that you may want to skip.
step_ig... | python | {
"resource": ""
} |
q271748 | HelpCommand.show_category | test | def show_category(self, category, args):
"""Show short help for all commands in `category'."""
n2cmd = self.proc.commands
names = list(n2cmd.keys())
if len(args) == 1 and args[0] == '*':
self.section("Commands in class %s:" % category)
cmds = [cmd for cmd in names... | python | {
"resource": ""
} |
q271749 | InfoLine.run | test | def run(self, args):
"""Current line number in source file"""
# info line identifier
if not self.proc.curframe:
self.errmsg("No line number information available.")
return
if len(args) == 3:
# lineinfo returns (item, file, lineno) or (None,)
... | python | {
"resource": ""
} |
q271750 | find_debugged_frame | test | def find_debugged_frame(frame):
"""Find the first frame that is a debugged frame. We do this
Generally we want traceback information without polluting it with
debugger frames. We can tell these because those are frames on the
top which don't have f_trace set. So we'll look back from the top
to find ... | python | {
"resource": ""
} |
q271751 | map_thread_names | test | def map_thread_names():
'''Invert threading._active'''
name2id = {}
for thread_id in list(threading._active.keys()):
thread = threading._active[thread_id]
name = thread.getName()
if name not in list(name2id.keys()):
name2id[name] = thread_id
pass
pass
... | python | {
"resource": ""
} |
q271752 | get_int | test | def get_int(errmsg, arg, default=1, cmdname=None):
"""If arg is an int, use that otherwise take default."""
if arg:
try:
# eval() is used so we will allow arithmetic expressions,
# variables etc.
default = int(eval(arg))
except (SyntaxError, NameError, ValueEr... | python | {
"resource": ""
} |
q271753 | get_onoff | test | def get_onoff(errmsg, arg, default=None, print_error=True):
"""Return True if arg is 'on' or 1 and False arg is 'off' or 0.
Any other value is raises ValueError."""
if not arg:
if default is None:
if print_error:
errmsg("Expecting 'on', 1, 'off', or 0. Got nothing.")
... | python | {
"resource": ""
} |
q271754 | run_set_bool | test | def run_set_bool(obj, args):
"""set a Boolean-valued debugger setting. 'obj' is a generally a
subcommand that has 'name' and 'debugger.settings' attributes"""
try:
if 0 == len(args): args = ['on']
obj.debugger.settings[obj.name] = get_onoff(obj.errmsg, args[0])
except ValueError:
... | python | {
"resource": ""
} |
q271755 | run_set_int | test | def run_set_int(obj, arg, msg_on_error, min_value=None, max_value=None):
"""set an Integer-valued debugger setting. 'obj' is a generally a
subcommand that has 'name' and 'debugger.settings' attributes"""
if '' == arg.strip():
obj.errmsg("You need to supply a number.")
return
obj.debugger... | python | {
"resource": ""
} |
q271756 | run_show_bool | test | def run_show_bool(obj, what=None):
"""Generic subcommand showing a boolean-valued debugger setting.
'obj' is generally a subcommand that has 'name' and
'debugger.setting' attributes."""
val = show_onoff(obj.debugger.settings[obj.name])
if not what: what = obj.name
return obj.msg("%s is %s." % (w... | python | {
"resource": ""
} |
q271757 | run_show_int | test | def run_show_int(obj, what=None):
"""Generic subcommand integer value display"""
val = obj.debugger.settings[obj.name]
if not what: what = obj.name
return obj.msg("%s is %d." % (what, val)) | python | {
"resource": ""
} |
q271758 | run_show_val | test | def run_show_val(obj, name):
"""Generic subcommand value display"""
val = obj.debugger.settings[obj.name]
obj.msg("%s is %s." % (obj.name, obj.cmd.proc._saferepr(val),))
return False | python | {
"resource": ""
} |
q271759 | is_def_stmt | test | def is_def_stmt(line, frame):
"""Return True if we are looking at a def statement"""
# Should really also check that operand of 'LOAD_CONST' is a code object
return (line and _re_def.match(line) and op_at_frame(frame)=='LOAD_CONST'
and stmt_contains_opcode(frame.f_code, frame.f_lineno,
... | python | {
"resource": ""
} |
q271760 | is_class_def | test | def is_class_def(line, frame):
"""Return True if we are looking at a class definition statement"""
return (line and _re_class.match(line)
and stmt_contains_opcode(frame.f_code, frame.f_lineno,
'BUILD_CLASS')) | python | {
"resource": ""
} |
q271761 | QuitCommand.threaded_quit | test | def threaded_quit(self, arg):
""" quit command when several threads are involved. """
threading_list = threading.enumerate()
mythread = threading.currentThread()
for t in threading_list:
if t != mythread:
ctype_async_raise(t, Mexcept.DebuggerQuit)
... | python | {
"resource": ""
} |
q271762 | set_default_bg | test | def set_default_bg():
"""Get bacground from
default values based on the TERM environment variable
"""
term = environ.get('TERM', None)
if term:
if (term.startswith('xterm',) or term.startswith('eterm')
or term == 'dtterm'):
return False
return True | python | {
"resource": ""
} |
q271763 | is_dark_rgb | test | def is_dark_rgb(r, g, b):
"""Pass as parameters R G B values in hex
On return, variable is_dark_bg is set
"""
try:
midpoint = int(environ.get('TERMINAL_COLOR_MIDPOINT', None))
except:
pass
if not midpoint:
term = environ.get('TERM', None)
# 117963 = (* .6 (+ 6553... | python | {
"resource": ""
} |
q271764 | signature | test | def signature(frame):
'''return suitable frame signature to key display expressions off of.'''
if not frame: return None
code = frame.f_code
return (code.co_name, code.co_filename, code.co_firstlineno) | python | {
"resource": ""
} |
q271765 | DisplayMgr.all | test | def all(self):
"""List all display items; return 0 if none"""
found = False
s = []
for display in self.list:
if not found:
s.append("""Auto-display expressions now in effect:
Num Enb Expression""")
found = True
pass
... | python | {
"resource": ""
} |
q271766 | DisplayMgr.display | test | def display(self, frame):
'''display any items that are active'''
if not frame: return
s = []
sig = signature(frame)
for display in self.list:
if display.signature == sig and display.enabled:
s.append(display.to_s(frame))
pass
... | python | {
"resource": ""
} |
q271767 | Display.format | test | def format(self, show_enabled=True):
'''format display item'''
what = ''
if show_enabled:
if self.enabled:
what += ' y '
else:
what += ' n '
pass
pass
if self.fmt:
what += self.fmt + ' '
... | python | {
"resource": ""
} |
q271768 | TCPClient.read_msg | test | def read_msg(self):
"""Read one message unit. It's possible however that
more than one message will be set in a receive, so we will
have to buffer that for the next read.
EOFError will be raised on EOF.
"""
if self.state == 'connected':
if 0 == len(self.buf):
... | python | {
"resource": ""
} |
q271769 | debug | test | def debug(frame=None):
"""Set breakpoint at current location, or a specified frame"""
# ???
if frame is None:
frame = _frame().f_back
dbg = RemoteCeleryTrepan()
dbg.say(BANNER.format(self=dbg))
# dbg.say(SESSION_STARTED.format(self=dbg))
trepan.api.debug(dbg_opts=dbg.dbg_opts) | python | {
"resource": ""
} |
q271770 | SubcommandMgr.undefined_subcmd | test | def undefined_subcmd(self, cmd, subcmd):
"""Error message when subcommand asked for but doesn't exist"""
self.proc.intf[-1].errmsg(('Undefined "%s" subcommand: "%s". ' +
'Try "help %s *".') % (cmd, subcmd, cmd))
return | python | {
"resource": ""
} |
q271771 | FrameCommand.run | test | def run(self, args):
'''Run a frame command. This routine is a little complex
because we allow a number parameter variations.'''
if len(args) == 1:
# Form is: "frame" which means "frame 0"
position_str = '0'
elif len(args) == 2:
# Form is: "frame {pos... | python | {
"resource": ""
} |
q271772 | pprint_simple_array | test | def pprint_simple_array(val, displaywidth, msg_nocr, msg, lineprefix=''):
'''Try to pretty print a simple case where a list is not nested.
Return True if we can do it and False if not. '''
if type(val) != list:
return False
numeric = True
for i in range(len(val)):
if not (type(val[... | python | {
"resource": ""
} |
q271773 | lookup_signame | test | def lookup_signame(num):
"""Find the corresponding signal name for 'num'. Return None
if 'num' is invalid."""
signames = signal.__dict__
num = abs(num)
for signame in list(signames.keys()):
if signame.startswith('SIG') and signames[signame] == num:
return signame
pass
... | python | {
"resource": ""
} |
q271774 | lookup_signum | test | def lookup_signum(name):
"""Find the corresponding signal number for 'name'. Return None
if 'name' is invalid."""
uname = name.upper()
if (uname.startswith('SIG') and hasattr(signal, uname)):
return getattr(signal, uname)
else:
uname = "SIG"+uname
if hasattr(signal, uname):
... | python | {
"resource": ""
} |
q271775 | canonic_signame | test | def canonic_signame(name_num):
"""Return a signal name for a signal name or signal
number. Return None is name_num is an int but not a valid signal
number and False if name_num is a not number. If name_num is a
signal name or signal number, the canonic if name is returned."""
signum = lookup_signum... | python | {
"resource": ""
} |
q271776 | SignalManager.set_signal_replacement | test | def set_signal_replacement(self, signum, handle):
"""A replacement for signal.signal which chains the signal behind
the debugger's handler"""
signame = lookup_signame(signum)
if signame is None:
self.dbgr.intf[-1].errmsg(("%s is not a signal number"
... | python | {
"resource": ""
} |
q271777 | SignalManager.check_and_adjust_sighandlers | test | def check_and_adjust_sighandlers(self):
"""Check to see if any of the signal handlers we are interested in have
changed or is not initially set. Change any that are not right. """
for signame in list(self.sigs.keys()):
if not self.check_and_adjust_sighandler(signame, self.sigs):
... | python | {
"resource": ""
} |
q271778 | SignalManager.info_signal | test | def info_signal(self, args):
"""Print information about a signal"""
if len(args) == 0: return None
signame = args[0]
if signame in ['handle', 'signal']:
# This has come from dbgr's info command
if len(args) == 1:
# Show all signal handlers
... | python | {
"resource": ""
} |
q271779 | SignalManager.action | test | def action(self, arg):
"""Delegate the actions specified in 'arg' to another
method.
"""
if not arg:
self.info_signal(['handle'])
return True
args = arg.split()
signame = args[0]
signame = self.is_name_or_number(args[0])
if not sign... | python | {
"resource": ""
} |
q271780 | SignalManager.handle_print | test | def handle_print(self, signame, set_print):
"""Set whether we print or not when this signal is caught."""
if set_print:
self.sigs[signame].print_method = self.dbgr.intf[-1].msg
else:
self.sigs[signame].print_method = None
pass
return set_print | python | {
"resource": ""
} |
q271781 | SigHandler.handle | test | def handle(self, signum, frame):
"""This method is called when a signal is received."""
if self.print_method:
self.print_method('\nProgram received signal %s.'
% self.signame)
if self.print_stack:
import traceback
strings = traceb... | python | {
"resource": ""
} |
q271782 | file2module | test | def file2module(filename):
"""Given a file name, extract the most likely module name. """
basename = osp.basename(filename)
if '.' in basename:
pos = basename.rfind('.')
return basename[:pos]
else:
return basename
return None | python | {
"resource": ""
} |
q271783 | search_file | test | def search_file(filename, directories, cdir):
"""Return a full pathname for filename if we can find one. path
is a list of directories to prepend to filename. If no file is
found we'll return None"""
for trydir in directories:
# Handle $cwd and $cdir
if trydir =='$cwd': trydir='.'
... | python | {
"resource": ""
} |
q271784 | whence_file | test | def whence_file(py_script, dirnames=None):
"""Do a shell-like path lookup for py_script and return the results.
If we can't find anything return py_script"""
if py_script.find(os.sep) != -1:
# Don't search since this name has path separator components
return py_script
if dirnames is None... | python | {
"resource": ""
} |
q271785 | pyfiles | test | def pyfiles(callername, level=2):
"All python files caller's dir without the path and trailing .py"
d = os.path.dirname(callername)
# Get the name of our directory.
# A glob pattern that will get all *.py files but not __init__.py
glob(os.path.join(d, '[a-zA-Z]*.py'))
py_files = glob(os.path.joi... | python | {
"resource": ""
} |
q271786 | TrepanInterface.msg | test | def msg(self, msg):
""" used to write to a debugger that is connected to this
server; `str' written will have a newline added to it
"""
if hasattr(self.output, 'writeline'):
self.output.writeline(msg)
elif hasattr(self.output, 'writelines'):
self.output.wr... | python | {
"resource": ""
} |
q271787 | InfoProgram.run | test | def run(self, args):
"""Execution status of the program."""
mainfile = self.core.filename(None)
if self.core.is_running():
if mainfile:
part1 = "Python program '%s' is stopped" % mainfile
else:
part1 = 'Program is stopped'
p... | python | {
"resource": ""
} |
q271788 | DebuggerCommand.columnize_commands | test | def columnize_commands(self, commands):
"""List commands arranged in an aligned columns"""
commands.sort()
width = self.debugger.settings['width']
return columnize.columnize(commands, displaywidth=width,
lineprefix=' ') | python | {
"resource": ""
} |
q271789 | post_mortem | test | def post_mortem(exc=None, frameno=1, dbg=None):
"""Enter debugger read loop after your program has crashed.
exc is a triple like you get back from sys.exc_info. If no exc
parameter, is supplied, the values from sys.last_type,
sys.last_value, sys.last_traceback are used. And if these don't
exist ei... | python | {
"resource": ""
} |
q271790 | TCPServer.close | test | def close(self):
""" Closes both socket and server connection. """
self.state = 'closing'
if self.inout:
self.inout.close()
pass
self.state = 'closing connection'
if self.conn:
self.conn.close()
self.state = 'disconnected'
retur... | python | {
"resource": ""
} |
q271791 | TCPServer.write | test | def write(self, msg):
""" This method the debugger uses to write. In contrast to
writeline, no newline is added to the end to `str'. Also
msg doesn't have to be a string.
"""
if self.state != 'connected':
self.wait_for_connect()
pass
buffer = Mtcpf... | python | {
"resource": ""
} |
q271792 | complete_identifier | test | def complete_identifier(cmd, prefix):
'''Complete an arbitrary expression.'''
if not cmd.proc.curframe: return [None]
# Collect globals and locals. It is usually not really sensible to also
# complete builtins, and they clutter the namespace quite heavily, so we
# leave them out.
ns = cmd.proc.... | python | {
"resource": ""
} |
q271793 | PythonCommand.dbgr | test | def dbgr(self, string):
'''Invoke a debugger command from inside a python shell called inside
the debugger.
'''
print('')
self.proc.cmd_queue.append(string)
self.proc.process_command()
return | python | {
"resource": ""
} |
q271794 | TrepanCore.add_ignore | test | def add_ignore(self, *frames_or_fns):
"""Add `frame_or_fn' to the list of functions that are not to
be debugged"""
for frame_or_fn in frames_or_fns:
rc = self.ignore_filter.add_include(frame_or_fn)
pass
return rc | python | {
"resource": ""
} |
q271795 | TrepanCore.canonic | test | def canonic(self, filename):
""" Turns `filename' into its canonic representation and returns this
string. This allows a user to refer to a given file in one of several
equivalent ways.
Relative filenames need to be fully resolved, since the current working
directory might chang... | python | {
"resource": ""
} |
q271796 | TrepanCore.filename | test | def filename(self, filename=None):
"""Return filename or the basename of that depending on the
basename setting"""
if filename is None:
if self.debugger.mainpyfile:
filename = self.debugger.mainpyfile
else:
return None
if self.debug... | python | {
"resource": ""
} |
q271797 | TrepanCore.is_started | test | def is_started(self):
'''Return True if debugging is in progress.'''
return (tracer.is_started() and
not self.trace_hook_suspend
and tracer.find_hook(self.trace_dispatch)) | python | {
"resource": ""
} |
q271798 | TrepanCore.is_stop_here | test | def is_stop_here(self, frame, event, arg):
""" Does the magic to determine if we stop here and run a
command processor or not. If so, return True and set
self.stop_reason; if not, return False.
Determining factors can be whether a breakpoint was
encountered, whether we are stepp... | python | {
"resource": ""
} |
q271799 | TrepanCore.set_next | test | def set_next(self, frame, step_ignore=0, step_events=None):
"Sets to stop on the next event that happens in frame 'frame'."
self.step_events = None # Consider all events
self.stop_level = Mstack.count_frames(frame)
self.last_level = self.stop_level
self.last_fra... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.