Commit 9871fcb2 authored by Andrey Filippov's avatar Andrey Filippov

more on remote console applications

parent 743b1642
/*******************************************************************************
* Copyright (c) 2014 Elphel, Inc.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Eclipse/VDT plug-in is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
package com.elphel.vdt.core.launching;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.debug.internal.ui.views.console.ProcessConsole;
//import org.eclipse.core.resources.IProject;
//import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.IStreamListener;
//import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IProcess;
//import org.eclipse.debug.ui.DebugUITools;
//import org.eclipse.ui.console.ConsolePlugin;
//import org.eclipse.ui.console.IConsoleManager;
//import org.eclipse.ui.console.IPatternMatchListener;
//import org.eclipse.ui.console.MessageConsole;
import org.eclipse.debug.core.model.IStreamMonitor;
import org.eclipse.debug.core.model.IStreamsProxy;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.ui.console.IConsole;
//import org.eclipse.debug.ui.console.IConsole;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.IOConsole;
import org.eclipse.ui.console.IOConsoleInputStream;
import org.eclipse.ui.console.IOConsoleOutputStream;
import com.elphel.vdt.Txt;
import com.elphel.vdt.core.tools.contexts.BuildParamsItem;
import com.elphel.vdt.ui.MessageUI;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.parser.OutlineContainer;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
//import com.elphel.vdt.core.Utils;
import org.eclipse.ui.console.IConsoleListener;
public class RunningBuilds {
// int nextBuildStep=0;
private final Map<String, VDTRunnerConfiguration> unfinishedBuilds;
public RunningBuilds(){
unfinishedBuilds = new ConcurrentHashMap<String, VDTRunnerConfiguration>();
IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
// This is not used, just for testing
System.out.println("***Addded console listeners");
manager.addConsoleListener(new IConsoleListener(){
public void consolesAdded(IConsole[] consoles){
for (int i=0;i<consoles.length;i++){
System.out.println("+++ Added: "+consoles[i].getName());
// Only shows added consoles
}
}
public void consolesRemoved(IConsole[] consoles){
for (int i=0;i<consoles.length;i++){
System.out.println("--- Removed: "+consoles[i].getName());
// unfinishedBuilds.remove(consoles[i]);
removeConsole(consoles[i]);
}
}
});
}
public String findConsoleParent(IConsole console){
Iterator<String> iter=unfinishedBuilds.keySet().iterator();
System.out.println("findConsoleParent("+console.getName()+")");
while (iter.hasNext()) {
String consoleName=iter.next();
System.out.print("Got console name:"+consoleName);
VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName);
if (runConfig.hasConsole(console)){
System.out.println(consoleName+" -> GOT IT");
return consoleName;
}
System.out.println(consoleName+" -> no luck");
}
return null;
}
public void removeConsole(IConsole console){
String consoleName=findConsoleParent(console);
if (consoleName!=null){
VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName);
runConfig.removeConsole(console);
System.out.println("Removing console "+console.getName()+" from runConfig for "+consoleName);
if (runConfig.noConsoles()){
System.out.println("No consoles left in unfinished "+consoleName+" - removing it too");
unfinishedBuilds.remove(consoleName);
}
} else {
System.out.println("Console "+console.getName()+" did not belong here");
}
}
public boolean isUnfinished(IConsole console){
return unfinishedBuilds.containsKey(console);
}
public VDTRunnerConfiguration resumeConfiguration(String consoleName){
VDTRunnerConfiguration conf=unfinishedBuilds.get(consoleName);
unfinishedBuilds.remove(consoleName);
return conf;
}
public VDTRunnerConfiguration getConfiguration(String consoleName){
VDTRunnerConfiguration conf=unfinishedBuilds.get(consoleName);
return conf;
}
public void removeConfiguration(String consoleName){
unfinishedBuilds.remove(consoleName);
}
public void saveUnfinished(String consoleName, VDTRunnerConfiguration configuration ){
unfinishedBuilds.put(consoleName, configuration);
}
} // class RunningBuilds
/*******************************************************************************
* Copyright (c) 2014 Elphel, Inc.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Eclipse/VDT plug-in is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
package com.elphel.vdt.core.launching;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.debug.internal.ui.views.console.ProcessConsole;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.IStreamListener;
//import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IProcess;
//import org.eclipse.debug.ui.DebugUITools;
//import org.eclipse.ui.console.ConsolePlugin;
//import org.eclipse.ui.console.IConsoleManager;
//import org.eclipse.ui.console.IPatternMatchListener;
//import org.eclipse.ui.console.MessageConsole;
import org.eclipse.debug.core.model.IStreamMonitor;
//import org.eclipse.debug.core.model.IStreamListener;
import org.eclipse.debug.core.model.IStreamsProxy;
import org.eclipse.swt.graphics.Color;
import org.eclipse.ui.console.IConsole;
//import org.eclipse.debug.ui.console.IConsole;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.IOConsole;
import org.eclipse.ui.console.IOConsoleOutputStream;
import com.elphel.vdt.core.tools.contexts.BuildParamsItem;
import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
public class VDTConsoleRunner{
private final VDTRunnerConfiguration runConfig;
private IProcess processErr=null;
private IProcess processOut=null;
private IStreamsProxy stdoutStreamProxy=null;
private IStreamsProxy stderrStreamProxy=null;
private IStreamsProxy sendErrorsToStreamProxy=null;
private Object errorListener=null; //+
private Object outputListener=null; //+
private IOConsole iCons=null;
private IProcess process=null;
private IStreamsProxy consoleInStreamProxy= null;
public VDTConsoleRunner (VDTRunnerConfiguration runConfig){
this.runConfig=runConfig;
}
private BuildParamsItem getParser( String parserName){
if (parserName==null) return null;
BuildParamsItem[] buildParamsItems = runConfig.getArgumentsItemsArray(); // uses already calculated
if (buildParamsItems==null) return null;
for (int i=0;i<buildParamsItems.length;i++){
if (parserName.equals(buildParamsItems[i].getNameAsParser()))
return buildParamsItems[i];
}
return null;
}
public IOConsole runConsole(String consolePrefix
, ILaunch launch
, IProgressMonitor monitor
) throws CoreException{
VDTRunner runner = VDTLaunchUtil.getRunner();
int numItem=runConfig.getBuildStep();
BuildParamsItem buildParamsItem = runConfig.getArgumentsItemsArray()[numItem]; // uses already calculated
//TODO: Handle monitor
// Find console with name starting with consolePrefix
IConsoleManager man = ConsolePlugin.getDefault().getConsoleManager(); // debugging
IConsole[] consoles=(IConsole[]) man.getConsoles();
// IOConsole iCons=null;
iCons=null;
consoleInStreamProxy=null;
for (int i=0;i<consoles.length;i++){
if (consoles[i].getName().startsWith(consolePrefix)){
iCons=(IOConsole) consoles[i];
break;
}
}
if (iCons==null) {
MessageUI.error("Specified console: "+consolePrefix+" is not found");
return null;
}
// try to send
String[] arguments = runConfig.getToolArguments();
if (arguments == null) arguments=new String[0];
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
// System.out.println("patternErrors= \""+ runConfig.getPatternErrors()+"\"");
// System.out.println("patternWarnings= \""+runConfig.getPatternWarnings()+"\"");
// System.out.println("patternInfo= \"" +runConfig.getPatternInfo()+"\"");
if (arguments!=null){
for (int i=0;i<arguments.length;i++){
System.out.println("Console line "+i+" = \""+arguments[i]+"\"");
}
}
}
runner.log("Writing to console "+iCons.getName()+":", arguments, null, false, true); /* Appears in the console of the target Eclipse (immediately erased) */
runner.log("Writing to console "+iCons.getName()+":", arguments, null, false, false); /* Appears in the console of the parent Eclipse */
// IOConsoleInputStream inStream= iCons.getInputStream();
IOConsoleOutputStream outStream= iCons.newOutputStream();
// IProcess process=((ProcessConsole)iCons).getProcess();
process=((ProcessConsole)iCons).getProcess();
// IStreamsProxy consoleInStreamProxy= process.getStreamsProxy();
consoleInStreamProxy= process.getStreamsProxy();
BuildParamsItem stderrParser=getParser(buildParamsItem.getStderr()); // re-parses all - why?
BuildParamsItem stdoutParser=getParser(buildParamsItem.getStdout());
System.out.println("Using parser for stderr: "+((stderrParser!=null)?stderrParser.getNameAsParser():"none")); // actually may be the same as stdout
System.out.println("Using parser for stdout: "+((stdoutParser!=null)?stdoutParser.getNameAsParser():"none"));
processErr=null;
processOut=null;
stdoutStreamProxy=null;
stderrStreamProxy=null;
if (stdoutParser!=null){
List<String> toolArgumentsStdout = new ArrayList<String>();
List<String> stdoutArguments=stdoutParser.getParamsAsList();
if (stdoutArguments != null)
toolArgumentsStdout.addAll(stdoutArguments);
// overwriting runConfig, but this is done sequentially, so OK
runConfig.setToolArguments((String[])toolArgumentsStdout.toArray(new String[toolArgumentsStdout.size()]));
processOut=runner.run(runConfig,
"OUT for "+iCons.getName(),
launch,
null); //monitor);
stdoutStreamProxy= processOut.getStreamsProxy();
//TODO: Add error parsers
}
if (stderrParser!=null){
List<String> toolArgumentsStderr = new ArrayList<String>();
List<String> stderrArguments=stderrParser.getParamsAsList();
if (stderrArguments != null)
toolArgumentsStderr.addAll(stderrArguments);
// overwriting runConfig, but this is done sequentially, so OK
runConfig.setToolArguments((String[])toolArgumentsStderr.toArray(new String[toolArgumentsStderr.size()]));
processErr=runner.run(runConfig,
"ERR for "+iCons.getName(),
launch,
null); //monitor);
stderrStreamProxy= processErr.getStreamsProxy();
//TODO: Add error parsers
}
sendErrorsToStreamProxy=(stderrStreamProxy!=null)?stderrStreamProxy:stdoutStreamProxy;
final IStreamsProxy fSendErrorsToStreamProxy=sendErrorsToStreamProxy;
final IStreamsProxy fSendOutputToStreamProxy= stdoutStreamProxy;
// connect input streams of the parsers to the out from the console process
IStreamMonitor consoleOutStreamMonitor=null;
IStreamMonitor consoleErrStreamMonitor=null;
runConfig.resetConsoleText();
String interrupt=buildParamsItem.getInterrupt(); // Not yet used
runConfig.setConsoleFinish(buildParamsItem.getPrompt());
System.out.println("Using console program termination string: \""+buildParamsItem.getPrompt()+"\"");
errorListener=null;
if (fSendErrorsToStreamProxy!=null){
consoleErrStreamMonitor=consoleInStreamProxy.getErrorStreamMonitor();
// IStreamListener errorListener=null;
errorListener=new IStreamListener(){
public void streamAppended(String text, IStreamMonitor monitor){
// System.out.println("Err:'"+text+"'");
try {
fSendErrorsToStreamProxy.write(text);
} catch (IOException e) {
System.out.println("Can not write errors"); //happens for the last prompt got after finish marker
}
if (runConfig.addConsoleText(text)){
System.out.println("Got finish sequence");
// TODO: launch continuation of the build process
finishConsolescript();
}
}
};
consoleErrStreamMonitor.addListener((IStreamListener) errorListener);
}
outputListener=null;
if (fSendOutputToStreamProxy!=null){
consoleOutStreamMonitor=consoleInStreamProxy.getOutputStreamMonitor();
outputListener=new IStreamListener(){
public void streamAppended(String text, IStreamMonitor monitor){
// System.out.println("Out:'"+text+"'");
try {
fSendOutputToStreamProxy.write(text);
} catch (IOException e) {
System.out.println("Can not write output");
}
if (runConfig.addConsoleText(text)){
System.out.println("Got finish sequence");
// TODO: launch continuation of the build process
finishConsolescript();
}
}
};
consoleOutStreamMonitor.addListener((IStreamListener) outputListener );
}
outStream.setColor(new Color(null, 128, 128, 255));
try {
for (int i=0;i<arguments.length;i++){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.LOCAL_ECHO)) {
outStream.write(arguments[i]+"\n"); // writes to console itself
}
consoleInStreamProxy.write(arguments[i]+"\n");
}
} catch (IOException e) {
System.out.println("Can not write to outStream of console "+iCons.getName());
}
return iCons;
}
// TODO: remove unneeded global vars
public void finishConsolescript() {
System.out.println("finishConsolescript()");
if (consoleInStreamProxy==null) {
System.out.println("Bug: consoleInStreamProxy == null");
return; // or continue other commands?
}
if (errorListener !=null) { // disconnect error stream listener
IStreamMonitor consoleErrorStreamMonitor=consoleInStreamProxy.getOutputStreamMonitor();
consoleErrorStreamMonitor.removeListener((IStreamListener) errorListener);
}
if (outputListener !=null) { // disconnect output stream listener
IStreamMonitor consoleOutStreamMonitor=consoleInStreamProxy.getOutputStreamMonitor();
consoleOutStreamMonitor.removeListener((IStreamListener) outputListener);
}
// terminate parser(s). Do those console listeners (parsers) have to be removed too?
if (processErr!=null){
try {
processErr.terminate();
} catch (DebugException e) {
System.out.println("Failed to reminate processErr parser process");
}
}
if (processOut!=null){
try {
processOut.terminate();
} catch (DebugException e) {
System.out.println("Failed to reminate processOut parser process");
}
}
// Is that all?
// runConfig.setBuildStep(runConfig.getBuildStep()+1); // next task to run
int thisStep=runConfig.getBuildStep();
System.out.println("Finished console task, step was "+thisStep);
runConfig.setBuildStep(thisStep+1); // next task to run
VDTLaunchUtil.getRunner().getRunningBuilds().saveUnfinished(runConfig.getOriginalConsoleName(), runConfig );
try {
VDTLaunchUtil.getRunner().resumeLaunch(runConfig.getOriginalConsoleName()); // replace with console
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} // class VDTConsoleRunner
...@@ -107,9 +107,11 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg ...@@ -107,9 +107,11 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg
runConfig.setBuildStep(0); runConfig.setBuildStep(0);
List<String> controlFiles = VDTLaunchUtil.getControlFiles(configuration); List<String> controlFiles = VDTLaunchUtil.getControlFiles(configuration);
runConfig.setControlFiles((String[])controlFiles.toArray(new String[controlFiles.size()])); runConfig.setControlFiles((String[])controlFiles.toArray(new String[controlFiles.size()]));
// String consoleName=VDTRunner.renderProcessLabel(runConfig.getToolName());
String consoleName=VDTRunner.renderProcessLabel(runConfig.getToolName()); String consoleName=runConfig.getOriginalConsoleName();
runner.saveUnfinished(consoleName, runConfig );
runner.getRunningBuilds().saveUnfinished(consoleName, runConfig );
runner.resumeLaunch(consoleName); runner.resumeLaunch(consoleName);
return; return;
} }
......
...@@ -72,7 +72,7 @@ public class VDTLaunchUtil { ...@@ -72,7 +72,7 @@ public class VDTLaunchUtil {
} }
return toolRunner; return toolRunner;
} }
//runningBuilds
/** /**
* Construct attribute name for command line representations of * Construct attribute name for command line representations of
* tool parameter. * tool parameter.
......
...@@ -74,6 +74,10 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings; ...@@ -74,6 +74,10 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings;
//import com.elphel.vdt.core.Utils; //import com.elphel.vdt.core.Utils;
import org.eclipse.ui.console.IConsoleListener; import org.eclipse.ui.console.IConsoleListener;
...@@ -85,70 +89,27 @@ import org.eclipse.ui.console.IConsoleListener; ...@@ -85,70 +89,27 @@ import org.eclipse.ui.console.IConsoleListener;
*/ */
public class VDTRunner { public class VDTRunner {
private RunningBuilds runningBuilds;
// TODO:Remove
VDTRunnerConfiguration runningConfiguration; // multi-step configuration currently active
int nextBuildStep=0;
private Map<String, VDTRunnerConfiguration> unfinishedBuilds;
public VDTRunner(){ public VDTRunner(){
unfinishedBuilds = new HashMap<String, VDTRunnerConfiguration>(); runningBuilds = new RunningBuilds();
IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
// This is not used, just for testing
System.out.println("***Addded console listeners");
manager.addConsoleListener(new IConsoleListener(){
public void consolesAdded(IConsole[] consoles){
for (int i=0;i<consoles.length;i++){
System.out.println("+++ Added: "+consoles[i].getName());
// Only shows added consoles
}
}
public void consolesRemoved(IConsole[] consoles){
for (int i=0;i<consoles.length;i++){
System.out.println("--- Removed: "+consoles[i].getName());
}
}
});
}
public boolean isUnfinished(String consoleName){
return unfinishedBuilds.containsKey(consoleName);
}
public VDTRunnerConfiguration resumeConfiguration(String consoleName){
VDTRunnerConfiguration conf=unfinishedBuilds.get(consoleName);
unfinishedBuilds.remove(consoleName);
return conf;
} }
public void removeConfiguration(String consoleName){ public RunningBuilds getRunningBuilds(){
unfinishedBuilds.remove(consoleName); return runningBuilds;
}
public void saveUnfinished(String consoleName, VDTRunnerConfiguration configuration ){
unfinishedBuilds.put(consoleName, configuration);
} }
// make call it when console is closed // make call it when console is closed
private void doResumeLaunch( String consoleName ) throws CoreException { private void doResumeLaunch(String consoleName ) throws CoreException {
// System.out.println("--------- resuming "+ consoleName+" ------------"); final VDTRunnerConfiguration runConfig=runningBuilds.resumeConfiguration(consoleName);
VDTRunnerConfiguration runConfig=resumeConfiguration(consoleName);
if (runConfig==null){ if (runConfig==null){
System.out.println("Turned out nothing to do. Probably a bug"); System.out.println("Turned out nothing to do. Probably a bug");
return; return;
} }
// ILaunchConfiguration configuration=runConfig.getConfiguration();
// BuildParamsItem[] argumentsItemsArray = VDTLaunchUtil.getArguments(configuration); // calculates all parameters
BuildParamsItem[] argumentsItemsArray = runConfig.getArgumentsItemsArray(); // uses already calculated BuildParamsItem[] argumentsItemsArray = runConfig.getArgumentsItemsArray(); // uses already calculated
int numItem=runConfig.getBuildStep(); int numItem=runConfig.getBuildStep();
System.out.println("--------- resuming "+ consoleName+", numItem="+numItem+" ------------"); System.out.println("--------- resuming "+ consoleName+", numItem="+numItem+" ------------");
ILaunch launch=runConfig.getLaunch(); ILaunch launch=runConfig.getLaunch();
IProgressMonitor monitor=runConfig.getMonitor(); IProgressMonitor monitor=runConfig.getMonitor();
for (;numItem<argumentsItemsArray.length;numItem++){ for (;numItem<argumentsItemsArray.length;numItem++){
runConfig.setBuildStep(numItem); // was not updated if was not sleeping runConfig.setBuildStep(numItem); // was not updated if was not sleeping
List<String> toolArguments = new ArrayList<String>(); List<String> toolArguments = new ArrayList<String>();
...@@ -159,20 +120,22 @@ public class VDTRunner { ...@@ -159,20 +120,22 @@ public class VDTRunner {
// toolArguments.addAll(resources); // toolArguments.addAll(resources);
runConfig.setToolArguments((String[])toolArguments.toArray(new String[toolArguments.size()])); runConfig.setToolArguments((String[])toolArguments.toArray(new String[toolArguments.size()]));
if (argumentsItemsArray[numItem].getConsoleName()!=null){ if (argumentsItemsArray[numItem].getConsoleName()!=null){
runConsole(argumentsItemsArray[numItem].getConsoleName(),runConfig, launch, monitor); VDTConsoleRunner consoleRunner= runConfig.getConsoleRunner();
continue; consoleRunner.runConsole(argumentsItemsArray[numItem].getConsoleName(), launch, monitor);
return; // Should be awaken by listener when the finish sequence will be output to console
//continue;
} }
if (argumentsItemsArray[numItem].getNameAsParser()!=null){ if (argumentsItemsArray[numItem].getNameAsParser()!=null){
// parsers should be launched by the console scripts, in parallel to them // parsers should be launched by the console scripts, in parallel to them
System.out.println("Skipping parser "+argumentsItemsArray[numItem].getNameAsParser()); System.out.println("Skipping parser "+argumentsItemsArray[numItem].getNameAsParser());
continue; continue;
} }
// Launch the configuration - 1 unit of work // Launch the configuration - 1 unit of work
// VDTRunner runner = VDTLaunchUtil.getRunner(); // VDTRunner runner = VDTLaunchUtil.getRunner();
IProcess process=run( IProcess process=run(
runConfig, runConfig,
renderProcessLabel(runConfig.getToolName()), // toolname + (date) // renderProcessLabel(runConfig.getToolName()), // toolname + (date)
runConfig.getOriginalConsoleName(),
launch, launch,
monitor); monitor);
...@@ -182,7 +145,7 @@ public class VDTRunner { ...@@ -182,7 +145,7 @@ public class VDTRunner {
// check for cancellation // check for cancellation
if (monitor.isCanceled() || (process==null)) { if (monitor.isCanceled() || (process==null)) {
removeConfiguration(consoleName); runningBuilds.removeConfiguration(consoleName);
return; return;
} }
if (numItem<(argumentsItemsArray.length-1)){ // Not for the last if (numItem<(argumentsItemsArray.length-1)){ // Not for the last
...@@ -194,7 +157,7 @@ public class VDTRunner { ...@@ -194,7 +157,7 @@ public class VDTRunner {
System.out.println("Could not get a console for the specified process"); System.out.println("Could not get a console for the specified process");
continue; continue;
} }
System.out.println("consoleName="+consoleName+ System.out.println("originalConsoleName="+consoleName+
"\nprocessConsole name="+iCons.getName()); "\nprocessConsole name="+iCons.getName());
final IOConsole fiCons=iCons; final IOConsole fiCons=iCons;
// final String fConsoleName=fiCons.getName(); // actual console name - may be already "<terminated> ... " // final String fConsoleName=fiCons.getName(); // actual console name - may be already "<terminated> ... "
...@@ -206,16 +169,16 @@ public class VDTRunner { ...@@ -206,16 +169,16 @@ public class VDTRunner {
} }
/* Prepare to postpone next commands to be resumed by event*/ /* Prepare to postpone next commands to be resumed by event*/
runConfig.setBuildStep(numItem+1); runConfig.setBuildStep(numItem+1);
saveUnfinished(consoleName, runConfig ); runningBuilds.saveUnfinished(consoleName, runConfig );
iCons.addPropertyChangeListener( new IPropertyChangeListener() { iCons.addPropertyChangeListener( new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) { public void propertyChange(PropertyChangeEvent event) {
if (!fConsoleName.equals(fiCons.getName())){ if (!fConsoleName.equals(fiCons.getName())){
fiCons.removePropertyChangeListener(this); fiCons.removePropertyChangeListener(this);
System.out.println(">>> "+fConsoleName+" -> "+fiCons.getName()); System.out.println(">>> "+fConsoleName+" -> "+fiCons.getName());
VDTRunner runner = VDTLaunchUtil.getRunner(); // VDTRunner runner = VDTLaunchUtil.getRunner();
try { try {
runner.resumeLaunch(fConsoleName); resumeLaunch(fConsoleName); // replace with console
} catch (CoreException e) { } catch (CoreException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
...@@ -235,157 +198,7 @@ public class VDTRunner { ...@@ -235,157 +198,7 @@ public class VDTRunner {
monitor.done(); monitor.done();
} }
private BuildParamsItem getParser(VDTRunnerConfiguration configuration, String parserName){ public void resumeLaunch(String consoleName) throws CoreException
if (parserName==null) return null;
BuildParamsItem[] buildParamsItems = configuration.getArgumentsItemsArray(); // uses already calculated
if (buildParamsItems==null) return null;
for (int i=0;i<buildParamsItems.length;i++){
if (parserName.equals(buildParamsItems[i].getNameAsParser()))
return buildParamsItems[i];
}
return null;
}
public IOConsole runConsole(String consolePrefix
, VDTRunnerConfiguration configuration
, ILaunch launch
, IProgressMonitor monitor
) throws CoreException{
int numItem=configuration.getBuildStep();
// BuildParamsItem buildParamsItem= VDTLaunchUtil.getArguments(configuration.getConfiguration())[numItem];
BuildParamsItem buildParamsItem = configuration.getArgumentsItemsArray()[numItem]; // uses already calculated
//TODO: Handle monitor
// Find console with name starting with consolePrefix
IConsoleManager man = ConsolePlugin.getDefault().getConsoleManager(); // debugging
IConsole[] consoles=(IConsole[]) man.getConsoles();
IOConsole iCons=null;
for (int i=0;i<consoles.length;i++){
if (consoles[i].getName().startsWith(consolePrefix)){
iCons=(IOConsole) consoles[i];
break;
}
}
if (iCons==null) {
MessageUI.error("Specified console: "+consolePrefix+" is not found");
return null;
}
// try to send
String[] arguments = configuration.getToolArguments();
if (arguments == null) arguments=new String[0];
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
// System.out.println("patternErrors= \""+ configuration.getPatternErrors()+"\"");
// System.out.println("patternWarnings= \""+configuration.getPatternWarnings()+"\"");
// System.out.println("patternInfo= \"" +configuration.getPatternInfo()+"\"");
if (arguments!=null){
for (int i=0;i<arguments.length;i++){
System.out.println("Console line "+i+" = \""+arguments[i]+"\"");
}
}
}
log("Writing to console "+iCons.getName()+":", arguments, null, false, true); /* Appears in the console of the target Eclipse (immediately erased) */
log("Writing to console "+iCons.getName()+":", arguments, null, false, false); /* Appears in the console of the parent Eclipse */
// IOConsoleInputStream inStream= iCons.getInputStream();
IOConsoleOutputStream outStream= iCons.newOutputStream();
IProcess process=((ProcessConsole)iCons).getProcess();
IStreamsProxy consoleInStreamProxy= process.getStreamsProxy();
BuildParamsItem stderrParser=getParser(configuration, buildParamsItem.getStderr()); // re-parses all - why?
BuildParamsItem stdoutParser=getParser(configuration, buildParamsItem.getStdout());
System.out.println("Using parser for stderr: "+((stderrParser!=null)?stderrParser.getNameAsParser():"none")); // actually may be the same as stdout
System.out.println("Using parser for stdout: "+((stdoutParser!=null)?stdoutParser.getNameAsParser():"none"));
// basically use
// IProcess process=run(configuration, launch, monitor);
// renderProcessLabel(configuration.getToolName()+":out")
IProcess processErr=null;
IProcess processOut=null;
IStreamsProxy stdoutStreamProxy=null;
IStreamsProxy stderrStreamProxy=null;
if (stdoutParser!=null){
List<String> toolArgumentsStdout = new ArrayList<String>();
List<String> stdoutArguments=stdoutParser.getParamsAsList();
if (stdoutArguments != null)
toolArgumentsStdout.addAll(stdoutArguments);
// overwriting configuration, but this is done sequentially, so OK
configuration.setToolArguments((String[])toolArgumentsStdout.toArray(new String[toolArgumentsStdout.size()]));
processOut=run(configuration,
renderProcessLabel(configuration.getToolName()+":out"),
launch,
null); //monitor);
stdoutStreamProxy= processOut.getStreamsProxy();
//TODO: Add error parsers
}
if (stderrParser!=null){
List<String> toolArgumentsStderr = new ArrayList<String>();
List<String> stderrArguments=stderrParser.getParamsAsList();
if (stderrArguments != null)
toolArgumentsStderr.addAll(stderrArguments);
// overwriting configuration, but this is done sequentially, so OK
configuration.setToolArguments((String[])toolArgumentsStderr.toArray(new String[toolArgumentsStderr.size()]));
processErr=run(configuration,
renderProcessLabel(configuration.getToolName()+":err"),
launch,
null); //monitor);
stderrStreamProxy= processErr.getStreamsProxy();
//TODO: Add error parsers
}
final IStreamsProxy fSendErrorsToStreamProxy=(stderrStreamProxy!=null)?stderrStreamProxy:stdoutStreamProxy;
final IStreamsProxy fSendOutputToStreamProxy= stdoutStreamProxy;
// connect input streams of the parsers to the out from the console process
IStreamMonitor consoleOutStreamMonitor=null;
IStreamMonitor consoleErrStreamMonitor=null;
if (fSendErrorsToStreamProxy!=null){
consoleErrStreamMonitor=consoleInStreamProxy.getErrorStreamMonitor();
consoleErrStreamMonitor.addListener(new IStreamListener(){
public void streamAppended(String text, IStreamMonitor monitor){
System.out.println("Err:'"+text+"'");
try {
fSendErrorsToStreamProxy.write(text);
} catch (IOException e) {
System.out.println("Can not write errors");
}
}
});
}
if (fSendOutputToStreamProxy!=null){
consoleOutStreamMonitor=consoleInStreamProxy.getOutputStreamMonitor();
consoleOutStreamMonitor.addListener(new IStreamListener(){
public void streamAppended(String text, IStreamMonitor monitor){
System.out.println("Out:'"+text+"'");
try {
fSendOutputToStreamProxy.write(text);
} catch (IOException e) {
System.out.println("Can not write output");
}
}
});
}
try {
for (int i=0;i<arguments.length;i++){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.LOCAL_ECHO)) {
outStream.setColor(new Color(null, 128, 128, 255));
outStream.write(arguments[i]+"\n"); // writes to console itself
outStream.setColor(null);
}
consoleInStreamProxy.write(arguments[i]+"\n");
}
} catch (IOException e) {
System.out.println("Can not write to outStream of console "+iCons.getName());
}
return iCons;
}
public void resumeLaunch( String consoleName ) throws CoreException
{ {
try { try {
doResumeLaunch(consoleName); doResumeLaunch(consoleName);
...@@ -565,7 +378,7 @@ public class VDTRunner { ...@@ -565,7 +378,7 @@ public class VDTRunner {
} // run() } // run()
private void log(String header, public void log(String header,
String[] strings, String[] strings,
String[] controlFiles, String[] controlFiles,
boolean formatColumn, boolean formatColumn,
......
...@@ -17,9 +17,14 @@ ...@@ -17,9 +17,14 @@
*******************************************************************************/ *******************************************************************************/
package com.elphel.vdt.core.launching; package com.elphel.vdt.core.launching;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
//import org.eclipse.debug.ui.console.IConsole;
import org.eclipse.ui.console.IConsole;
import com.elphel.vdt.Txt; import com.elphel.vdt.Txt;
import com.elphel.vdt.core.tools.contexts.BuildParamsItem; import com.elphel.vdt.core.tools.contexts.BuildParamsItem;
...@@ -56,6 +61,13 @@ public class VDTRunnerConfiguration { ...@@ -56,6 +61,13 @@ public class VDTRunnerConfiguration {
private IProgressMonitor monitor; private IProgressMonitor monitor;
private BuildParamsItem[] argumentsItemsArray; // calculate once for the launch of the sequence private BuildParamsItem[] argumentsItemsArray; // calculate once for the launch of the sequence
private String consoleFinish; // double prompt? - string to look for in consoleBuffer to finish
private String consoleBuffer; // accumulates stdout & stderr, looking for consoleFinish (endsWith() )
private int extraChars=100; // Allow these chars to appear in the output after consoleFinish (user pressed smth.?)
private String originalConsoleName=null;
private Set<IConsole> consoles=null; // parser consoles opened for this console
private VDTConsoleRunner consoleRunner=null;
public BuildParamsItem[] getArgumentsItemsArray(){ public BuildParamsItem[] getArgumentsItemsArray(){
return argumentsItemsArray; return argumentsItemsArray;
...@@ -78,8 +90,52 @@ public class VDTRunnerConfiguration { ...@@ -78,8 +90,52 @@ public class VDTRunnerConfiguration {
throw new IllegalArgumentException(Txt.s("Launch.Error.ToolNotNull")); throw new IllegalArgumentException(Txt.s("Launch.Error.ToolNotNull"));
} }
this.toolToLaunch = toolToLaunch; this.toolToLaunch = toolToLaunch;
this.consoleFinish=null;
this.consoleBuffer="";
this.consoles= new HashSet<IConsole>();
this.consoleRunner= new VDTConsoleRunner(this); // arguments here?
}
public VDTConsoleRunner getConsoleRunner(){
return this.consoleRunner;
}
public void addConsole(IConsole console){
consoles.add(console);
}
public void removeConsole(IConsole console){
consoles.remove(console);
}
public boolean noConsoles(){
return consoles.isEmpty();
}
public boolean hasConsole(IConsole console){
return consoles.contains(console);
} }
public void setConsoleFinish(String consoleFinish){
this.consoleFinish=consoleFinish;
}
public boolean addConsoleText(String text){
if (consoleFinish==null){
System.out.println("Dinish console sequence is not defined");
return false;
}
consoleBuffer=consoleBuffer+text;
int maxLength=consoleFinish.length()+extraChars;
if (consoleBuffer.length()>(maxLength)){
consoleBuffer=consoleBuffer.substring(consoleBuffer.length()-maxLength);
}
if (consoleBuffer.indexOf(consoleFinish)>=0){
resetConsoleText();
return true;
}
return false;
}
public void resetConsoleText(){
consoleBuffer="";
}
public void setConfiguration(ILaunchConfiguration configuration){ public void setConfiguration(ILaunchConfiguration configuration){
this.configuration=configuration; this.configuration=configuration;
} }
...@@ -160,7 +216,12 @@ public class VDTRunnerConfiguration { ...@@ -160,7 +216,12 @@ public class VDTRunnerConfiguration {
} }
public void setToolName(String str) { public void setToolName(String str) {
this.toolName=str; this.toolName=str;
this.originalConsoleName=VDTRunner.renderProcessLabel(this.toolName); //
} }
public String getOriginalConsoleName() {
return originalConsoleName;
}
public String getToolName() { public String getToolName() {
return toolName; return toolName;
} }
......
...@@ -63,6 +63,8 @@ public class CommandLinesNodeReader extends AbstractConditionNodeReader { ...@@ -63,6 +63,8 @@ public class CommandLinesNodeReader extends AbstractConditionNodeReader {
String warnings = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_WARNINGS_ATTR); String warnings = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_WARNINGS_ATTR);
String info = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_INFO_ATTR); String info = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_INFO_ATTR);
String prompt = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_PROMPT_ATTR); String prompt = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_PROMPT_ATTR);
String interrupt = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_INTERRUPT_ATTR);
String stderr = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_STDERR_ATTR); String stderr = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_STDERR_ATTR);
String stdout = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_STDOUT_ATTR); String stdout = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_STDOUT_ATTR);
...@@ -87,6 +89,7 @@ public class CommandLinesNodeReader extends AbstractConditionNodeReader { ...@@ -87,6 +89,7 @@ public class CommandLinesNodeReader extends AbstractConditionNodeReader {
warnings, warnings,
info, info,
prompt, prompt,
interrupt,
stderr, stderr,
stdout, stdout,
lines, lines,
......
...@@ -132,6 +132,7 @@ public class XMLConfig extends Config { ...@@ -132,6 +132,7 @@ public class XMLConfig extends Config {
static final String CONTEXT_LINEBLOCK_WARNINGS_ATTR = "warnings"; static final String CONTEXT_LINEBLOCK_WARNINGS_ATTR = "warnings";
static final String CONTEXT_LINEBLOCK_INFO_ATTR = "info"; static final String CONTEXT_LINEBLOCK_INFO_ATTR = "info";
static final String CONTEXT_LINEBLOCK_PROMPT_ATTR = "prompt"; static final String CONTEXT_LINEBLOCK_PROMPT_ATTR = "prompt";
static final String CONTEXT_LINEBLOCK_INTERRUPT_ATTR ="interrupt";
static final String CONTEXT_LINEBLOCK_STDERR_ATTR = "stderr"; static final String CONTEXT_LINEBLOCK_STDERR_ATTR = "stderr";
static final String CONTEXT_LINEBLOCK_STDOUT_ATTR = "stdout"; static final String CONTEXT_LINEBLOCK_STDOUT_ATTR = "stdout";
......
...@@ -30,6 +30,7 @@ public class BuildParamsItem implements Cloneable{ ...@@ -30,6 +30,7 @@ public class BuildParamsItem implements Cloneable{
private String toolInfo; // Eclipse pattern for pattern recognizer private String toolInfo; // Eclipse pattern for pattern recognizer
// for commands being sent to opened remote console: // for commands being sent to opened remote console:
private String prompt; // relevant for commands sent to remote console - double prompt means "done" (extra separator on input) private String prompt; // relevant for commands sent to remote console - double prompt means "done" (extra separator on input)
private String interrupt; // control character(s) to interrupt console command
private String stderr; // name of the command to (command line block) to launch in a separate process/console private String stderr; // name of the command to (command line block) to launch in a separate process/console
// and connect to stderr of the terminal session // and connect to stderr of the terminal session
private String stdout; // name of the command to (command line block) to launch in a separate process/console private String stdout; // name of the command to (command line block) to launch in a separate process/console
...@@ -46,6 +47,7 @@ public class BuildParamsItem implements Cloneable{ ...@@ -46,6 +47,7 @@ public class BuildParamsItem implements Cloneable{
String toolWarnings, String toolWarnings,
String toolInfo, String toolInfo,
String prompt, String prompt,
String interrupt,
String stderr, String stderr,
String stdout String stdout
) { ) {
...@@ -57,6 +59,7 @@ public class BuildParamsItem implements Cloneable{ ...@@ -57,6 +59,7 @@ public class BuildParamsItem implements Cloneable{
this.toolWarnings=toolWarnings; this.toolWarnings=toolWarnings;
this.toolInfo=toolInfo; this.toolInfo=toolInfo;
this.prompt=prompt; this.prompt=prompt;
this.interrupt=interrupt;
this.stderr=stderr; this.stderr=stderr;
this.stdout=stdout; this.stdout=stdout;
...@@ -71,6 +74,7 @@ public class BuildParamsItem implements Cloneable{ ...@@ -71,6 +74,7 @@ public class BuildParamsItem implements Cloneable{
item.toolWarnings, item.toolWarnings,
item.toolInfo, item.toolInfo,
item.prompt, item.prompt,
item.interrupt,
item.stderr, item.stderr,
item.stdout item.stdout
); );
...@@ -128,6 +132,7 @@ public class BuildParamsItem implements Cloneable{ ...@@ -128,6 +132,7 @@ public class BuildParamsItem implements Cloneable{
public String getWarnings() { return toolWarnings; } public String getWarnings() { return toolWarnings; }
public String getInfo() { return toolInfo; } public String getInfo() { return toolInfo; }
public String getPrompt() { return prompt; } public String getPrompt() { return prompt; }
public String getInterrupt() { return interrupt; }
public String getStderr() { return stderr; } public String getStderr() { return stderr; }
public String getStdout() { return stdout; } public String getStdout() { return stdout; }
} }
...@@ -215,8 +215,10 @@ public abstract class Context { ...@@ -215,8 +215,10 @@ public abstract class Context {
String toolInfo=commandLinesBlock.getInfo(); String toolInfo=commandLinesBlock.getInfo();
String stderr=commandLinesBlock.getStderr(); String stderr=commandLinesBlock.getStderr();
String stdout=commandLinesBlock.getStdout(); String stdout=commandLinesBlock.getStdout();
String prompt=buildSimpleString(commandLinesBlock.getPrompt()); String prompt=buildSimpleString(commandLinesBlock.getPrompt()); // evaluate string
if ((prompt !=null ) && (mark!=null)) prompt=prompt.replace(mark, ""); prompt=commandLinesBlock.parseCntrl(prompt); // replace control character codes (\n,\t,\x)
prompt=commandLinesBlock.applyMark(prompt); // remove mark sequence
String interrupt=commandLinesBlock.getInterrupt();
List<String> lines = commandLinesBlock.getLines(); // [%Param_Shell_Options, echo BuildDir=%BuildDir ;, echo SimulationTopFile=%SimulationTopFile ;, echo SimulationTopModule=%SimulationTopModule ;, echo BuildDir=%BuildDir;, %Param_PreExe, %Param_Exe, %Param_TopModule, %TopModulesOther, %ModuleLibrary, %LegacyModel, %NoSpecify, %v, %SourceList, %ExtraFiles, %Filter_String] List<String> lines = commandLinesBlock.getLines(); // [%Param_Shell_Options, echo BuildDir=%BuildDir ;, echo SimulationTopFile=%SimulationTopFile ;, echo SimulationTopModule=%SimulationTopModule ;, echo BuildDir=%BuildDir;, %Param_PreExe, %Param_Exe, %Param_TopModule, %TopModulesOther, %ModuleLibrary, %LegacyModel, %NoSpecify, %v, %SourceList, %ExtraFiles, %Filter_String]
List<List<String>> commandSequence = new ArrayList<List<String>>(); List<List<String>> commandSequence = new ArrayList<List<String>>();
for(Iterator<String> lineIter = lines.iterator(); lineIter.hasNext();) { for(Iterator<String> lineIter = lines.iterator(); lineIter.hasNext();) {
...@@ -224,8 +226,6 @@ public abstract class Context { ...@@ -224,8 +226,6 @@ public abstract class Context {
commandSequence.add(buildCommandString(line)); // TODO: parses them here? VERIFY commandSequence.add(buildCommandString(line)); // TODO: parses them here? VERIFY
} }
// parse prompt?
// Here - already resolved to empty // Here - already resolved to empty
List<String> commandLineParams = new ArrayList<String>(); List<String> commandLineParams = new ArrayList<String>();
if(destName != null) { if(destName != null) {
...@@ -245,6 +245,7 @@ public abstract class Context { ...@@ -245,6 +245,7 @@ public abstract class Context {
toolWarnings, toolWarnings,
toolInfo, toolInfo,
prompt, prompt,
interrupt,
stderr, stderr,
stdout) stdout)
); );
...@@ -279,6 +280,7 @@ public abstract class Context { ...@@ -279,6 +280,7 @@ public abstract class Context {
toolWarnings, toolWarnings,
toolInfo, toolInfo,
prompt, prompt,
interrupt,
stderr, stderr,
stdout) stdout)
); );
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*******************************************************************************/ *******************************************************************************/
package com.elphel.vdt.core.tools.params; package com.elphel.vdt.core.tools.params;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import com.elphel.vdt.core.tools.Updateable; import com.elphel.vdt.core.tools.Updateable;
...@@ -48,6 +49,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer ...@@ -48,6 +49,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer
// and connect to stderr of the terminal session // and connect to stderr of the terminal session
// If both are specified and pointing to the same command block - two instances/consoles will be launched. // If both are specified and pointing to the same command block - two instances/consoles will be launched.
// if only stdout - both stdout and stdin of a session will go to the same process/console // if only stdout - both stdout and stdin of a session will go to the same process/console
private String interrupt; // send this to remote terminal to interrupt execution (parses use \xNN)
public CommandLinesBlock(String contextName, public CommandLinesBlock(String contextName,
...@@ -60,6 +62,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer ...@@ -60,6 +62,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer
String toolWarnings, String toolWarnings,
String toolInfo, String toolInfo,
String prompt, String prompt,
String interrupt,
String stderr, String stderr,
String stdout, String stdout,
ConditionalStringsList lines, ConditionalStringsList lines,
...@@ -78,15 +81,47 @@ public class CommandLinesBlock extends UpdateableStringsContainer ...@@ -78,15 +81,47 @@ public class CommandLinesBlock extends UpdateableStringsContainer
this.toolWarnings=toolWarnings; this.toolWarnings=toolWarnings;
this.toolInfo=toolInfo; this.toolInfo=toolInfo;
this.prompt=prompt; this.prompt=prompt;
this.interrupt=interrupt;
this.stderr=stderr; this.stderr=stderr;
this.stdout=stdout; this.stdout=stdout;
if(separator != null) { if(this.separator != null) {
separator = separator.replace("\\n", "\n"); // separator = separator.replace("\\n", "\n");
separator = separator.replace("\\t", "\t"); // separator = separator.replace("\\t", "\t");
this.separator = parseCntrl(this.separator);
} }
/*
if (this.prompt!=null){
this.prompt=parseCntrl(this.prompt);
if (this.mark!=null){
this.prompt=this.prompt.replace(this.mark,"");
}
}
*/
if(this.interrupt != null) {
this.interrupt = parseCntrl(this.interrupt);
}
} }
public String parseCntrl(String str){
if (str==null) return null;
str=str.replace("\\n" ,"\n");
str=str.replace("\\t", "\t");
while (true){
int start=str.indexOf("\\x");
if (start<0) break;
String s= new String(new byte[]{ Byte.parseByte(str.substring(start+2,start+4),16) }, StandardCharsets.US_ASCII);
str=str.replace(str.subSequence(start,start+4),s);
}
return str;
}
public String applyMark(String str){
if ((mark!=null) && (str!=null)){
str=str.replace(mark, "");
}
return str;
}
public CommandLinesBlock(CommandLinesBlock block) { public CommandLinesBlock(CommandLinesBlock block) {
this(block.contextName, this(block.contextName,
block.name, block.name,
...@@ -98,6 +133,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer ...@@ -98,6 +133,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer
block.toolWarnings, block.toolWarnings,
block.toolInfo, block.toolInfo,
block.prompt, block.prompt,
block.interrupt,
block.stderr, block.stderr,
block.stdout, block.stdout,
block.strings != null? block.strings != null?
...@@ -166,6 +202,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer ...@@ -166,6 +202,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer
public String getWarnings() { return toolWarnings; } public String getWarnings() { return toolWarnings; }
public String getInfo() { return toolInfo; } public String getInfo() { return toolInfo; }
public String getPrompt() { return prompt; } public String getPrompt() { return prompt; }
public String getInterrupt() { return prompt; }
public String getStderr() { return stderr; } public String getStderr() { return stderr; }
public String getStdout() { return stdout; } public String getStdout() { return stdout; }
......
...@@ -34,9 +34,7 @@ public class SimpleGeneratorRecognizer implements Recognizer { ...@@ -34,9 +34,7 @@ public class SimpleGeneratorRecognizer implements Recognizer {
new CurrentFileGenerator(), new CurrentFileGenerator(),
new CurrentFileBaseGenerator(), new CurrentFileBaseGenerator(),
new ChosenActionGenerator(), new ChosenActionGenerator(),
new BuildStampGenerator(), new BuildStampGenerator()
new BlankGenerator(),
new NewLineGenerator()
}; };
public SimpleGeneratorRecognizer(){ public SimpleGeneratorRecognizer(){
......
...@@ -54,10 +54,12 @@ ...@@ -54,10 +54,12 @@
</input> </input>
<output> <output>
<line name="command_line"> <line name="command_line"
interrupt="\x03">
"%ShellSwitches" "%ShellSwitches"
"%PreSSH" "%PreSSH"
"ssh" "ssh"
"-t"
"-l" "-l"
"%RemoteUser" "%RemoteUser"
"%RemoteHost" "%RemoteHost"
...@@ -108,10 +110,11 @@ ...@@ -108,10 +110,11 @@
dest="python_console_name" dest="python_console_name"
mark="``" mark="``"
sep="\n" sep="\n"
prompt=">>>" prompt="@@FINISH@@"
stdout="parser_001"> stdout="parser_001">
"%RemoteCommand" "%RemoteCommand"
"``" <!-- two new lines should generate a pair of prompts from the remote --> "print '@@FINISH@@'"
"``"`" <!-- two new lines should generate a pair of prompts from the remote -->
</line> </line>
<line name="command_line_02"> <line name="command_line_02">
"-c" "-c"
...@@ -132,3 +135,4 @@ ...@@ -132,3 +135,4 @@
</tool> </tool>
</vdt-project> </vdt-project>
<!-- /opt/Xilinx/Vivado/2013.4/bin/vivado -mode tcl -->
\ No newline at end of file
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