(self, request)
| 285 | |
| 286 | @_start_message_handler |
| 287 | def launch_request(self, request): |
| 288 | from debugpy.adapter import launchers |
| 289 | |
| 290 | if self.session.id != 1 or len(servers.connections()): |
| 291 | raise request.cant_handle('"attach" expected') |
| 292 | |
| 293 | debug_options = set(request("debugOptions", json.array(str))) |
| 294 | |
| 295 | # Handling of properties that can also be specified as legacy "debugOptions" flags. |
| 296 | # If property is explicitly set to false, but the flag is in "debugOptions", treat |
| 297 | # it as an error. Returns None if the property wasn't explicitly set either way. |
| 298 | def property_or_debug_option(prop_name, flag_name): |
| 299 | assert prop_name[0].islower() and flag_name[0].isupper() |
| 300 | |
| 301 | value = request(prop_name, bool, optional=True) |
| 302 | if value == (): |
| 303 | value = None |
| 304 | |
| 305 | if flag_name in debug_options: |
| 306 | if value is False: |
| 307 | raise request.isnt_valid( |
| 308 | '{0}:false and "debugOptions":[{1}] are mutually exclusive', |
| 309 | json.repr(prop_name), |
| 310 | json.repr(flag_name), |
| 311 | ) |
| 312 | value = True |
| 313 | |
| 314 | return value |
| 315 | |
| 316 | # "pythonPath" is a deprecated legacy spelling. If "python" is missing, then try |
| 317 | # the alternative. But if both are missing, the error message should say "python". |
| 318 | python_key = "python" |
| 319 | if python_key in request: |
| 320 | if "pythonPath" in request: |
| 321 | raise request.isnt_valid( |
| 322 | '"pythonPath" is not valid if "python" is specified' |
| 323 | ) |
| 324 | elif "pythonPath" in request: |
| 325 | python_key = "pythonPath" |
| 326 | python = request(python_key, json.array(str, vectorize=True, size=(0,))) |
| 327 | if not len(python): |
| 328 | python = [sys.executable] |
| 329 | |
| 330 | python += request("pythonArgs", json.array(str, size=(0,))) |
| 331 | request.arguments["pythonArgs"] = python[1:] |
| 332 | request.arguments["python"] = python |
| 333 | |
| 334 | launcher_python = request("debugLauncherPython", str, optional=True) |
| 335 | if launcher_python == (): |
| 336 | launcher_python = python[0] |
| 337 | |
| 338 | program = module = code = () |
| 339 | if "program" in request: |
| 340 | program = request("program", str) |
| 341 | args = [program] |
| 342 | request.arguments["processName"] = program |
| 343 | if "module" in request: |
| 344 | module = request("module", str) |
nothing calls this directly
no test coverage detected