Package org.scictrl.csshell.python
Class PythonRunner
java.lang.Object
org.scictrl.csshell.python.PythonRunner
- Direct Known Subclasses:
EmittanceCalculator
PythonRunner executes python scripts in working directory and parses returned output as double array.
- Author:
- igor@scictrl.com
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
ConstantPYTHON_BIN="/usr/bin/python3"
, points to Python executable, but be present on system. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionexecuteArrayTransaction
(double... inputs) Executes string, add input double values are provided as list of input parameters for script, separated by space.Getter for the fielddirectory
.double[]
Getter for the fieldlastData
.Getter for the fieldlastResult
.Getter for the fieldscript
.static final double
parseDouble
(String value) Parse string representing Python number and return as Java numeral.void
setDirectory
(File directory) Setter for the fielddirectory
.void
Setter for the fieldscript
.
-
Field Details
-
PYTHON_BIN
ConstantPYTHON_BIN="/usr/bin/python3"
, points to Python executable, but be present on system.- See Also:
-
-
Constructor Details
-
PythonRunner
public PythonRunner()Constructor for PythonRunner.
-
-
Method Details
-
parseDouble
Parse string representing Python number and return as Java numeral.- Parameters:
value
- string representing Python number- Returns:
- number
-
setDirectory
Setter for the field
directory
.- Parameters:
directory
- aFile
object
-
getDirectory
Getter for the field
directory
.- Returns:
- a
File
object
-
setScript
Setter for the field
script
.- Parameters:
script
- aString
object
-
getScript
Getter for the field
script
.- Returns:
- a
String
object
-
executeArrayTransaction
Executes string, add input double values are provided as list of input parameters for script, separated by space.
Returned result is expected to be series of string lines. If line is started by # or empty space it is added to string result. If starts with character, then results are search within ( ) ad array separated by comma.
- Parameters:
inputs
- a double- Returns:
- a
PythonRunner.Result
object
-
getLastData
public double[] getLastData()Getter for the field
lastData
.- Returns:
- an array of
invalid reference
double
-
getLastResult
Getter for the field
lastResult
.- Returns:
- a
PythonRunner.Result
object
-