def run(file, port_num, debug_id, pid, run_as='script'):
    attach_process(port_num, pid, debug_id)

    # Now execute main file.
    globals_obj = {'__name__': '__main__'}

    try:
        if run_as == 'module':
            _vspu.exec_module(file, globals_obj)
        elif run_as == 'code':
            _vspu.exec_code(file, '<string>', globals_obj)
        else:
            _vspu.exec_file(file, globals_obj)
    except:
        exc_type, exc_value, exc_tb = sys.exc_info()
        handle_exception(exc_type, exc_value, exc_tb)

    _vspu.write_bytes(conn, LAST)
    # Wait for message to be received by debugger.
    time.sleep(0.5)
Example #2
0
                  help='do not redirect stdout and stderr to debugger')
parser.add_option('--wait',
                  dest='wait',
                  action='store_true',
                  default=False,
                  help='wait for a debugger to attach before executing')

argv = sys.argv[1:]
script_argv = []
if '-' in argv:
    script_argv = argv[argv.index('-') + 1:]
    del argv[argv.index('-'):]

(opts, args) = parser.parse_args(argv)
if not args and not script_argv:
    parser.error('<file> not specified')
if args:
    script_argv.insert(0, args[0])
if opts.keyfile and not opts.certfile:
    parser.error('--keyfile requires --certfile')

enable_attach(opts.secret, (opts.interface, opts.port), opts.certfile,
              opts.keyfile, opts.redirect_output)
if opts.wait:
    wait_for_attach()

DONT_DEBUG.append(os.path.normcase(__file__))

sys.argv = script_argv
exec_file(script_argv[0], {'__name__': '__main__'})
Example #3
0
parser.add_option('-s', '--secret', metavar = '<secret>', help = 'restrict server to only allow clients that specify <secret> when connecting')
parser.add_option('-i', '--interface', default = '0.0.0.0', metavar = '<ip-address>', help = 'listen for debugger connections on interface <ip-address>')
parser.add_option('-p', '--port', type='int', default = DEFAULT_PORT, metavar = '<port>', help = 'listen for debugger connections on <port>')
parser.add_option('--certfile', metavar = '<file>', help = 'Enable SSL and use PEM certificate from <file> to secure connection')
parser.add_option('--keyfile', metavar = '<file>', help = 'Use private key from <file> to secure connection (requires --certfile)')
parser.add_option('--no-output-redirection', dest = 'redirect_output', action = 'store_false', default = True, help = 'do not redirect stdout and stderr to debugger')
parser.add_option('--wait', dest = 'wait', action = 'store_true', default = False, help = 'wait for a debugger to attach before executing')

argv = sys.argv[1:]
script_argv = []
if '-' in argv:
    script_argv = argv[argv.index('-') + 1:]
    del argv[argv.index('-'):]

(opts, args) = parser.parse_args(argv)
if not args and not script_argv:
    parser.error('<file> not specified')
if args:
    script_argv.insert(0, args[0])
if opts.keyfile and not opts.certfile:
    parser.error('--keyfile requires --certfile')

enable_attach(opts.secret, (opts.interface, opts.port), opts.certfile, opts.keyfile, opts.redirect_output)
if opts.wait:
    wait_for_attach()

DONT_DEBUG.append(os.path.normcase(__file__))

sys.argv = script_argv
exec_file(script_argv[0], {'__name__': '__main__'})
Example #4
0
    action="store_false",
    default=True,
    help="do not redirect stdout and stderr to debugger",
)
parser.add_option(
    "--wait", dest="wait", action="store_true", default=False, help="wait for a debugger to attach before executing"
)

argv = sys.argv[1:]
script_argv = []
if "-" in argv:
    script_argv = argv[argv.index("-") + 1 :]
    del argv[argv.index("-") :]

(opts, args) = parser.parse_args(argv)
if not args and not script_argv:
    parser.error("<file> not specified")
if args:
    script_argv.insert(0, args[0])
if opts.keyfile and not opts.certfile:
    parser.error("--keyfile requires --certfile")

enable_attach(opts.secret, (opts.interface, opts.port), opts.certfile, opts.keyfile, opts.redirect_output)
if opts.wait:
    wait_for_attach()

DONT_DEBUG.append(os.path.normcase(__file__))

sys.argv = script_argv
exec_file(script_argv[0], {"__name__": "__main__"})