def _PrepareLaunch(self, command_line, adapter_config, launch_config): run_config = adapter_config.get('launch', {}) if 'remote' in run_config: remote = run_config['remote'] remote_exec_cmd = self._GetRemoteExecCommand(remote) commands = self._GetCommands(remote, 'run') for index, command in enumerate(commands): cmd = remote_exec_cmd + command[:] full_cmd = [] for item in cmd: if isinstance(command_line, list): if item == '%CMD%': full_cmd.extend(command_line) else: full_cmd.append(item) else: full_cmd.append(item.replace('%CMD%', command_line)) self._logger.debug('Running remote app: %s', full_cmd) self._remote_term = terminal.LaunchTerminal( self._api_prefix, { 'args': full_cmd, 'cwd': os.getcwd() }, self._codeView._window, self._remote_term)
def LaunchTerminal( self, params ): self._terminal = terminal.LaunchTerminal( self._api_prefix, params, window_for_start = self._window, existing_term = self._terminal ) # FIXME: Change this tor return the PID rather than having debug_session # work that out return self._terminal.buffer_number
def _PrepareAttach(self, adapter_config, launch_config): atttach_config = adapter_config.get('attach') if not atttach_config: return if 'remote' in atttach_config: # FIXME: We almost want this to feed-back variables to be expanded later, # e.g. expand variables when we use them, not all at once. This would # remove the whole %PID% hack. remote = atttach_config['remote'] remote_exec_cmd = self._GetRemoteExecCommand(remote) # FIXME: Why does this not use self._GetCommands ? pid_cmd = remote_exec_cmd + remote['pidCommand'] self._logger.debug('Getting PID: %s', pid_cmd) pid = subprocess.check_output(pid_cmd).decode('utf-8').strip() self._logger.debug('Got PID: %s', pid) if not pid: # FIXME: We should raise an exception here or something utils.UserMessage('Unable to get PID', persist=True) return if 'initCompleteCommand' in remote: initcmd = remote_exec_cmd + remote['initCompleteCommand'][:] for index, item in enumerate(initcmd): initcmd[index] = item.replace('%PID%', pid) self._on_init_complete_handlers.append( lambda: subprocess.check_call(initcmd)) commands = self._GetCommands(remote, 'attach') for command in commands: cmd = remote_exec_cmd + command for index, item in enumerate(cmd): cmd[index] = item.replace('%PID%', pid) self._logger.debug('Running remote app: %s', cmd) self._remote_term = terminal.LaunchTerminal( self._api_prefix, { 'args': cmd, 'cwd': os.getcwd() }, self._codeView._window, self._remote_term) else: if atttach_config['pidSelect'] == 'ask': prop = atttach_config['pidProperty'] if prop not in launch_config: pid = utils.AskForInput('Enter PID to attach to: ') if pid is None: return launch_config[prop] = pid return elif atttach_config['pidSelect'] == 'none': return raise ValueError('Unrecognised pidSelect {0}'.format( atttach_config['pidSelect']))