Author: ug
Date: Wed Jul 18 14:03:44 2007
New Revision: 39497
URL: http://svn.opensuse.org/viewcvs/yast?rev=39497&view=rev
Log:
bidirectional feedback during script execution (currently inactive)
Modified:
trunk/autoinstallation/src/modules/AutoinstScripts.ycp
Modified: trunk/autoinstallation/src/modules/AutoinstScripts.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/autoinstallation/src/modules/AutoinstScripts.ycp?rev=39497&r1=39496&r2=39497&view=diff
==============================================================================
--- trunk/autoinstallation/src/modules/AutoinstScripts.ycp (original)
+++ trunk/autoinstallation/src/modules/AutoinstScripts.ycp Wed Jul 18 14:03:44 2007
@@ -575,3 +575,133 @@
// EOF
}
+
+/*
+bidirectional feedback during script execution
+Experimental
+
+{
+ import "UI";
+ import "Label";
+ textdomain "autoinst";
+
+ define map splitParams( string s ) ``{
+ list<string> l = splitstring( s, ":" );
+ map ret = $[];
+ l = remove( l, 0 );
+ y2milestone("XXX %1",l);
+ foreach( string element, l, ``{
+ list<string> p = splitstring( element, "=" );
+ ret[ p[0]:"" ] = p[1]:"";
+ });
+ y2milestone("UWE %1",ret);
+ return ret;
+ }
+
+ define void go () ``{
+ map data = $[];
+ string widget = "";
+ SCR::Execute(.target.bash, "mkfifo -m 660 /tmp/ay_opipe", $[]);
+ SCR::Execute(.target.bash, "mkfifo -m 660 /tmp/ay_ipipe", $[]);
+ SCR::Execute(.target.bash_background, "OPIPE=/tmp/ay_opipe IPIPE=/tmp/ay_ipipe /tmp/test.sh", $[]);
+ boolean run = true;
+ list<string> buffer = [];
+ while( SCR::Read(.target.lstat, "/tmp/ay_opipe") != $[] && run ) {
+ data = (map)SCR::Execute (.target.bash_output, "cat /tmp/ay_opipe", $[]);
+ y2milestone("read: %1",data);
+ buffer = splitstring( data["stdout"]:"", "\n" );
+ while( buffer != [] ) {
+ string line = buffer[0]:"";
+ buffer = remove( buffer, 0 );
+ if( size(line) == 0 )
+ continue;
+ data["stdout"] = line;
+ y2milestone("working on line %1",line);
+ if( substring( data["stdout"]:"", 0, 12 ) == "__PROGRESS__" ) {
+ map params = splitParams( data["stdout"]:"" );
+ if( widget != "" )
+ UI::CloseDialog();
+ UI::OpenDialog(
+ `VBox( `ProgressBar(`id(`pr), params["label"]:"", tointeger(params["max"]:"100"), 0 ) )
+ );
+ widget = "progressbar";
+ } else if( substring( data["stdout"]:"", 0, 8 ) == "__TEXT__" ) {
+ map params = splitParams( data["stdout"]:"" );
+ integer hspace = tointeger(params["width"]:"10");
+ integer vspace = tointeger(params["height"]:"20");
+ if( widget != "" )
+ UI::CloseDialog();
+ UI::OpenDialog(
+ `VBox( `HSpacing(hspace), `HBox( `VSpacing(vspace), `MultiLineEdit( `id( `mle ), "label", "" ) ) ) );
+ widget = "text";
+ } else if( substring( data["stdout"]:"", 0, 9 ) == "__ENTRY__" ) {
+ map params = splitParams( data["stdout"]:"" );
+ UI::OpenDialog(
+ `VBox( `TextEntry( `id(`ay_entry), params["label"]:"", params["default"]:"" ), `PushButton(`id(`ok), Label::OKButton() ) )
+ );
+ any ret = UI::UserInput();
+ any val = UI::QueryWidget(`id(`ay_entry), `Value);
+ SCR::Execute (.target.bash, sformat("echo \"%1\" > /tmp/ay_ipipe", (string)(val) ), $[]);
+ UI::CloseDialog();
+ } else if( substring( data["stdout"]:"", 0, 15 ) == "__RADIOBUTTON__" ) {
+ boolean run2 = true;
+ term vbox = `VBox();
+ if( widget != "" )
+ UI::CloseDialog();
+ widget = "radiobutton";
+ while( SCR::Read(.target.lstat, "/tmp/ay_opipe") != $[] && run2 == true ) {
+ if( buffer == [] ) {
+ data = (map)SCR::Execute (.target.bash_output, "cat /tmp/ay_opipe", $[]);
+ buffer = splitstring( data["stdout"]:"", "\n" );
+ }
+ integer idCnt = 0;
+ while( buffer != [] ) {
+ string line = buffer[0]:"";
+ buffer = remove( buffer, 0 );
+ y2milestone("working on line: %1",line);
+ if( size(line) == 0 )
+ continue;
+ data["stdout"] = line;
+ if( substring( data["stdout"]:"", 0, 10 ) == "__BUTTON__" ) {
+ map params = splitParams( data["stdout"]:"" );
+ vbox = add( vbox, `Left(`RadioButton(`id(params["val"]:""), params["label"]:"")) );
+ idCnt = idCnt + 1;
+ } else if( substring( data["stdout"]:"", 0, 8 ) == "__EXIT__" ) {
+ run2 = false;
+ vbox = add( vbox, `PushButton(`id(`ok), Label::OKButton() ) );
+ } else {
+ y2milestone("bad thing happened. Neither 'BUTTON' nor 'EXIT' found in 'RADIOBUTTON' : %1",data["stdout"]:"");
+ }
+ };
+ }
+ UI::OpenDialog(
+ `RadioButtonGroup(`id(`rb),
+ vbox
+ )
+ );
+ any ret = UI::UserInput();
+ any val = UI::QueryWidget(`id(`rb), `CurrentButton);
+ SCR::Execute (.target.bash, sformat("echo \"%1\" > /tmp/ay_ipipe", val ), $[]);
+ UI::CloseDialog();
+ } else if( substring( data["stdout"]:"", 0, 8 ) == "__EXIT__" ) {
+ run = false;
+ } else {
+ if( widget == "progressbar" ) {
+ UI::ChangeWidget(`id(`pr), `Value, tointeger(data["stdout"]:"0") );
+ } else if( widget == "text" ) {
+ UI::ChangeWidget(`id(`mle), `Value, (string)UI::QueryWidget(`id(`mle), `Value)+data["stdout"]:""+"\n" );
+ }
+ }
+ };
+ };
+ SCR::Execute (.target.remove, "/tmp/ay_opipe");
+ SCR::Execute (.target.remove, "/tmp/ay_ipipe");
+ }
+ go();
+ UI::CloseDialog();
+}
+
+
+
+
+*/
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org