Rename ide_access_token -> client_access_token in pydevd, for consistency with terminology used in DAP.

This commit is contained in:
Pavel Minaev 2019-12-09 13:01:14 -08:00 committed by Pavel Minaev
parent e9a5b68054
commit 0d37f2f271
11 changed files with 46 additions and 46 deletions

View file

@ -68,7 +68,7 @@ def _get_setup_updated_with_protocol(setup):
def _get_python_c_args(host, port, indC, args, setup):
setup = _get_setup_updated_with_protocol(setup)
return ("import sys; sys.path.append(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, ide_access_token=%r); "
"pydevd.settrace(host=%r, port=%s, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True, access_token=%r, client_access_token=%r); "
"from pydevd import SetupHolder; SetupHolder.setup = %s; %s"
) % (
pydev_src_dir,
@ -76,7 +76,7 @@ def _get_python_c_args(host, port, indC, args, setup):
host,
port,
setup.get('access-token'),
setup.get('ide-access-token'),
setup.get('client-access-token'),
setup,
args[indC + 1])

View file

@ -53,7 +53,7 @@ ACCEPTED_ARG_HANDLERS = [
ArgHandlerWithParam('vm_type'),
ArgHandlerWithParam('client'),
ArgHandlerWithParam('access-token'),
ArgHandlerWithParam('ide-access-token'),
ArgHandlerWithParam('client-access-token'),
ArgHandlerBool('server'),
ArgHandlerBool('DEBUG_RECORD_SOCKET_READS'),

View file

@ -75,7 +75,7 @@ class _PyDevCommandProcessor(object):
access_token = text
py_db.authentication.login(access_token)
if py_db.authentication.is_authenticated():
return NetCommand(cmd_id, seq, py_db.authentication.ide_access_token)
return NetCommand(cmd_id, seq, py_db.authentication.client_access_token)
return py_db.cmd_factory.make_error_message(seq, 'Client not authenticated.')

View file

@ -181,10 +181,10 @@ class PyDevJsonCommandProcessor(object):
py_db.writer.add_command(cmd)
def on_pydevdauthorize_request(self, py_db, request):
ide_access_token = py_db.authentication.ide_access_token
client_access_token = py_db.authentication.client_access_token
body = {'clientAccessToken': None}
if ide_access_token:
body['clientAccessToken'] = ide_access_token
if client_access_token:
body['clientAccessToken'] = client_access_token
response = pydevd_base_schema.build_response(request, kwargs={'body': body})
return NetCommand(CMD_RETURN, 0, response, is_json=True)

View file

@ -391,7 +391,7 @@ class ThreadsSuspendedSingleNotification(AbstractSingleNotificationBehavior):
class _Authentication(object):
__slots__ = ['access_token', 'ide_access_token', '_authenticated', '_wrong_attempts']
__slots__ = ['access_token', 'client_access_token', '_authenticated', '_wrong_attempts']
def __init__(self):
# A token to be send in the command line or through the settrace api -- when such token
@ -399,10 +399,10 @@ class _Authentication(object):
# Note that if a disconnect is sent, the same message must be resent to authenticate.
self.access_token = None
# This token is the one that the ide requires to accept a connection from pydevd
# This token is the one that the client requires to accept a connection from pydevd
# (it's stored here and just passed back when required, it's not used internally
# for anything else).
self.ide_access_token = None
self.client_access_token = None
self._authenticated = None
@ -2405,7 +2405,7 @@ def _enable_attach(
dont_trace_end_patterns=(),
patch_multiprocessing=False,
access_token=None,
ide_access_token=None,
client_access_token=None,
):
'''
Starts accepting connections at the given host/port. The debugger will not be initialized nor
@ -2433,7 +2433,7 @@ def _enable_attach(
dont_trace_end_patterns=dont_trace_end_patterns,
patch_multiprocessing=patch_multiprocessing,
access_token=access_token,
ide_access_token=ide_access_token,
client_access_token=client_access_token,
)
py_db = get_global_debugger()
@ -2481,7 +2481,7 @@ def settrace(
dont_trace_start_patterns=(),
dont_trace_end_patterns=(),
access_token=None,
ide_access_token=None,
client_access_token=None,
):
'''Sets the tracing function with the pydev debug function and initializes needed facilities.
@ -2525,7 +2525,7 @@ def settrace(
:param access_token: token to be sent from the client (i.e.: IDE) to the debugger when a connection
is established (verified by the debugger).
:param ide_access_token: token to be sent from the debugger to the client (i.e.: IDE) when
:param client_access_token: token to be sent from the debugger to the client (i.e.: IDE) when
a connection is established (verified by the client).
'''
with _set_trace_lock:
@ -2543,7 +2543,7 @@ def settrace(
dont_trace_start_patterns,
dont_trace_end_patterns,
access_token,
ide_access_token,
client_access_token,
)
@ -2564,7 +2564,7 @@ def _locked_settrace(
dont_trace_start_patterns,
dont_trace_end_patterns,
access_token,
ide_access_token,
client_access_token,
):
if patch_multiprocessing:
try:
@ -2598,9 +2598,9 @@ def _locked_settrace(
if access_token is not None:
py_db.authentication.access_token = access_token
SetupHolder.setup['access-token'] = access_token
if ide_access_token is not None:
py_db.authentication.ide_access_token = ide_access_token
SetupHolder.setup['ide-access-token'] = ide_access_token
if client_access_token is not None:
py_db.authentication.client_access_token = client_access_token
SetupHolder.setup['client-access-token'] = client_access_token
if block_until_connected:
py_db.connect(host, port) # Note: connect can raise error.
@ -2652,8 +2652,8 @@ def _locked_settrace(
# ok, we're already in debug mode, with all set, so, let's just set the break
if access_token is not None:
py_db.authentication.access_token = access_token
if ide_access_token is not None:
py_db.authentication.ide_access_token = ide_access_token
if client_access_token is not None:
py_db.authentication.client_access_token = client_access_token
py_db.set_trace_for_frame_and_parents(get_frame().f_back)
@ -2806,7 +2806,7 @@ def settrace_forked(setup_tracing=True):
if setup is None:
setup = {}
access_token = setup.get('access-token')
ide_access_token = setup.get('ide-access-token')
client_access_token = setup.get('client-access-token')
if setup_tracing:
from _pydevd_frame_eval.pydevd_frame_eval_main import clear_thread_local_info
@ -2830,7 +2830,7 @@ def settrace_forked(setup_tracing=True):
overwrite_prev_trace=True,
patch_multiprocessing=True,
access_token=access_token,
ide_access_token=ide_access_token,
client_access_token=client_access_token,
)
@ -3081,9 +3081,9 @@ def main():
if access_token:
debugger.authentication.access_token = access_token
ide_access_token = setup['ide-access-token']
if ide_access_token:
debugger.authentication.ide_access_token = ide_access_token
client_access_token = setup['client-access-token']
if client_access_token:
debugger.authentication.client_access_token = client_access_token
if fix_app_engine_debug:
sys.stderr.write("pydev debugger: google app engine integration enabled\n")

View file

@ -326,7 +326,7 @@ def case_setup_remote(debugger_runner_remote):
filename,
wait_for_port=True,
access_token=None,
ide_access_token=None,
client_access_token=None,
append_command_line_args=(),
**kwargs
):
@ -339,9 +339,9 @@ def case_setup_remote(debugger_runner_remote):
if access_token is not None:
ret.append('--access-token')
ret.append(access_token)
if ide_access_token is not None:
ret.append('--ide-access-token')
ret.append(ide_access_token)
if client_access_token is not None:
ret.append('--client-access-token')
ret.append(client_access_token)
ret.extend(append_command_line_args)
return ret

View file

@ -1105,11 +1105,11 @@ class AbstractWriterThread(threading.Thread):
def write_set_protocol(self, protocol):
self.write("%s\t%s\t%s" % (CMD_SET_PROTOCOL, self.next_seq(), protocol))
def write_authenticate(self, access_token, ide_access_token):
def write_authenticate(self, access_token, client_access_token):
msg = "%s\t%s\t%s" % (CMD_AUTHENTICATE, self.next_seq(), access_token)
self.write(msg)
self.wait_for_message(lambda msg:ide_access_token in msg, expect_xml=False)
self.wait_for_message(lambda msg:client_access_token in msg, expect_xml=False)
def write_version(self):
from _pydevd_bundle.pydevd_constants import IS_WINDOWS

View file

@ -7,13 +7,13 @@ if __name__ == '__main__':
port = int(args.pop(0))
access_token = None
ide_access_token = None
client_access_token = None
while args:
if args[0] == '--access-token':
access_token = args[1]
args = args[2:]
elif args[0] == '--ide-access-token':
ide_access_token = args[1]
elif args[0] == '--client-access-token':
client_access_token = args[1]
args = args[2:]
else:
raise AssertionError('Unable to handle args: %s' % (sys.argv[1:]))
@ -31,7 +31,7 @@ if __name__ == '__main__':
port=port,
patch_multiprocessing=True,
access_token=access_token,
ide_access_token=ide_access_token,
client_access_token=client_access_token,
)
print('after pydevd.settrace')
sys.stdout.flush()

View file

@ -2759,10 +2759,10 @@ def test_py_37_breakpoint_remote_no_import(case_setup_remote):
def test_remote_debugger_multi_proc(case_setup_remote, authenticate):
access_token = None
ide_access_token = None
client_access_token = None
if authenticate:
access_token = 'tok123'
ide_access_token = 'tok456'
client_access_token = 'tok456'
class _SecondaryMultiProcProcessWriterThread(debugger_unittest.AbstractWriterThread):
@ -2788,7 +2788,7 @@ def test_remote_debugger_multi_proc(case_setup_remote, authenticate):
if authenticate:
self.wait_for_message(lambda msg:'Client not authenticated.' in msg, expect_xml=False)
self.write_authenticate(access_token=access_token, ide_access_token=ide_access_token)
self.write_authenticate(access_token=access_token, client_access_token=client_access_token)
self.write_version()
self.log.append('start_socket')
@ -2806,7 +2806,7 @@ def test_remote_debugger_multi_proc(case_setup_remote, authenticate):
do_kill=do_kill,
EXPECTED_RETURNCODE='any',
access_token=access_token,
ide_access_token=ide_access_token,
client_access_token=client_access_token,
) as writer:
# It seems sometimes it becomes flaky on the ci because the process outlives the writer thread...
@ -2820,7 +2820,7 @@ def test_remote_debugger_multi_proc(case_setup_remote, authenticate):
if authenticate:
writer.wait_for_message(lambda msg:'Client not authenticated.' in msg, expect_xml=False)
writer.write_authenticate(access_token=access_token, ide_access_token=ide_access_token)
writer.write_authenticate(access_token=access_token, client_access_token=client_access_token)
writer.write_make_initial_run()
writer.log.append('waiting for breakpoint hit')
@ -3525,7 +3525,7 @@ def test_access_token(case_setup):
def update_command_line_args(self, args):
args.insert(2, '--access-token')
args.insert(3, 'bar123')
args.insert(2, '--ide-access-token')
args.insert(2, '--client-access-token')
args.insert(3, 'foo234')
return args
@ -3534,7 +3534,7 @@ def test_access_token(case_setup):
writer.wait_for_message(lambda msg:'Client not authenticated.' in msg, expect_xml=False)
writer.write_authenticate(access_token='bar123', ide_access_token='foo234')
writer.write_authenticate(access_token='bar123', client_access_token='foo234')
writer.write_version()

View file

@ -3331,7 +3331,7 @@ def test_access_token(case_setup):
args.insert(1, '--json-dap-http')
args.insert(2, '--access-token')
args.insert(3, 'bar123')
args.insert(4, '--ide-access-token')
args.insert(4, '--client-access-token')
args.insert(5, 'foo321')
return args

View file

@ -126,7 +126,7 @@ def enable_attach(dont_trace_start_patterns, dont_trace_end_patterns):
dont_trace_start_patterns=dont_trace_start_patterns,
dont_trace_end_patterns=dont_trace_end_patterns,
access_token=server_access_token,
ide_access_token=options.client_access_token,
client_access_token=options.client_access_token,
)
log.info("pydevd debug client connected to: {0}:{1}", host, port)
@ -151,7 +151,7 @@ def attach(dont_trace_start_patterns, dont_trace_end_patterns):
patch_multiprocessing=options.multiprocess,
dont_trace_start_patterns=dont_trace_start_patterns,
dont_trace_end_patterns=dont_trace_end_patterns,
ide_access_token=options.client_access_token,
client_access_token=options.client_access_token,
)