def execute_script( self, script_path: str, args: List[str], working_directory: Optional[str] = None, command_name: str = "Run", ) -> None: if (working_directory is not None and get_workbench().get_cwd() != working_directory): # create compound command # start with %cd cd_cmd_line = construct_cmd_line(["%cd", working_directory]) + "\n" next_cwd = working_directory else: # create simple command cd_cmd_line = "" next_cwd = get_workbench().get_cwd() # append main command (Run, run, Debug or debug) rel_filename = os.path.relpath(script_path, next_cwd) exe_cmd_line = ( construct_cmd_line(["%" + command_name, rel_filename] + args) + "\n") # submit to shell (shell will execute it) get_shell().submit_magic_command(cd_cmd_line + exe_cmd_line)
def execute_script( self, script_path: str, args: List[str], working_directory: Optional[str] = None, command_name: str = "Run", ) -> None: if working_directory is not None and get_workbench().get_local_cwd( ) != working_directory: # create compound command # start with %cd cd_cmd_line = construct_cd_command(working_directory) + "\n" next_cwd = working_directory else: # create simple command cd_cmd_line = "" next_cwd = get_workbench().get_local_cwd() if not is_remote_path( script_path) and self._proxy.uses_local_filesystem(): rel_filename = os.path.relpath(script_path, next_cwd) cmd_parts = ["%" + command_name, rel_filename] + args else: cmd_parts = ["%" + command_name, "-c", EDITOR_CONTENT_TOKEN] + args exe_cmd_line = construct_cmd_line(cmd_parts, [EDITOR_CONTENT_TOKEN]) + "\n" # submit to shell (shell will execute it) get_shell().submit_magic_command(cd_cmd_line + exe_cmd_line)
def submit_magic_command(self, cmd_line): if isinstance(cmd_line, list): cmd_line = construct_cmd_line(cmd_line) if not cmd_line.endswith("\n"): cmd_line += "\n" self.text.submit_command(cmd_line, ("magic", ))
def execute_script( self, script_path: str, args: List[str], working_directory: Optional[str] = None, command_name: str = "Run", ) -> None: if self._proxy.get_cwd() != working_directory: # create compound command # start with %cd cd_cmd_line = construct_cd_command(working_directory) + "\n" else: # create simple command cd_cmd_line = "" rel_filename = universal_relpath(script_path, working_directory) cmd_parts = ["%" + command_name, rel_filename] + args exe_cmd_line = construct_cmd_line(cmd_parts, [EDITOR_CONTENT_TOKEN]) + "\n" # submit to shell (shell will execute it) get_shell().submit_magic_command(cd_cmd_line + exe_cmd_line)
def construct_cd_command(path): return construct_cmd_line(["%cd", normpath_with_actual_case(path)])
def long_desc(cmd): return "Command:\n%s\n\nOutput:\n" % construct_cmd_line(cmd)
def execute_editor_content(self, command_name, args): get_shell().submit_magic_command( construct_cmd_line( ["%" + command_name, "-c", EDITOR_CONTENT_TOKEN] + args, [EDITOR_CONTENT_TOKEN] ) )
def construct_cd_command(path) -> str: return construct_cmd_line(["%cd", path])