Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vdt-plugin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
vdt-plugin
Commits
10b43301
Commit
10b43301
authored
Feb 01, 2014
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disconnecting stdin instead of terminating parser processes, several
other small changes
parent
1621d905
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
173 additions
and
35 deletions
+173
-35
VDTConsoleRunner.java
src/com/elphel/vdt/core/launching/VDTConsoleRunner.java
+51
-9
Context.java
src/com/elphel/vdt/core/tools/contexts/Context.java
+71
-21
AbstractGenerator.java
...m/elphel/vdt/core/tools/generators/AbstractGenerator.java
+7
-3
CommandLinesBlock.java
src/com/elphel/vdt/core/tools/params/CommandLinesBlock.java
+1
-1
Parameter.java
src/com/elphel/vdt/core/tools/params/Parameter.java
+2
-1
ContextParamListRecognizer.java
.../tools/params/recognizers/ContextParamListRecognizer.java
+41
-0
No files found.
src/com/elphel/vdt/core/launching/VDTConsoleRunner.java
View file @
10b43301
...
@@ -39,6 +39,7 @@ import org.eclipse.debug.core.model.IProcess;
...
@@ -39,6 +39,7 @@ import org.eclipse.debug.core.model.IProcess;
import
org.eclipse.debug.core.model.IStreamMonitor
;
import
org.eclipse.debug.core.model.IStreamMonitor
;
//import org.eclipse.debug.core.model.IStreamListener;
//import org.eclipse.debug.core.model.IStreamListener;
import
org.eclipse.debug.core.model.IStreamsProxy
;
import
org.eclipse.debug.core.model.IStreamsProxy
;
import
org.eclipse.debug.core.model.IStreamsProxy2
;
import
org.eclipse.swt.graphics.Color
;
import
org.eclipse.swt.graphics.Color
;
import
org.eclipse.ui.console.IConsole
;
import
org.eclipse.ui.console.IConsole
;
//import org.eclipse.debug.ui.console.IConsole;
//import org.eclipse.debug.ui.console.IConsole;
...
@@ -57,11 +58,13 @@ public class VDTConsoleRunner{
...
@@ -57,11 +58,13 @@ public class VDTConsoleRunner{
private
final
VDTRunnerConfiguration
runConfig
;
//*
private
final
VDTRunnerConfiguration
runConfig
;
//*
private
IProcess
processErr
=
null
;
//*
private
IProcess
processErr
=
null
;
//*
private
IProcess
processOut
=
null
;
//*
private
IProcess
processOut
=
null
;
//*
private
IStreamsProxy
sendErrorsToStreamProxy
=
null
;
private
IStreamsProxy
2
sendErrorsToStreamProxy
=
null
;
private
Object
errorListener
=
null
;
//+
private
Object
errorListener
=
null
;
//+
private
Object
outputListener
=
null
;
//+
private
Object
outputListener
=
null
;
//+
private
IStreamsProxy
consoleInStreamProxy
=
null
;
//+
private
IStreamsProxy
2
consoleInStreamProxy
=
null
;
//+
private
Timer
timer
;
private
Timer
timer
;
private
IStreamsProxy2
stdoutStreamProxy
=
null
;
private
IStreamsProxy2
stderrStreamProxy
=
null
;
public
VDTConsoleRunner
(
VDTRunnerConfiguration
runConfig
){
public
VDTConsoleRunner
(
VDTRunnerConfiguration
runConfig
){
...
@@ -122,7 +125,7 @@ public class VDTConsoleRunner{
...
@@ -122,7 +125,7 @@ public class VDTConsoleRunner{
runner
.
log
(
"Writing to console "
+
iCons
.
getName
()+
":"
,
arguments
,
null
,
false
,
false
);
/* Appears in the console of the parent Eclipse */
runner
.
log
(
"Writing to console "
+
iCons
.
getName
()+
":"
,
arguments
,
null
,
false
,
false
);
/* Appears in the console of the parent Eclipse */
IOConsoleOutputStream
outStream
=
iCons
.
newOutputStream
();
IOConsoleOutputStream
outStream
=
iCons
.
newOutputStream
();
IProcess
process
=((
ProcessConsole
)
iCons
).
getProcess
();
IProcess
process
=((
ProcessConsole
)
iCons
).
getProcess
();
consoleInStreamProxy
=
process
.
getStreamsProxy
();
consoleInStreamProxy
=
(
IStreamsProxy2
)
process
.
getStreamsProxy
();
int
stderrParserIndex
=
getParserIndex
(
buildParamsItem
.
getStderr
());
int
stderrParserIndex
=
getParserIndex
(
buildParamsItem
.
getStderr
());
int
stdoutParserIndex
=
getParserIndex
(
buildParamsItem
.
getStdout
());
int
stdoutParserIndex
=
getParserIndex
(
buildParamsItem
.
getStdout
());
BuildParamsItem
stderrParser
=(
stderrParserIndex
>=
0
)?
runConfig
.
getArgumentsItemsArray
()[
stderrParserIndex
]:
null
;
BuildParamsItem
stderrParser
=(
stderrParserIndex
>=
0
)?
runConfig
.
getArgumentsItemsArray
()[
stderrParserIndex
]:
null
;
...
@@ -133,8 +136,10 @@ public class VDTConsoleRunner{
...
@@ -133,8 +136,10 @@ public class VDTConsoleRunner{
}
}
processErr
=
null
;
processErr
=
null
;
processOut
=
null
;
processOut
=
null
;
IStreamsProxy
stdoutStreamProxy
=
null
;
// IStreamsProxy2 stdoutStreamProxy=null;
IStreamsProxy
stderrStreamProxy
=
null
;
// IStreamsProxy2 stderrStreamProxy=null;
stdoutStreamProxy
=
null
;
stderrStreamProxy
=
null
;
if
(
stdoutParser
!=
null
){
if
(
stdoutParser
!=
null
){
List
<
String
>
toolArgumentsStdout
=
new
ArrayList
<
String
>();
List
<
String
>
toolArgumentsStdout
=
new
ArrayList
<
String
>();
List
<
String
>
stdoutArguments
=
stdoutParser
.
getParamsAsList
();
List
<
String
>
stdoutArguments
=
stdoutParser
.
getParamsAsList
();
...
@@ -147,7 +152,7 @@ public class VDTConsoleRunner{
...
@@ -147,7 +152,7 @@ public class VDTConsoleRunner{
launch
,
launch
,
null
,
//monitor
null
,
//monitor
stdoutParserIndex
);
stdoutParserIndex
);
stdoutStreamProxy
=
processOut
.
getStreamsProxy
();
stdoutStreamProxy
=
(
IStreamsProxy2
)
processOut
.
getStreamsProxy
();
}
}
if
(
stderrParser
!=
null
){
if
(
stderrParser
!=
null
){
...
@@ -162,13 +167,13 @@ public class VDTConsoleRunner{
...
@@ -162,13 +167,13 @@ public class VDTConsoleRunner{
launch
,
launch
,
null
,
//monitor);
null
,
//monitor);
stderrParserIndex
);
stderrParserIndex
);
stderrStreamProxy
=
processErr
.
getStreamsProxy
();
stderrStreamProxy
=
(
IStreamsProxy2
)
processErr
.
getStreamsProxy
();
//TODO: Add error parsers
//TODO: Add error parsers
}
}
sendErrorsToStreamProxy
=(
stderrStreamProxy
!=
null
)?
stderrStreamProxy:
stdoutStreamProxy
;
sendErrorsToStreamProxy
=(
stderrStreamProxy
!=
null
)?
stderrStreamProxy:
stdoutStreamProxy
;
final
IStreamsProxy
fSendErrorsToStreamProxy
=
sendErrorsToStreamProxy
;
final
IStreamsProxy
2
fSendErrorsToStreamProxy
=
sendErrorsToStreamProxy
;
final
IStreamsProxy
fSendOutputToStreamProxy
=
stdoutStreamProxy
;
final
IStreamsProxy
2
fSendOutputToStreamProxy
=
stdoutStreamProxy
;
// connect input streams of the parsers to the out from the console process
// connect input streams of the parsers to the out from the console process
IStreamMonitor
consoleOutStreamMonitor
=
null
;
IStreamMonitor
consoleOutStreamMonitor
=
null
;
...
@@ -270,9 +275,45 @@ public class VDTConsoleRunner{
...
@@ -270,9 +275,45 @@ public class VDTConsoleRunner{
consoleOutStreamMonitor
.
removeListener
((
IStreamListener
)
outputListener
);
consoleOutStreamMonitor
.
removeListener
((
IStreamListener
)
outputListener
);
}
}
// terminate parser(s). Do those console listeners (parsers) have to be removed too?
// terminate parser(s). Do those console listeners (parsers) have to be removed too?
// TODO: Maybe wait for the process (small time) to terminate by disconnecting it's stdin
// Now end of the parsing may be lost if it did not have enough time to finish.
//IStreamsProxy2.closeInputStream()
// Disconnection worked !!
if
(
stderrStreamProxy
!=
null
){
try
{
stderrStreamProxy
.
closeInputStream
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Failed to disconnect stdin of the processErr parser process"
);
if
(
processErr
!=
null
){
try
{
processErr
.
terminate
();
}
catch
(
DebugException
te
)
{
System
.
out
.
println
(
"Failed to terminate processErr parser process"
);
}
}
}
}
if
(
stdoutStreamProxy
!=
null
){
try
{
stdoutStreamProxy
.
closeInputStream
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Failed to disconnect stdin of the processOut parser process"
);
if
(
processOut
!=
null
){
try
{
processOut
.
terminate
();
}
catch
(
DebugException
te
)
{
System
.
out
.
println
(
"Failed to terminate processOut parser process"
);
}
}
}
}
/*
if (processErr!=null){
if (processErr!=null){
try {
try {
processErr.terminate();
processErr.terminate();
} catch (DebugException e) {
} catch (DebugException e) {
System.out.println("Failed to terminate processErr parser process");
System.out.println("Failed to terminate processErr parser process");
}
}
...
@@ -284,6 +325,7 @@ public class VDTConsoleRunner{
...
@@ -284,6 +325,7 @@ public class VDTConsoleRunner{
System.out.println("Failed to terminate processOut parser process");
System.out.println("Failed to terminate processOut parser process");
}
}
}
}
*/
int
thisStep
=
runConfig
.
getBuildStep
();
int
thisStep
=
runConfig
.
getBuildStep
();
if
(
VerilogPlugin
.
getPreferenceBoolean
(
PreferenceStrings
.
DEBUG_LAUNCHING
))
if
(
VerilogPlugin
.
getPreferenceBoolean
(
PreferenceStrings
.
DEBUG_LAUNCHING
))
System
.
out
.
println
(
"Finished console task, step was "
+
thisStep
);
System
.
out
.
println
(
"Finished console task, step was "
+
thisStep
);
...
...
src/com/elphel/vdt/core/tools/contexts/Context.java
View file @
10b43301
...
@@ -240,7 +240,7 @@ public abstract class Context {
...
@@ -240,7 +240,7 @@ public abstract class Context {
parName
.
getValue
().
get
(
0
).
trim
()
:
null
;
parName
.
getValue
().
get
(
0
).
trim
()
:
null
;
if
(
isConsoleName
)
{
if
(
isConsoleName
)
{
// System.out.println("TODO: Enable console command generation here");
// System.out.println("TODO: Enable console command generation here");
printStringsToConsoleLine
(
commandLineParams
,
commandSequence
,
mark
);
printStringsToConsoleLine
(
commandLineParams
,
commandSequence
,
sep
,
mark
);
buildParamItems
.
add
(
buildParamItems
.
add
(
new
BuildParamsItem
(
new
BuildParamsItem
(
(
String
[])
commandLineParams
.
toArray
(
new
String
[
commandLineParams
.
size
()]),
(
String
[])
commandLineParams
.
toArray
(
new
String
[
commandLineParams
.
size
()]),
...
@@ -458,7 +458,7 @@ public abstract class Context {
...
@@ -458,7 +458,7 @@ public abstract class Context {
if
(
s
.
length
()
==
0
)
if
(
s
.
length
()
==
0
)
continue
;
continue
;
out
.
print
(
useMark
?(
s
.
replace
(
mark
,
""
)):
s
);
out
.
print
(
useMark
?(
CommandLinesBlock
.
parseCntrl
(
s
).
replace
(
mark
,
""
)):
CommandLinesBlock
.
parseCntrl
(
s
)
);
written
+=
s
.
length
();
written
+=
s
.
length
();
writtenNow
+=
s
.
length
();
writtenNow
+=
s
.
length
();
...
@@ -486,31 +486,55 @@ public abstract class Context {
...
@@ -486,31 +486,55 @@ public abstract class Context {
out
.
close
();
out
.
close
();
}
}
private
void
printStringsToCommandLine
(
List
<
String
>
commandLineParams
,
private
void
printStringsToConsoleLine
(
List
<
List
<
String
>>
commandSequence
,
List
<
String
>
commandLineParams
,
String
mark
)
List
<
List
<
String
>>
commandSequence
,
throws
ToolException
String
separator
,
{
String
mark
)
throws
ToolException
{
String
sep
=
(
separator
!=
null
?
separator
:
" "
);
boolean
useMark
=(
mark
!=
null
)
&&
(
mark
.
length
()>
0
);
boolean
useMark
=(
mark
!=
null
)
&&
(
mark
.
length
()>
0
);
for
(
Iterator
<
List
<
String
>>
li
=
commandSequence
.
iterator
();
li
.
hasNext
();)
{
int
written
=
0
;
List
<
String
>
strList
=
(
List
<
String
>)
li
.
next
();
StringBuilder
builder
=
new
StringBuilder
();
for
(
Iterator
<
List
<
String
>>
li
=
commandSequence
.
iterator
();
li
.
hasNext
();)
{
if
(
strList
.
size
()
>
0
)
{
List
<
String
>
strList
=
(
List
<
String
>)
li
.
next
();
for
(
Iterator
<
String
>
si
=
strList
.
iterator
();
si
.
hasNext
();)
{
if
(
strList
.
size
()
>
0
)
{
String
s
=
((
String
)
si
.
next
()).
trim
();
int
writtenNow
=
0
;
if
(!
s
.
equals
(
""
))
for
(
Iterator
<
String
>
si
=
strList
.
iterator
();
si
.
hasNext
();)
{
// "words" in each line
commandLineParams
.
add
(
useMark
?(
s
.
replace
(
mark
,
""
)):
s
);
String
s
=
(
String
)
si
.
next
();
if
(
s
.
length
()
==
0
)
continue
;
builder
.
append
(
useMark
?(
CommandLinesBlock
.
parseCntrl
(
s
).
replace
(
mark
,
""
)):
CommandLinesBlock
.
parseCntrl
(
s
));
written
+=
s
.
length
();
writtenNow
+=
s
.
length
();
// try to avoid needless spaces
if
(
writtenNow
>
0
&&
si
.
hasNext
())
{
// adding spaces between generator "words" ?
String
stripped
=
s
.
replace
(
'\n'
,
' '
).
replace
(
'\t'
,
' '
).
trim
();
if
(
stripped
.
length
()
>
0
)
builder
.
append
(
" "
);
}
}
}
}
if
(
writtenNow
>
0
&&
li
.
hasNext
())
}
builder
.
append
(
sep
);
}
}
// Andrey: now is the same as command line, but will change to allow last element be prompt
}
if
(
written
>
0
)
builder
.
append
(
"\n"
);
commandLineParams
.
add
(
builder
.
toString
());
// just a single line
}
/*
* previous version
private void printStringsToConsoleLine(
private void printStringsToConsoleLine(
List<String> commandLineParams,
List<String> commandLineParams,
List<List<String>> commandSequence,
List<List<String>> commandSequence,
String separator,
String mark) throws ToolException
String mark) throws ToolException
{
{
String sep = (separator != null? separator : " ");
boolean useMark=(mark!=null) && (mark.length()>0);
boolean useMark=(mark!=null) && (mark.length()>0);
for(Iterator<List<String>> li = commandSequence.iterator(); li.hasNext();) {
for(Iterator<List<String>> li = commandSequence.iterator(); li.hasNext();) {
List<String> strList = (List<String>)li.next();
List<String> strList = (List<String>)li.next();
...
@@ -520,11 +544,37 @@ public abstract class Context {
...
@@ -520,11 +544,37 @@ public abstract class Context {
String s = ((String)si.next()).trim();
String s = ((String)si.next()).trim();
if(!s.equals(""))
if(!s.equals(""))
commandLineParams
.
add
(
useMark
?(
s
.
replace
(
mark
,
""
)):
s
);
commandLineParams.add(useMark?
(CommandLinesBlock.parseCntrl(s).replace(mark,"")):
CommandLinesBlock.parseCntrl(s));
}
}
}
}
}
}
}
}
*/
private
void
printStringsToCommandLine
(
List
<
String
>
commandLineParams
,
List
<
List
<
String
>>
commandSequence
,
String
mark
)
throws
ToolException
{
boolean
useMark
=(
mark
!=
null
)
&&
(
mark
.
length
()>
0
);
for
(
Iterator
<
List
<
String
>>
li
=
commandSequence
.
iterator
();
li
.
hasNext
();)
{
List
<
String
>
strList
=
(
List
<
String
>)
li
.
next
();
if
(
strList
.
size
()
>
0
)
{
for
(
Iterator
<
String
>
si
=
strList
.
iterator
();
si
.
hasNext
();)
{
String
s
=
((
String
)
si
.
next
()).
trim
();
if
(!
s
.
equals
(
""
))
commandLineParams
.
add
(
useMark
?
(
CommandLinesBlock
.
parseCntrl
(
s
).
replace
(
mark
,
""
)):
CommandLinesBlock
.
parseCntrl
(
s
));
}
}
}
}
// Andrey: now is the same as command line, but will change to allow last element be prompt
private
void
checkNotInitialized
()
throws
ConfigException
{
private
void
checkNotInitialized
()
throws
ConfigException
{
if
(
initialized
)
if
(
initialized
)
...
...
src/com/elphel/vdt/core/tools/generators/AbstractGenerator.java
View file @
10b43301
...
@@ -57,9 +57,10 @@ public abstract class AbstractGenerator {
...
@@ -57,9 +57,10 @@ public abstract class AbstractGenerator {
this
.
suffix
=
suffix
;
this
.
suffix
=
suffix
;
this
.
forcedMultiline
=
forcedMultiline
;
this
.
forcedMultiline
=
forcedMultiline
;
this
.
separator
=
sep
;
this
.
separator
=
sep
;
if
(
separator
!=
null
)
{
separator
=
separator
.
replace
(
"\\n"
,
"\n"
);
separator
=
separator
.
replace
(
"\\n"
,
"\n"
);
separator
=
separator
.
replace
(
"\\t"
,
"\t"
);
separator
=
separator
.
replace
(
"\\t"
,
"\t"
);
}
}
}
public
void
setMenuMode
(
boolean
menuMode
){
public
void
setMenuMode
(
boolean
menuMode
){
this
.
menuMode
=
menuMode
;
this
.
menuMode
=
menuMode
;
...
@@ -72,6 +73,9 @@ public abstract class AbstractGenerator {
...
@@ -72,6 +73,9 @@ public abstract class AbstractGenerator {
public
abstract
String
getName
();
public
abstract
String
getName
();
public
String
[]
generate
()
{
public
String
[]
generate
()
{
// Andrey: added separator==null option to enable copying list parameter to another list parameter as default
// TODO: Make sure nothing else is broken because of that
if
(
separator
==
null
)
return
getStringValues
();
boolean
multiline
=
Utils
.
stringContainsSpace
(
separator
);
boolean
multiline
=
Utils
.
stringContainsSpace
(
separator
);
String
[]
output
;
String
[]
output
;
...
...
src/com/elphel/vdt/core/tools/params/CommandLinesBlock.java
View file @
10b43301
...
@@ -107,7 +107,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer
...
@@ -107,7 +107,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer
}
}
public
String
parseCntrl
(
String
str
){
public
static
String
parseCntrl
(
String
str
){
if
(
str
==
null
)
return
null
;
if
(
str
==
null
)
return
null
;
str
=
str
.
replace
(
"\\n"
,
"\n"
);
str
=
str
.
replace
(
"\\n"
,
"\n"
);
str
=
str
.
replace
(
"\\t"
,
"\t"
);
str
=
str
.
replace
(
"\\t"
,
"\t"
);
...
...
src/com/elphel/vdt/core/tools/params/Parameter.java
View file @
10b43301
...
@@ -328,7 +328,8 @@ public class Parameter implements Cloneable, Updateable {
...
@@ -328,7 +328,8 @@ public class Parameter implements Cloneable, Updateable {
FormatProcessor
processor
=
new
FormatProcessor
(
new
Recognizer
[]
{
FormatProcessor
processor
=
new
FormatProcessor
(
new
Recognizer
[]
{
//new RepeaterRecognizer(),
//new RepeaterRecognizer(),
new
SimpleGeneratorRecognizer
(
menuMode
),
new
SimpleGeneratorRecognizer
(
menuMode
),
new
ContextParamRecognizer
(
context
)
new
ContextParamListRecognizer
(
context
)
// Andrey: returning list as the source parameter
// new ContextParamRecognizer(context)
});
});
try
{
try
{
...
...
src/com/elphel/vdt/core/tools/params/recognizers/ContextParamListRecognizer.java
0 → 100644
View file @
10b43301
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* 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 2 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package
com
.
elphel
.
vdt
.
core
.
tools
.
params
.
recognizers
;
import
com.elphel.vdt.core.tools.params.Parameter
;
import
com.elphel.vdt.core.tools.params.ToolException
;
import
com.elphel.vdt.core.tools.contexts.Context
;
import
com.elphel.vdt.core.tools.generators.AbstractGenerator
;
import
com.elphel.vdt.core.tools.generators.ValueGenerator
;
public
class
ContextParamListRecognizer
extends
ParamRecognizer
{
private
Context
context
;
public
ContextParamListRecognizer
(
Context
context
)
{
this
.
context
=
context
;
}
protected
Parameter
findParam
(
String
paramID
)
{
return
context
.
findParam
(
paramID
);
}
protected
AbstractGenerator
getGenerator
(
Parameter
param
)
throws
ToolException
{
return
new
ValueGenerator
(
param
,
""
,
""
,
null
);
// will return list value of the parameter
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment