Commit 80615cef authored by danielkisov's avatar danielkisov
Browse files

taking pythonPath to execute commands in terminal

parent 6cfb02ca
Pipeline #471789 passed with stage
in 10 minutes and 33 seconds
......@@ -37,6 +37,7 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
private ArchitectureSymbol architecture;
private String backend;
private String customFilesPath = "";
private String pythonPath = "";
public CNNArchSymbolTableCreator(final ResolvingConfiguration resolvingConfig,
......@@ -48,9 +49,11 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
public CNNArchSymbolTableCreator(final ResolvingConfiguration resolvingConfig,
final MutableScope enclosingScope,
String customFilesPath,
String pythonPath,
String backend) {
super(resolvingConfig, enclosingScope);
setBackend(backend);
setPythonPath(pythonPath);
setCustomFilesPath(customFilesPath);
initSuperSTC(resolvingConfig);
}
......@@ -64,9 +67,11 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
public CNNArchSymbolTableCreator(final ResolvingConfiguration resolvingConfig,
final Deque<MutableScope> scopeStack,
String customFilesPath,
String pythonPath,
String backend) {
super(resolvingConfig, scopeStack);
setBackend(backend);
setPythonPath(pythonPath);
setCustomFilesPath(customFilesPath);
initSuperSTC(resolvingConfig);
}
......@@ -107,6 +112,10 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
return this.customFilesPath;
}
private void setPythonPath (String pythonPath){ this.pythonPath = pythonPath; }
public String getPythonPath (){ return this.pythonPath; }
private CNNArchVisitor realThis = this;
@Override
......@@ -225,7 +234,7 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
continue;
}
String nameWithoutExtension = pyFiles[index].substring(0, pyFiles[index].length() - 3);
CustomPythonLayerDeclaration declaration = new CustomPythonLayerDeclaration(nameWithoutExtension, customFilesPath, "python");
CustomPythonLayerDeclaration declaration = new CustomPythonLayerDeclaration(nameWithoutExtension, customFilesPath, pythonPath, "python");
declaration.setParameters(declaration.extractParametersFromFile());
addToScope(declaration);
}
......
......@@ -20,8 +20,15 @@ import java.util.List;
public class CustomPythonLayerDeclaration extends CustomLayerDeclaration{
public CustomPythonLayerDeclaration(String name, File customPythonFilePath, String language) {
private String pythonPath = "";
public CustomPythonLayerDeclaration(String name, File customPythonFilePath, String pythonPath, String language) {
super(name, customPythonFilePath, language);
if(pythonPath == ""){
this.pythonPath = "python";
} else {
this.pythonPath = pythonPath;
}
}
//extracting parameters by taking the information from the python file of the layer
......@@ -33,15 +40,15 @@ public class CustomPythonLayerDeclaration extends CustomLayerDeclaration{
try {
String callingPrintMethod = "import " + getName() + "; temp=" + getName() + "." + getName() + "(); temp.print_parameters()";
if (SystemUtils.IS_OS_WINDOWS == false) {
printParametersOfLayer = "python -c '" + callingPrintMethod + "'";
printParametersOfLayer = this.pythonPath + " -c '" + callingPrintMethod + "'";
terminal = "/bin/bash";
com = "-c";
} else {
printParametersOfLayer = "python -c \"" + callingPrintMethod + "\"";
printParametersOfLayer = this.pythonPath + " -c \"" + callingPrintMethod + "\"";
terminal = "cmd.exe";
com = "/c";
}
Process process = Runtime.getRuntime().exec(new String[]{terminal, com, printParametersOfLayer}, null, getCustomFilePath());
Process process = Runtime.getRuntime().exec(new String[]{terminal, com, printParametersOfLayer},null, getCustomFilePath());
String line = null;
ArrayList<String> hold = new ArrayList<>();
......@@ -263,7 +270,7 @@ public class CustomPythonLayerDeclaration extends CustomLayerDeclaration{
}
public CustomPythonLayerDeclaration deepCopy() {
CustomPythonLayerDeclaration copy = new CustomPythonLayerDeclaration(getName(), getCustomFilePath(), getLanguage());
CustomPythonLayerDeclaration copy = new CustomPythonLayerDeclaration(getName(), getCustomFilePath(), this.pythonPath, getLanguage());
if (getAstNode().isPresent()){
copy.setAstNode(getAstNode().get());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment