当前位置: 首页>>代码示例>>Python>>正文


Python pudb.set_trace方法代码示例

本文整理汇总了Python中pudb.set_trace方法的典型用法代码示例。如果您正苦于以下问题:Python pudb.set_trace方法的具体用法?Python pudb.set_trace怎么用?Python pudb.set_trace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pudb的用法示例。


在下文中一共展示了pudb.set_trace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_trace

# 需要导入模块: import pudb [as 别名]
# 或者: from pudb import set_trace [as 别名]
def set_trace(addr='127.0.0.1', port=4444):
    # Backup stdin and stdout before replacing them by the socket handle
    old_stdout = sys.stdout
    old_stdin = sys.stdin

    # Run telnet server and get the new fds
    (pid, stdout, stdin) = run_telnet_server(addr, port)
    sys.stdout = stdout
    sys.stdin = stdin

    # Kill children on exit.
    def cleanup():
        print('Killing server...')
        os.kill(pid, signal.SIGKILL)
    atexit.register(cleanup)
    def signal_handler(signal, frame):
        sys.exit(0)
    signal.signal(signal.SIGINT, signal_handler)

    # Finally, run pudb
    pudb.set_trace() 
开发者ID:msbrogli,项目名称:rpudb,代码行数:23,代码来源:__init__.py

示例2: app_service_call

# 需要导入模块: import pudb [as 别名]
# 或者: from pudb import set_trace [as 别名]
def app_service_call(self, d_msg):
        """
        This method sends the JSON 'msg' argument to the remote service.
        """
        b_httpResponseBodyParse = True

        # pudb.set_trace()
        str_http = settings.PFCON_URL

        serviceCall = pfurl.Pfurl(
            msg                     = json.dumps(d_msg),
            http                    = str_http,
            verb                    = 'POST',
            # contentType             = 'application/json',
            b_raw                   = True,
            b_quiet                 = True,
            b_httpResponseBodyParse = b_httpResponseBodyParse,
            jsonwrapper             = 'payload',
        )
        # speak to the service...
        d_response = json.loads(serviceCall())
        if not b_httpResponseBodyParse:
            d_response = parse_qs(d_response)
        return d_response 
开发者ID:FNNDSC,项目名称:ChRIS_ultron_backEnd,代码行数:26,代码来源:charm.py

示例3: urlify

# 需要导入模块: import pudb [as 别名]
# 或者: from pudb import set_trace [as 别名]
def urlify(astr, astr_join = '_'):
        # Remove all non-word characters (everything except numbers and letters)
        # pudb.set_trace()
        astr = re.sub(r"[^\w\s]", '', astr)

        # Replace all runs of whitespace with an underscore
        astr = re.sub(r"\s+", astr_join, astr)

        return astr 
开发者ID:FNNDSC,项目名称:med2image,代码行数:11,代码来源:med2image.py

示例4: break_in_pudb

# 需要导入模块: import pudb [as 别名]
# 或者: from pudb import set_trace [as 别名]
def break_in_pudb(func):                                    # pragma: debugging
    """A function decorator to stop in the debugger for each call."""
    @functools.wraps(func)
    def _wrapper(*args, **kwargs):
        import pudb
        sys.stdout = sys.__stdout__
        pudb.set_trace()
        return func(*args, **kwargs)
    return _wrapper 
开发者ID:nedbat,项目名称:coveragepy,代码行数:11,代码来源:debug.py

示例5: ag_call

# 需要导入模块: import pudb [as 别名]
# 或者: from pudb import set_trace [as 别名]
def ag_call(
    func, *args, expected_rc=None, new_only=True, headers=None, no_cache=False, **kwargs
):
    """
    Wrap AGitHub calls with basic error detection

    Not smart, and hides any error information from caller.
    But very convenient. :)
    """

    def query_string():
        return urllib.parse.quote_plus(kwargs["q"])

    if not headers:
        headers = {}
    url = func.keywords["url"]
    # Insert our (possibly modified) headers
    real_headers = kwargs.setdefault("headers", {})
    real_headers.update(headers)

    if expected_rc is None:
        expected_rc = [200, 304]
    rc, body = func(*args, **kwargs)
    # If we have new information, we want to use it (and store it unless
    # no_cache is true)
    # If we are told our existing info is ok, or there's an error, use the
    # stored info
    # Handle repo rename/removal corner cases
    if rc == 301:
        logger.error("Permanent Redirect for '{}'".format(url))
        # TODO: do something better, like switch to using id's
        # for now, act like nothing is there
        body = []
    elif rc == 403 and rc not in expected_rc:
        # don't throw on this one, but do show query string
        # for search, there is a seperate rate limit we don't yet take into
        # account:
        #  https://developer.github.com/v3/search/#rate-limit
        logger.error("403 for query string '{}'".format(query_string()))
        logger.error("response: '{}'".format(repr(body)))
        expected_rc.append(rc)
    elif rc == 404 and rc not in expected_rc:
        logger.error("No longer available or access denied: {}".format(url))
        # TODO: Figure out what to do here. Maybe it's just that message, but
        # maybe need to delete from DB before next run
        body = []
        # don't throw on this one
        expected_rc.append(rc)
    elif rc == 422 and rc not in expected_rc:
        logger.error(f"Unprocessable Entity: {url} {query_string()}")
    logger.debug("{} for {}".format(rc, url))

    if rc not in expected_rc:
        if DEBUG:
            import pudb

            pudb.set_trace()  # noqa: E702
        else:
            logger.error("{} for {}".format(rc, url))
            raise AG_Exception
    return body 
开发者ID:mozilla-services,项目名称:GitHub-Audit,代码行数:63,代码来源:open_issues.py

示例6: ag_call

# 需要导入模块: import pudb [as 别名]
# 或者: from pudb import set_trace [as 别名]
def ag_call(
    func, *args, expected_rc=None, new_only=True, headers=None, no_cache=False, **kwargs
):
    """
    Wrap AGitHub calls with basic error detection

    Not smart, and hides any error information from caller.
    But very convenient. :)
    """

    def query_string():
        return urllib.parse.quote_plus(kwargs["q"])

    if not headers:
        headers = {}
    url = func.keywords["url"]
    # Insert our (possibly modified) headers
    real_headers = kwargs.setdefault("headers", {})
    real_headers.update(headers)

    if expected_rc is None:
        expected_rc = [200, 304]
    rc, body = func(*args, **kwargs)
    # If we have new information, we want to use it (and store it unless
    # no_cache is true)
    # If we are told our existing info is ok, or there's an error, use the
    # stored info
    # Handle repo rename/removal corner cases
    if rc == 301:
        logger.error("Permanent Redirect for '{}'".format(url))
        # TODO: do something better, like switch to using id's
        # for now, act like nothing is there
        body = []
    elif rc == 403 and rc not in expected_rc:
        # don't throw on this one, but do show query string
        # for search, there is a seperate rate limit we don't yet take into
        # account:
        #  https://developer.github.com/v3/search/#rate-limit
        logger.error("403 for query string '{}'".format(query_string()))
        logger.error("response: '{}'".format(repr(body)))
        expected_rc.append(rc)
    elif rc == 404 and rc not in expected_rc:
        logger.error("No longer available or access denied: {}".format(url))
        # TODO: Figure out what to do here. Maybe it's just that message, but
        # maybe need to delete from DB before next run
        body = []
        # don't throw on this one
        expected_rc.append(rc)
    logger.debug("{} for {}".format(rc, url))

    if rc not in expected_rc:
        if DEBUG:
            import pudb

            pudb.set_trace()  # noqa: E702
        else:
            logger.error("{} for {}".format(rc, url))
            raise AG_Exception
    return body 
开发者ID:mozilla-services,项目名称:GitHub-Audit,代码行数:61,代码来源:term_search.py

示例7: __init__

# 需要导入模块: import pudb [as 别名]
# 或者: from pudb import set_trace [as 别名]
def __init__(self, **kwargs):
        med2image.__init__(self, **kwargs)

        self.l_dcmFileNames = sorted(glob.glob('%s/*.dcm' % self.str_inputDir))
        self.slices         = len(self.l_dcmFileNames)

        if self._b_convertMiddleSlice:
            self._sliceToConvert = int(self.slices/2)
            self._dcm            = dicom.read_file(self.l_dcmFileNames[self._sliceToConvert],force=True)
            self.str_inputFile  = self.l_dcmFileNames[self._sliceToConvert]

            # if not self.str_outputFileStem.startswith('%'):
            #     self.str_outputFileStem, ext = os.path.splitext(self.l_dcmFileNames[self._sliceToConvert])
        if not self._b_convertMiddleSlice and self._sliceToConvert != -1:
            self._dcm = dicom.read_file(self.l_dcmFileNames[self._sliceToConvert],force=True)
            self.str_inputFile = self.l_dcmFileNames[self._sliceToConvert]
        else:
            self._dcm = dicom.read_file(self.str_inputFile,force=True)
        if self._sliceToConvert == -1:
            self._b_3D = True
            self._dcm = dicom.read_file(self.str_inputFile,force=True)
            image = self._dcm.pixel_array
            shape2D = image.shape
            #print(shape2D)
            self._Vnp_3DVol = np.empty( (shape2D[0], shape2D[1], self.slices) )
            i = 0
            for img in self.l_dcmFileNames:
                self._dcm = dicom.read_file(img,force=True)
                image = self._dcm.pixel_array
                self._dcmList.append(self._dcm)
                #print('%s: %s' % (img, image.shape))
                try:
                    self._Vnp_3DVol[:,:,i] = image
                except Exception as e:
                    self.warn(
                    'dcmInsertionFail',
                    '\nFor input DICOM file %s%s' % (img, str(e)),
                    True)
                i += 1
        if self.str_outputFileStem.startswith('%'):
            str_spec = self.str_outputFileStem
            self.str_outputFileStem = ''
            for key in str_spec.split('%')[1:]:
                str_fileComponent = ''
                if key == 'inputFile':
                    str_fileName, str_ext = os.path.splitext(self.str_inputFile)
                    str_fileComponent = str_fileName
                else:
                    # pudb.set_trace()
                    str_fileComponent = eval('str(self._dcm.%s)' % key)
                    str_fileComponent = med2image.urlify(str_fileComponent)
                if not len(self.str_outputFileStem):
                    self.str_outputFileStem = str_fileComponent
                else:
                    self.str_outputFileStem = self.str_outputFileStem + '-' + str_fileComponent
        image = self._dcm.pixel_array
        self._Mnp_2Dslice = image 
开发者ID:FNNDSC,项目名称:med2image,代码行数:59,代码来源:med2image.py

示例8: __init__

# 需要导入模块: import pudb [as 别名]
# 或者: from pudb import set_trace [as 别名]
def __init__(self, **kwargs):
        # threading.Thread.__init__(self)

        self.__name__               = "Charm"
        self.str_http               = ""
        self.d_msg                  = {}
        self.b_raw                  = False
        self.str_IOPhost            = ''
        self.str_cmd                = ''
        self.str_inputdir           = ''
        self.str_outputdir          = ''
        self.d_args                 = {}
        self.l_appArgs              = {}
        self.c_pluginInst           = {'contents':  'void'}
        self.app                    = None

        # A job ID prefix string. Necessary since some schedulers require
        # a minimum job ID string length
        self.str_jidPrefix = 'chris-jid-'

        for key, val in kwargs.items():
            if key == 'app_args':       self.l_appArgs         = val
            if key == 'd_args':         self.d_args            = val
            if key == 'plugin_inst':    self.c_pluginInst      = val
            if key == 'app':            self.app               = val
            if key == 'inputdir':       self.str_inputdir      = val
            if key == 'outputdir':      self.str_outputdir     = val
            if key == 'IOPhost':        self.str_IOPhost       = val

        # This for the case when Charm is instantiated w/o a plugin instance, eg
        # as a dispatcher to simply send a pfcon instance a message.
        try:
            self.d_pluginInst = vars(self.c_pluginInst)
        except:
            self.d_pluginInst = {}

        # pudb.set_trace()

        # logger.debug('d_args = %s', self.d_args)
        # logger.debug('app_args = %s', self.l_appArgs)
        # logger.debug('d_pluginInst = %s', self.d_pluginInst)
        # logger.debug('app = %s', self.app)
        # logger.debug('inputdir = %s', self.str_inputdir)
        # logger.debug('outputdir = %s', self.str_outputdir) 
开发者ID:FNNDSC,项目名称:ChRIS_ultron_backEnd,代码行数:46,代码来源:charm.py

示例9: app_service_fsplugin_setup

# 需要导入模块: import pudb [as 别名]
# 或者: from pudb import set_trace [as 别名]
def app_service_fsplugin_setup(self, *args, **kwargs):
        """
        Some fsplugins, esp those that might interact with the local file
        filesystem can be "massaged" to conform to the existing fileIO
        transmission pattern.

        This method edits the cmdLine for fsplugin input to /share/incoming
        and sets any --dir to data location in local object storage.
        """
        # pudb.set_trace()
        l_pathArgs  = []

        # Loop over the plugin parameters and search for any that have type
        # 'path'. Ideally speaking there should be only one, however for now
        # we won't assume that -- we'll lay the groundwork for more than 'path'
        # type parameter, but will process things as if there was only one...
        for d_param in self.c_pluginInst.plugin.parameters.all():
            if d_param.type == 'path':
                l_pathArgs.append(d_param.name)

        # The 'path' type parameter refers to some location (ideally in the
        # swift storage). We need to replace this location referring to some
        # 'local' path with a hard code '/share/incoming' since that is where
        # the data will be located in the remote compute env.
        #
        # We then need to pass this local input parameter as the inputdir to
        # pfcon, with appropriate pre-massaging for bucket prepending.
        if len(l_pathArgs):
            for argName in l_pathArgs:
                self.str_inputdir = self.d_args[argName]
                i = 0
                for v in self.l_appArgs:
                    if v == self.str_inputdir:
                        self.l_appArgs[i] = '/share/incoming'
                    i+=1
                str_allCmdLineArgs      = ' '.join(self.l_appArgs)
                str_exec                = os.path.join(self.c_pluginInst.plugin.selfpath, self.c_pluginInst.plugin.selfexec)
                self.str_cmd            = '%s %s' % (str_exec, str_allCmdLineArgs)
                logger.info('cmd = %s', self.str_cmd)

        # Manage args with type 'path' for FS type plugins
        # At the point the 'self.str_inputdir' now points to the location
        # of the 'path' type variable in the arg list of the FS app.
        # We will pass this new location on to be managed via kwargs
        kwargs['inputdir']  = self.str_inputdir
        d_manage = self.app_service_fsplugin_inputdirManage(*args, **kwargs)

        return {
            'status':   True,
            'cmd':      self.str_cmd,
            'd_manage': d_manage
        } 
开发者ID:FNNDSC,项目名称:ChRIS_ultron_backEnd,代码行数:54,代码来源:charm.py


注:本文中的pudb.set_trace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。