當前位置: 首頁>>代碼示例>>Python>>正文


Python pydevd.settrace方法代碼示例

本文整理匯總了Python中pydevd.settrace方法的典型用法代碼示例。如果您正苦於以下問題:Python pydevd.settrace方法的具體用法?Python pydevd.settrace怎麽用?Python pydevd.settrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pydevd的用法示例。


在下文中一共展示了pydevd.settrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: debug

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def debug(func):
    if not DEBUG:
        return func

    def wrapper(*args, **kwargs):
        import pydevd
        pydevd.settrace('localhost', port=4242, stdoutToServer=True, stderrToServer=True)

        try:
            func(*args, **kwargs)
        except Exception as e:
            pydevd.stoptrace()
            raise

        pydevd.stoptrace()

    return wrapper 
開發者ID:Soap4me,項目名稱:Kodi,代碼行數:19,代碼來源:addon.py

示例2: _get_python_c_args

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def _get_python_c_args(host, port, indC, args, setup):
    setup = _get_setup_updated_with_protocol_and_ppid(setup)

    # i.e.: We want to make the repr sorted so that it works in tests.
    setup_repr = setup if setup is None else (sorted_dict_repr(setup))

    return ("import sys; sys.path.insert(0, r'%s'); import pydevd; pydevd.PydevdCustomization.DEFAULT_PROTOCOL=%r; "
            "pydevd.settrace(host=%r, port=%s, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True, access_token=%r, client_access_token=%r, __setup_holder__=%s); "
            "%s"
            ) % (
               pydev_src_dir,
               pydevd_constants.get_protocol(),
               host,
               port,
               setup.get('access-token'),
               setup.get('client-access-token'),
               setup_repr,
               args[indC + 1]) 
開發者ID:fabioz,項目名稱:PyDev.Debugger,代碼行數:20,代碼來源:pydev_monkey.py

示例3: _detect_debug_environment

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def _detect_debug_environment():
    """
    Detect whether server is running in a debug environment
    if so, connect to debug server at a port stored in env[DEBUG_REST_SERVICE]
    """
    try:
        docl_debug_path = os.environ.get('DEBUG_CONFIG')
        if docl_debug_path and os.path.isfile(docl_debug_path):
            with open(docl_debug_path, 'r') as docl_debug_file:
                debug_config = yaml.safe_load(docl_debug_file)
            if debug_config.get('is_debug_on'):
                import pydevd
                pydevd.settrace(
                    debug_config['host'], port=53100, stdoutToServer=True,
                    stderrToServer=True, suspend=False)
    except BaseException as e:
        raise Exception('Failed to connect to debug server, {0}: {1}'.
                        format(type(e).__name__, str(e))) 
開發者ID:cloudify-cosmo,項目名稱:cloudify-manager,代碼行數:20,代碼來源:server.py

示例4: setup_remote_pydev_debug

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def setup_remote_pydev_debug(host, port):
    error_msg = ('Error setting up the debug environment. Verify that the'
                 ' option pydev_worker_debug_host is pointing to a valid '
                 'hostname or IP on which a pydev server is listening on'
                 ' the port indicated by pydev_worker_debug_port.')

    try:
        try:
            from pydev import pydevd
        except ImportError:
            import pydevd

        pydevd.settrace(host,
                        port=port,
                        stdoutToServer=True,
                        stderrToServer=True)
        return True
    except Exception:
        with excutils.save_and_reraise_exception():
            LOG.exception(error_msg) 
開發者ID:openstack,項目名稱:searchlight,代碼行數:22,代碼來源:utils.py

示例5: setup_remote_pydev_debug

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def setup_remote_pydev_debug():
    """Required setup for remote debugging."""

    if CONF.pydev_debug_host and CONF.pydev_debug_port:
        try:
            try:
                from pydev import pydevd
            except ImportError:
                import pydevd

            pydevd.settrace(CONF.pydev_debug_host,
                            port=int(CONF.pydev_debug_port),
                            stdoutToServer=True,
                            stderrToServer=True)
        except Exception:
            LOG.exception('Unable to join debugger, please '
                          'make sure that the debugger processes is '
                          'listening on debug-host \'%s\' debug-port \'%s\'.',
                          CONF.pydev_debug_host, CONF.pydev_debug_port)
            raise 
開發者ID:cloud-security-research,項目名稱:sgx-kms,代碼行數:22,代碼來源:config.py

示例6: startdebugger

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def startdebugger():
    debugegg = ''
    if sys.platform.lower().startswith('win'):
        debugegg = os.path.expandvars('%programfiles(x86)%\\JetBrains\\PyCharm 2016.1\\debug-eggs\\pycharm-debug.egg')
    elif sys.platform.lower().startswith('darwin'):
        debugegg = '/Applications/PyCharm.app/Contents/debug-eggs/pycharm-debug.egg'
    elif sys.platform.lower().startswith('linux'):
        debugegg = os.path.expandvars(os.path.expanduser('~/Applications/pycharm-2016.1.4/debug-eggs/pycharm-debug.egg'))
    if os.path.exists(debugegg):
        sys.path.append(debugegg)
        try:
            import pydevd
        except ImportError:
            xbmc.log(msg = 'Debugger import error @: "%s"' % debugegg)
            pydevd = pydevd_dummy
        pydevd.settrace('localhost', port=51234, stdoutToServer=True, stderrToServer=True, suspend=False)
    else:
        xbmc.log(msg='Debugger not found @: "%s"' % debugegg) 
開發者ID:KenV99,項目名稱:script.service.kodi.callbacks,代碼行數:20,代碼來源:debugger.py

示例7: setup_remote_pydev_debug

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def setup_remote_pydev_debug():
    """Required setup for remote debugging."""

    if CONF.pydev_debug_host and CONF.pydev_debug_port:
        try:
            try:
                from pydev import pydevd
            except ImportError:
                import pydevd

            pydevd.settrace(CONF.pydev_debug_host,
                            port=int(CONF.pydev_debug_port),
                            stdoutToServer=True,
                            stderrToServer=True)
        except Exception:
            LOG.exception('Unable to join debugger, please '
                          'make sure that the debugger processes is '
                          'listening on debug-host \'%(debug-host)s\' '
                          'debug-port \'%(debug-port)s\'.',
                          {'debug-host': CONF.pydev_debug_host,
                           'debug-port': CONF.pydev_debug_port})
            raise 
開發者ID:openstack,項目名稱:barbican,代碼行數:24,代碼來源:config.py

示例8: attach

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def attach(port, host):
    try:
        import pydevd
        pydevd.stoptrace() #I.e.: disconnect if already connected
        # pydevd.DebugInfoHolder.DEBUG_RECORD_SOCKET_READS = True
        # pydevd.DebugInfoHolder.DEBUG_TRACE_BREAKPOINTS = 3
        # pydevd.DebugInfoHolder.DEBUG_TRACE_LEVEL = 3
        pydevd.settrace(
            port=port,
            host=host,
            stdoutToServer=True,
            stderrToServer=True,
            overwrite_prev_trace=True,
            suspend=False,
            trace_only_current_thread=False,
            patch_multiprocessing=False,
        )
    except:
        import traceback;traceback.print_exc() 
開發者ID:mrknow,項目名稱:filmkodi,代碼行數:21,代碼來源:attach_script.py

示例9: execute

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def execute(self, context):
        import sys

        user_preferences = context.user_preferences
        addon_prefs = user_preferences.addons[__name__].preferences

        eggpath = os.path.abspath(addon_prefs.eggpath)

        if not os.path.exists(eggpath):
            self.report({'ERROR'}, 'Unable to find debug egg at %r. Configure the addon properties '
                                   'in the User Preferences menu.' % eggpath)
            return {'CANCELLED'}

        if not any('pycharm-debug' in p for p in sys.path):
            sys.path.append(eggpath)

        import pydevd
        pydevd.settrace('localhost', port=1090, stdoutToServer=True, stderrToServer=True)

        return {'FINISHED'} 
開發者ID:pelednoam,項目名稱:mmvt,代碼行數:22,代碼來源:remote_debugger.py

示例10: execute

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def execute(self, context):
        fol = op.join(DataMakerPanel.pycharm_fol, 'debug-eggs')
        eggpath = op.join(fol, 'pydevd-pycharm.egg')
        if not op.exists(eggpath):
            eggpath = op.join(fol, 'pycharm-debug-py3k.egg')
        if not op.exists(eggpath):
            self.report({'ERROR'}, 'Unable to find debug egg at {}. Configure the addon properties '
                                   'in the User Preferences menu.'.format(eggpath))
            return {'CANCELLED'}

        if not any('pycharm-debug' in p for p in sys.path):
            print('Adding eggpath to the path: {}'.format(eggpath))
            sys.path.append(eggpath)

        import pydevd
        print('Waiting to connects to a PyCharm debugger on localhost:1090')
        pydevd.settrace('localhost', port=1090, stdoutToServer=True, stderrToServer=True)
        return {'FINISHED'} 
開發者ID:pelednoam,項目名稱:mmvt,代碼行數:20,代碼來源:data_panel.py

示例11: debug

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def debug(user=None):
    # Turn on debug printing automatically if a debugger is attached
    try:
        import pydevd
        pydevd.settrace()
    except ImportError:
        pass
    return None, httplib.OK 
開發者ID:mitre,項目名稱:cascade-server,代碼行數:10,代碼來源:api.py

示例12: config

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def config(config):
    # prepare mqtt settings
    print('debug feature enabled')
    debughost = config.get('debughost', None)
    debugport = config.get('debugport', None)
    if None not in (debughost,debugport):
        try:
            print('activate debug for '+debughost+' Port '+str(debugport))
            pydevd.settrace(debughost, port=int(debugport), stdoutToServer=True, stderrToServer=True)
        except Exception as e:
            print( '...failed')
            print(e)
            pass 
開發者ID:datenschuft,項目名稱:SMA-EM,代碼行數:15,代碼來源:remotedebug.py

示例13: install_breakpointhook

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def install_breakpointhook():
    def custom_sitecustomize_breakpointhook(*args, **kwargs):
        import os
        hookname = os.getenv('PYTHONBREAKPOINT')
        if (
               hookname is not None 
               and len(hookname) > 0 
               and hasattr(sys, '__breakpointhook__')
               and sys.__breakpointhook__ != custom_sitecustomize_breakpointhook
            ):
            sys.__breakpointhook__(*args, **kwargs)
        else:
            sys.path.append(os.path.dirname(os.path.dirname(__file__)))
            import pydevd
            kwargs.setdefault('stop_at_frame', sys._getframe().f_back)
            pydevd.settrace(*args, **kwargs)

    if sys.version_info[0:2] >= (3, 7):
        # There are some choices on how to provide the breakpoint hook. Namely, we can provide a 
        # PYTHONBREAKPOINT which provides the import path for a method to be executed or we
        # can override sys.breakpointhook.
        # pydevd overrides sys.breakpointhook instead of providing an environment variable because
        # it's possible that the debugger starts the user program but is not available in the 
        # PYTHONPATH (and would thus fail to be imported if PYTHONBREAKPOINT was set to pydevd.settrace).
        # Note that the implementation still takes PYTHONBREAKPOINT in account (so, if it was provided
        # by someone else, it'd still work).
        sys.breakpointhook = custom_sitecustomize_breakpointhook
    else:
        if sys.version_info[0] >= 3:
            import builtins as __builtin__ # Py3
        else:
            import __builtin__

        # In older versions, breakpoint() isn't really available, so, install the hook directly
        # in the builtins.
        __builtin__.breakpoint = custom_sitecustomize_breakpointhook
        sys.__breakpointhook__ = custom_sitecustomize_breakpointhook

# Install the breakpoint hook at import time. 
開發者ID:fabioz,項目名稱:PyDev.Debugger,代碼行數:41,代碼來源:sitecustomize.py

示例14: ask_for_stop

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def ask_for_stop(use_back):
    import pydevd
    if use_back:
        pydevd.settrace(stop_at_frame=sys._getframe().f_back)
    else:
        pydevd.settrace()
    print('Will stop here if use_back==False.') 
開發者ID:fabioz,項目名稱:PyDev.Debugger,代碼行數:9,代碼來源:_debugger_case_settrace.py

示例15: execute

# 需要導入模塊: import pydevd [as 別名]
# 或者: from pydevd import settrace [as 別名]
def execute(self, context):
        import pydevd
        pydevd.settrace()
        return {'FINISHED'} 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:6,代碼來源:fd_general.py


注:本文中的pydevd.settrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。