Package com.mathworks.ci.utilities
Class MatlabCommandRunner
- java.lang.Object
-
- com.mathworks.ci.utilities.MatlabCommandRunner
-
public class MatlabCommandRunner extends Object
-
-
Constructor Summary
Constructors Constructor Description MatlabCommandRunner(MatlabActionParameters params)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEnvironmentVariable(String key, String value)
Adds an environment variable.FilePath
copyFileToTempFolder(String sourceFile, String targetFile)
Copies a resource into the temporary folder.protected FilePath
createFileWithContent(String content)
Creates a file with the specified content in the temporary folder.EnvVars
getEnvVars()
FilePath
getTempFolder()
protected FilePath
prepareRunnerExecutable()
Copies platform specific runner file into the temporary folder.void
redirectStdOut(OutputStream out)
Redirects stdout.void
removeTempFolder()
void
runMatlabCommand(String command)
Spawns a process to run the specified command.
-
-
-
Constructor Detail
-
MatlabCommandRunner
public MatlabCommandRunner(MatlabActionParameters params) throws IOException, InterruptedException
- Throws:
IOException
InterruptedException
-
-
Method Detail
-
runMatlabCommand
public void runMatlabCommand(String command) throws IOException, InterruptedException, MatlabExecutionException
Spawns a process to run the specified command.- Parameters:
command
- The command to run- Throws:
IOException
InterruptedException
MatlabExecutionException
-
redirectStdOut
public void redirectStdOut(OutputStream out)
Redirects stdout.- Parameters:
out
- the OutputStream to write to
-
addEnvironmentVariable
public void addEnvironmentVariable(String key, String value)
Adds an environment variable.- Parameters:
key
- the environment variable namevalue
- the environment variable value
-
getEnvVars
public EnvVars getEnvVars()
-
copyFileToTempFolder
public FilePath copyFileToTempFolder(String sourceFile, String targetFile) throws IOException, InterruptedException
Copies a resource into the temporary folder.- Parameters:
sourceFile
- the name of a resource the class loader can find.targetFile
- the name of the file to create in the temp folder.- Returns:
- the FilePath to the new location in the temp folder.
- Throws:
IOException
InterruptedException
-
getTempFolder
public FilePath getTempFolder()
-
removeTempFolder
public void removeTempFolder() throws IOException, InterruptedException
- Throws:
IOException
InterruptedException
-
createFileWithContent
protected FilePath createFileWithContent(String content) throws IOException, InterruptedException
Creates a file with the specified content in the temporary folder. Additionally, the file content will be prefixed with a statement returning to the MATLAB starting folder.- Parameters:
content
- string that represents the content of the file.- Returns:
- the FilePath to the script file that is created.
- Throws:
IOException
InterruptedException
-
prepareRunnerExecutable
protected FilePath prepareRunnerExecutable() throws IOException, InterruptedException
Copies platform specific runner file into the temporary folder.- Returns:
- the FilePath to the runner executable
- Throws:
IOException
InterruptedException
-
-