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


Python ptvsd.enable_attach函数代码示例

本文整理汇总了Python中ptvsd.enable_attach函数的典型用法代码示例。如果您正苦于以下问题:Python enable_attach函数的具体用法?Python enable_attach怎么用?Python enable_attach使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: __init__

    def __init__(self, vscode_debug_secret=None,
                 vscode_debug_address=None, vscode_debug_port=None, **kwargs):
        if vscode_debug_secret is not None:
            ptvsd.enable_attach(
                vscode_debug_secret,
                address=(vscode_debug_address, int(vscode_debug_port))
            )
            print "Waiting for VS Code to attach"
            ptvsd.wait_for_attach()

        if kwargs["gecko_log"] is None:
            kwargs["gecko_log"] = ("logs/marionette.{}.gecko.log"
                                   ).format(int(time.time()))
        self.gecko_log_relpath = kwargs["gecko_log"]

        FirefoxUITestRunner.__init__(self, **kwargs)

        def gather_debug(test, status):
            rv = {}
            marionette = test._marionette_weakref()

            if marionette.session is not None:
                try:
                    self._add_logging_info(rv, marionette)
                except Exception:
                    logger = get_default_logger()
                    logger.warning("Failed to gather test failure debug.",
                                   exc_info=True)
            return rv

        self.result_callbacks.append(gather_debug)
开发者ID:beriain,项目名称:requestpolicy,代码行数:31,代码来源:runner.py

示例2: init_logging

def init_logging(params):
    # Global configuration
    log_file = params.get('logFile', None)
    log_level = params.get('logLevel', logging.ERROR)
    logging.basicConfig(level=log_level, filename=log_file, datefmt='%H:%M:%S',
                        format='[%(asctime)s %(name)s] %(message)s')
    # Individuial loggers
    loggers = params.get('loggers')
    if loggers:
        for name, level in loggers.items():
            logging.getLogger(name).setLevel(level)
    # Visual Studio debug server
    ptvsd_params = params.get('ptvsd')
    if ptvsd_params:
        try:
            import ptvsd
            secret = ptvsd_params.get('secret')
            address = ptvsd_params.get('address', '127.0.0.1')
            port = ptvsd_params.get('port', 3000)
            ptvsd.enable_attach(secret, address = (address, port))
            wait_for = ptvsd_params.get('waitFor')
            if wait_for is not None:
                ptvsd.wait_for_attach(wait_for if wait_for > 0 else None)
        except Exception as e:
            log.error('ptvsd setup failed: %s', e)
开发者ID:harikrishnan94,项目名称:vscode-lldb,代码行数:25,代码来源:main.py

示例3: main

def main():
    """Setup debugging if required and send remaining arguments to execution_function"""
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--remoteDebug", help="Imports and launches remote debugger")
    parser.add_argument("--vsDelay", type=int, default=200, help="Fixes how long \
  the debugger will wait")
    parser.add_argument("--eclipseHost", help="The host for the thread to be debugged\
    (the client, in practice)")
    test_args, function_args = parser.parse_known_args()

    if str(test_args.remoteDebug).lower() == "vs":
        import ptvsd
        ptvsd.enable_attach(secret="cerro")
        ptvsd.wait_for_attach(test_args.vsDelay)
    elif str(test_args.remoteDebug).lower == "eclipse" and str(test_args.eclipseHost):
        # TODO: Put sanitisation or error-trapping in here for eclipse host and
        # call pydevd
        pass
    funcDict = {}
    # Making a dictionary of the non-test setup arguments not listed above
    for element in function_args:
        k, v = element.split('=', 1)
        funcDict[k.lstrip('--')] = v
    retVal=osd.execute_function(osd.generate_connection(), **funcDict)
    print (str(retVal))
开发者ID:CCATObservatory,项目名称:swdm-osd,代码行数:26,代码来源:debug_osd_api.py

示例4: wait_for_debugger

def wait_for_debugger(timeout=None):
    try:
        ptvsd.enable_attach(secret=None)   
    except:
        pass
    ptvsd.wait_for_attach(timeout)
    return
开发者ID:gtkfi,项目名称:ArcSDM,代码行数:7,代码来源:debug_ptvs.py

示例5: debug

    async def debug(self, engine, options):
        """
        Setup middlewared for remote debugging.

        engines:
          - PTVS: Python Visual Studio
          - PYDEV: Python Dev (Eclipse/PyCharm)

        options:
          - secret: password for PTVS
          - host: required for PYDEV, hostname of local computer (developer workstation)
          - local_path: required for PYDEV, path for middlewared source in local computer (e.g. /home/user/freenas/src/middlewared/middlewared
        """
        if engine == 'PTVS':
            import ptvsd
            if 'secret' not in options:
                raise ValidationError('secret', 'secret is required for PTVS')
            ptvsd.enable_attach(
                options['secret'],
                address=(options['bind_address'], options['bind_port']),
            )
            if options['wait_attach']:
                ptvsd.wait_for_attach()
        elif engine == 'PYDEV':
            for i in ('host', 'local_path'):
                if i not in options:
                    raise ValidationError(i, f'{i} is required for PYDEV')
            os.environ['PATHS_FROM_ECLIPSE_TO_PYTHON'] = json.dumps([
                [options['local_path'], '/usr/local/lib/python3.6/site-packages/middlewared'],
            ])
            import pydevd
            pydevd.stoptrace()
            pydevd.settrace(host=options['host'])
开发者ID:razzfazz,项目名称:freenas,代码行数:33,代码来源:service.py

示例6: debug_remote

def debug_remote(
    file, 
    port_num,
    debug_id,
    wait_on_exception,
    redirect_output, 
    wait_on_exit,
    break_on_systemexit_zero,
    debug_stdlib,
    run_as
):
    global BREAK_ON_SYSTEMEXIT_ZERO, DEBUG_STDLIB
    BREAK_ON_SYSTEMEXIT_ZERO = break_on_systemexit_zero
    DEBUG_STDLIB = debug_stdlib

    import datetime
    print('%s: Remote launcher starting ptvsd attach wait with File: %s, Port: %d, Id: %s\n' % (datetime.datetime.now(), file, port_num, debug_id))

    ptvsd.enable_attach(debug_id, address = ('0.0.0.0', port_num), redirect_output = redirect_output)
    try:
        import _ptvsdhelper
        if _ptvsdhelper.ping_debugger_for_attach():
            ptvsd.wait_for_attach()
    except ImportError:
        _ptvsdhelper = None

    # now execute main file
    globals_obj = {'__name__': '__main__'}
    if run_as == 'module':
        vspd.exec_module(file, globals_obj)
    elif run_as == 'code':
        vspd.exec_code(file, '<string>', globals_obj)
    else:
        vspd.exec_file(file, globals_obj)
开发者ID:BMBurstein,项目名称:PTVS,代码行数:34,代码来源:visualstudio_py_remote_launcher.py

示例7: _enable_ptvsd

def _enable_ptvsd(debuggger_host, debugger_port):
    import ptvsd

    # Allow other computers to attach to ptvsd at this IP address and port.
    ptvsd.enable_attach(address=(debuggger_host, debugger_port),
                        redirect_output=True)

    # Pause the program until a remote debugger is attached
    ptvsd.wait_for_attach()
开发者ID:openstack,项目名称:octavia,代码行数:9,代码来源:config.py

示例8: debuggable_app

def debuggable_app():
    """ For launching with gunicorn from a Heroku Procfile. 
    Problem: both the web and worker processes run the same create_app code. If we start a ptvsd service in create_app, it will be
    started twice on the same port, and fail. 
    Solution: gunicorn gets its app object through this method that also starts the debug server. 
    """
    if settings.DEBUG:
        import ptvsd
        ptvsd.enable_attach(address=('0.0.0.0', 3000))

    return app
开发者ID:formspree,项目名称:formspree,代码行数:11,代码来源:__init__.py

示例9: ListenDebugger

def ListenDebugger(port_ovr=None):
    """
	Start a debug server for Python Tools for Visual Studio (ptvs)
	"""
    import ptvsd

    if port_ovr:
        ptvsd.enable_attach(secret=PTVS_SECRET, address=("0.0.0.0", port_ovr), redirect_output=False)
    else:
        ptvsd.enable_attach(secret=PTVS_SECRET, redirect_output=False)

    GEUtil.Msg("Python debugger successfully connected!\n")
开发者ID:J-Shep,项目名称:ges-python,代码行数:12,代码来源:ge_debugger.py

示例10: debug

def debug(_connection=None):
    output = sims4.commands.CheatOutput(_connection)
    output("Connecting to Debugger")
    print("Connecting to Debugger")
    failed = True
    if failed:
        try:
            # Try connecting to Python Tools for Visual Studio 
            #   Note that you need ptvsd.zip in the Mods folder
            #   You also need ctypes from python33\lib in the ptvsd.zip 
            #   as well as _ctypes.pyd copied to Origin\Game\bin\Python\DLLs
            #   You would connect to this machine after this command
            import ptvsd
            ptvsd.enable_attach(secret='ts4')
            # ptvsd.wait_for_attach(timeout=20.0) # wait for 20 seconds?
            failed = False
        except Exception as e:
            import sys, traceback
            print(str(e), file=sys.stderr)
            traceback.print_exc(file=sys.stderr)
            pass
            
    if failed:
        try:
            # Try connecting to PyCharm or IntelliJ IDEA Professional
            #   Note that you need pycharm-debug-py3k.egg in the Mods folder
            #   and .egg renamed to .zip for this to work.
            #  Startup the Python Remote Debug Configuration before running this command.
            import pydevd
            pydevd.settrace('localhost', port=5678, stdoutToServer=True, stderrToServer=True)
            failed = False
        except Exception as e:
            import sys, traceback
            print(str(e), file=sys.stderr)
            traceback.print_exc(file=sys.stderr)
            pass
        

    if failed:
        output("Exception while connecting to Debugger")
        print("Exception while connecting to Debugger")    
    else:
        output("Continuing Debugger")
        print("Continuing Debugger")
    return False
开发者ID:figment,项目名称:sims4exmod,代码行数:45,代码来源:debug.py

示例11: debug

def debug():

    """
    Wait for debugger attach.
    """

    try:
        import os
        import inspect
        import ptvsd
        module_root = os.path.dirname(inspect.getfile(main))
        print("Debug mode enabled. Waiting for debugger attach.")
        print("    remote root:", module_root)
        print("    debug port:", 5151)
        print("    debug secret:", "debug_secret")
        ptvsd.enable_attach("debug_secret", address = ('0.0.0.0', 5151))
        ptvsd.wait_for_attach()
    except ImportError:
        print("Debug prerequisites not avalible.")
    
    main()
开发者ID:intel-iot-devkit,项目名称:how-to-code-samples,代码行数:21,代码来源:__main__.py

示例12: ListenDebugger

def ListenDebugger( port_ovr=None ):
    '''
    Start a debug server for Python Tools for Visual Studio (ptvs)
    '''
    try:
        if port_ovr:
            ptvsd.enable_attach( secret=PTVS_SECRET, address=('0.0.0.0', port_ovr), redirect_output=False )
        else:
            ptvsd.enable_attach( secret=PTVS_SECRET, redirect_output=False )

        print( "Listening for Python Tools for Visual Studio debugger, version %s\n" % ptvsd.attach_server.PTVS_VER )
    
    except AttachAlreadyEnabledError:
        Warning( "Python debugger is already listening!\n" )
        
    print( "To connect using Visual Studio 2013 & PTVS:" )
    print( "  1) DEBUG -> Attach to process..." )
    print( "  2) Select Python Remote (ptvsd) from the Transport menu" )
    print( "  3) Enter tcp://%[email protected]:5678 in the Qualifier field and press Refresh" % PTVS_SECRET )
    print( "  4) Click Attach to start debugging" )
    print( "\nGood Luck and happy coding!\n" )
开发者ID:goldeneye-source,项目名称:ges-python,代码行数:21,代码来源:ge_debugger.py

示例13: attach_to_pid

def attach_to_pid():
    def quoted_str(s):
        assert not isinstance(s, bytes)
        unescaped = set(chr(ch) for ch in range(32, 127)) - {'"', "'", '\\'}
        def escape(ch):
            return ch if ch in unescaped else '\\u%04X' % ord(ch)
        return 'u"' + ''.join(map(escape, s)) + '"'

    pid = ptvsd.options.target
    host = quoted_str(ptvsd.options.host)
    port = ptvsd.options.port

    ptvsd_path = os.path.abspath(os.path.join(ptvsd.__file__, '../..'))
    if isinstance(ptvsd_path, bytes):
        ptvsd_path = ptvsd_path.decode(sys.getfilesystemencoding())
    ptvsd_path = quoted_str(ptvsd_path)

    # pydevd requires injected code to not contain any single quotes.
    code = '''
import os
assert os.getpid() == {pid}

import sys
sys.path.insert(0, {ptvsd_path})
import ptvsd
del sys.path[0]

import ptvsd.options
ptvsd.options.client = True
ptvsd.options.host = {host}
ptvsd.options.port = {port}

ptvsd.enable_attach()
'''.format(**locals())
    print(code)

    pydevd_attach_to_process_path = os.path.join(
        os.path.dirname(pydevd.__file__),
        'pydevd_attach_to_process')
    sys.path.insert(0, pydevd_attach_to_process_path)
    from add_code_to_python_process import run_python_code
    run_python_code(pid, code, connect_debugger_tracing=True)
开发者ID:andrewgu12,项目名称:config,代码行数:42,代码来源:__main__.py

示例14:

import ptvsd
ptvsd.enable_attach(secret=None)
from time import sleep

print("hi")

X = raw_input("Response: ")

sleep(1)

print(":D")

sleep(1)

Y = raw_input("Response: ")
开发者ID:hobnob11,项目名称:Pi-thon,代码行数:15,代码来源:test.py

示例15: getAccount

from azure.storage import TableService, Entity, QueueService
import time
import redis
import spidev
from tokens import *
import ptvsd
ptvsd.enable_attach('xplatDebug')

spi = spidev.SpiDev()
spi.open(0,0)

myaccount = getAccount()
mykey = getKey()

table_service = TableService(account_name=myaccount, account_key=mykey)
queue_service = QueueService(account_name=myaccount, account_key=mykey)

queue_service.create_queue('acceldata')

i = 0

TableSlotList = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,43,44,45,46,47,48,49,50)

periods = ('a', 'b', 'c', 'd')

#table_service.insert_or_replace_entity(accel2, accel, tableSlot, periodSlot)

record = {}

#records = {'aX': generateX(),'aY': generateY(),'aZ': generateZ(),'bX': generateX(),'bY': generateY(),'bZ': generateZ(), 'cX': generateX(),'cY': generateY(),'cZ': generateZ(),'cX': generateX(),'cY': generateY(),'cZ': generateZ() }
开发者ID:timmyreilly,项目名称:raspberryHug,代码行数:30,代码来源:SendCloudData.py


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