def launch_request(self, request): from ptvsd.adapter import launchers if self.session.id != 1 or len(servers.connections()): raise request.cant_handle('"attach" expected') sudo = request("sudo", json.default("Sudo" in self.session.debug_options)) if sudo: if sys.platform == "win32": raise request.cant_handle( '"sudo":true is not supported on Windows.') else: if "Sudo" in self.session.debug_options: raise request.isnt_valid( '"sudo":false and "debugOptions":["Sudo"] are mutually exclusive' ) # Launcher doesn't use the command line at all, but we pass the arguments so # that they show up in the terminal if we're using "runInTerminal". if "program" in request: args = request("program", json.array(unicode, vectorize=True, size=(1, ))) elif "module" in request: args = ["-m"] + request( "module", json.array(unicode, vectorize=True, size=(1, ))) elif "code" in request: args = ["-c"] + request( "code", json.array(unicode, vectorize=True, size=(1, ))) else: args = [] args += request("args", json.array(unicode)) console = request( "console", json.enum( "internalConsole", "integratedTerminal", "externalTerminal", optional=True, ), ) console_title = request("consoleTitle", json.default("Python Debug Console")) launchers.spawn_debuggee(self.session, request, sudo, args, console, console_title)
def configurationDone_request(self, request): if self.start_request is None or self.has_started: request.cant_handle( '"configurationDone" is only allowed during handling of a "launch" ' 'or an "attach" request') try: self.has_started = True request.respond(self.server.channel.delegate(request)) except messaging.MessageHandlingError as exc: self.start_request.cant_handle(str(exc)) finally: self.start_request.respond({}) self._propagate_deferred_events() # Notify the IDE of any child processes of the debuggee that aren't already # being debugged. for conn in servers.connections(): if conn.server is None and conn.ppid == self.session.pid: self.notify_of_subprocess(conn)