def execute_current(self, command_name: str) -> None: """ This method's job is to create a command for running/debugging current file/script and submit it to shell """ if not self.is_waiting_toplevel_command(): self.restart_backend(True, False, 2) filename = get_saved_current_script_filename() if not filename: # user has cancelled file saving return if ( is_remote_path(filename) and not self._proxy.can_run_remote_files() or is_local_path(filename) and not self._proxy.can_run_local_files() ): self.execute_editor_content(command_name, self._get_active_arguments()) else: if get_workbench().get_option("run.auto_cd") and command_name[0].isupper(): working_directory = get_target_dirname_from_editor_filename(filename) else: working_directory = self._proxy.get_cwd() if is_local_path(filename): target_path = filename else: target_path = extract_target_path(filename) self.execute_script( target_path, self._get_active_arguments(), working_directory, command_name )
def execute_current(self, command_name: str) -> None: """ This method's job is to create a command for running/debugging current file/script and submit it to shell """ if not self.is_waiting_toplevel_command(): self.restart_backend(True, False, 2) filename = get_saved_current_script_filename() if not filename: # user has cancelled file saving return if is_remote_path(filename) or not self._proxy.uses_local_filesystem(): working_directory = None else: # changing dir may be required script_dir = os.path.dirname(filename) if get_workbench().get_option("run.auto_cd") and command_name[0].isupper(): working_directory = script_dir # type: Optional[str] else: working_directory = None args = self._get_active_arguments() self.execute_script(filename, args, working_directory, command_name)
def _cmd_run_current_script_in_terminal(self) -> None: filename = get_saved_current_script_filename() self._proxy.run_script_in_terminal( filename, self._get_active_arguments(), get_workbench().get_option("run.run_in_terminal_python_repl"), get_workbench().get_option("run.run_in_terminal_keep_open"), )