當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。