Re: [webmin-devel] adding a "please wait" popup while executing time consuming commands
marty leisner <[email protected]> Fri, 6 Jun 2014 11:17:11 -0400
| Newsgroups | gmane.comp.web.webmin.devel |
|---|---|
| Message-ID | <CAPNO-hZzzsFKcgkUfm8V3ANs3tMgoQYz+MpcX3g6ozhrNwk=+A@mail.gmail.com> |
--===============5787486405172094320==
Content-Type: multipart/alternative; boundary=001a11346f6a6bcbf804fb2c5d98
--001a11346f6a6bcbf804fb2c5d98
Content-Type: text/plain; charset=UTF-8
I still can't get the behavior I want where I print some text as soon as
possible and then wait.
Here's the relevant parg of a test .cgi:
$start=qx(date);
ui_print_unbuffered_header('Changing communication mode');
$|=1;
print "started at $start\n<BR>";
my $type_ethernet=$in{'type_ethernet'};
my $type_wifi=$in{'type_wifi'};
set_wifi($type_wifi);
set_ethernet($type_ethernet);
$end=qx(date);
print "ends at $end\n<BR>";
#print '<meta http-equiv="refresh" content="0;URL=index.cgi">';
footer();
The behavior of the "meta refresh" is what I want (at the end of the
script, go to another page)
But everything seems to print at once: (with and without the $|=1 trick)
Changing communication mode
started at Wed Jun 4 03:36:49 UTC 2014
ssh stop/waiting ssh start/running, process 20496 ends at Wed Jun 4
03:36:56 UTC 2014
(there should be about a 7 second visual delay between the started and
ends, the data is transmitted instantenously).
I want the data to be transmitted when I write it.
I've done lots of playing with this simple example wihtout different
results (seems the output is being buffered).
I have webmin being redirected through the SSL of nginx (though I can't
imagine that would be a problem)
marty
On Fri, May 23, 2014 at 4:48 PM, Jamie Cameron <[email protected]> wrote:
> You can't use the redirect function, as that can only be called if header
> isn't. You should instead output some JS like :
>
> <script>
> window.location = "/module./page.cgi";
> </script>
>
> On 23/May/2014 07:15 marty leisner <[email protected]> wrote ..
>
>
> Thanks -- its ui_print_unbuffered_header.
>
> But after the page is displayed, I want to force a redirect to another
> page -- how would I do it
>
> Something like:
> &ui_print_unbuffered_header('please wait');
> system('date');
> print "<BR>\n";
> sleep(5);
> system('date');
> print "<BR>first line\n<BR>";
> sleep(5);
> system('date');
> print "<BR>second line\n<BR>";
>
> footer();
>
> # redirect('index.cgi');
>
> marty
>
>
> On Wed, May 21, 2014 at 1:47 PM, Jamie Cameron <[email protected]
> <http://reply_mail.cgi?new=1&to=jcameron%40webmin%2Ecom>> wrote:
>
>> Try using un_print_unbuffered_header instead of ui_print_header
>>
>> On 20/May/2014 21:20 marty leisner <[email protected]
>> <http://reply_mail.cgi?new=1&to=maleisner%40gmail%2Ecom>> wrote ..
>>
>> I'm having a problem where my page is delivered on the network at the
>> same time -- after the delay (I used wireshark to
>> monitor this)
>>
>> What I want tried is:
>>
>> ui_print_header('please wait');
>> footer();
>> sleep(5);
>> print "final\n<BR>";
>>
>> I would have expected to see the header render, a delay, and "final".
>>
>> Its all happening after the delay.
>>
>> What I really want to do is:
>>
>> display "please wait"
>> run a long command
>> redirect to another page (after the command runs)
>>
>> marty
>>
>>
>> On Tue, May 20, 2014 at 4:19 PM, Jamie Cameron <[email protected]
>> <http://reply_mail.cgi?new=1&to=jcameron%40webmin%2Ecom>> wrote:
>>
>>> On 20/May/2014 09:27 marty leisner <[email protected]
>>> <http://reply_mail.cgi?new=1&to=maleisner%40gmail%2Ecom>> wrote ..
>>> > When having a custom module in webmin execute time consuming
>>> commands, how
>>> > would I add a
>>> > "please wait" message until the command is finished (without user
>>> > interaction).
>>> >
>>> > I.e.:
>>> >
>>> > start_please_wait();
>>> > system("long_command");
>>> > stop_please_wait();
>>>
>>> In some modules, I've had Webmin print out a series of dots (one per
>>> second)
>>> while performing some long operation. The code is like :
>>>
>>> print "Doing something slow ..";
>>> launch_slow_op_in_background();
>>> while(!done_slow_op()) {
>>> sleep(1);
>>> print ".";
>>> }
>>> print "<br>\n";
>>> print ".. done<p>\n";
>>>
>>> - Jamie
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
>>> Instantly run your Selenium tests across 300+ browser/OS combos.
>>> Get unparalleled scalability from the best Selenium testing platform
>>> available
>>> Simple to use. Nothing to install. Get started now for free."
>>> http://p.sf.net/sfu/SauceLabs
>>> -
>>> Forwarded by the Webmin development list at [email protected]
>>> <http://reply_mail.cgi?new=1&to=webmin%2Ddevel%40webmin%2Ecom>
>>> To remove yourself from this list, go to
>>> http://lists.sourceforge.net/lists/listinfo/webadmin-devel
>>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
>> Instantly run your Selenium tests across 300+ browser/OS combos.
>> Get unparalleled scalability from the best Selenium testing platform
>> available
>> Simple to use. Nothing to install. Get started now for free."
>> http://p.sf.net/sfu/SauceLabs
>> -
>> Forwarded by the Webmin development list at [email protected]
>> <http://reply_mail.cgi?new=1&to=webmin%2Ddevel%40webmin%2Ecom>
>> To remove yourself from this list, go to
>> http://lists.sourceforge.net/lists/listinfo/webadmin-devel
>>
>>
>
>
>
> ------------------------------------------------------------------------------
> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
> Instantly run your Selenium tests across 300+ browser/OS combos.
> Get unparalleled scalability from the best Selenium testing platform
> available
> Simple to use. Nothing to install. Get started now for free."
> http://p.sf.net/sfu/SauceLabs
> -
> Forwarded by the Webmin development list at [email protected]
> To remove yourself from this list, go to
> http://lists.sourceforge.net/lists/listinfo/webadmin-devel
>
>
--001a11346f6a6bcbf804fb2c5d98
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div>I still can't get the behavior I want where I=
print some text as soon as possible and then wait.</div><div><br></div><di=
v>Here's the relevant parg of a=C2=A0 test .cgi:</div><div><br></div><d=
iv style=3D"margin-left:40px">
<span style=3D"font-family:courier new,monospace">$start=3Dqx(date);<br><br=
>
ui_print_unbuffered_header('</span><span style=3D"font-family:courier n=
ew,monospace">Changing communication mode');<br>$|=3D1;<br>print "=
started at $start\n<BR>";<br><br>my $type_ethernet=3D$in{'ty=
pe_</span><span style=3D"font-family:courier new,monospace">ethernet'};=
<br>
<br>my $type_wifi=3D$in{'type_wifi'};<br></span>
<span style=3D"font-family:courier new,monospace"><br>set_wifi($type_wifi);=
<br>set_ethernet($type_ethernet);<br><br>$end=3Dqx(date);</span></div><div =
style=3D"margin-left:40px"><span style=3D"font-family:courier new,monospace=
"><br>
</span></div><div style=3D"margin-left:40px"><span style=3D"font-family:cou=
rier new,monospace"> print "ends at $end\n<BR>";<br><br>#pr=
int '<meta http-equiv=3D"refresh" content=3D"0;URL=3D=
index.cgi">';<br>
footer();<br></span></div><div><br></div><div>The behavior of the "met=
a refresh" is what I want (at the end of the script, go to another pag=
e)</div><div><br></div><div>But everything seems to print at once:=C2=A0 (w=
ith and without the $|=3D1 trick)<br>
</div><div><br>
</div><div style=3D"margin-left:40px"><span style=3D"font-family:courier ne=
w,monospace">Changing communication mode<br> started at Wed Jun 4 03:36:49 =
UTC 2014 <br>ssh stop/waiting ssh start/running, process 20496 ends at Wed =
Jun 4 03:36:56 UTC 2014</span></div>
<div><br></div><div>(there should be about a 7 second visual delay between =
the started and ends, the data is transmitted instantenously).<br><br></div=
><div>I want the data to be transmitted when I write it.<br><br></div>
<div>
I've done lots of playing with this simple example wihtout different re=
sults (seems the output is being buffered).<br><br></div><div>I have webmin=
being redirected through the SSL of nginx (though I can't imagine that=
would be a problem)<br>
</div><div><br></div><div>marty<br></div>
<div><br></div>
<div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Fri, May 2=
3, 2014 at 4:48 PM, Jamie Cameron <span dir=3D"ltr"><<a href=3D"mailto:j=
[email protected]" target=3D"_blank">[email protected]</a>></span> wr=
ote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><p>You can't use the redirect function, =
as that can only be called if header isn't. You should instead output s=
ome JS like :<br>
<br><script><br>window.location =3D "/module./page.cgi";<br=
></script>=C2=A0</p>
<p>On 23/May/2014 07:15 marty leisner <<a href=3D"mailto:maleisner@gma=
il.com" target=3D"_blank">[email protected]</a>> wrote ..
</p><div><div>
<blockquote type=3D"cite">=20
<div dir=3D"ltr">
<div><br></div>
<div>Thanks -- its ui_print_unbuffered_header.</div>
<div><br></div>
<div>But after the page is displayed, I want to force a redirect to a=
nother page -- how would I do it</div>
<div><br></div>
<div>
Something like:</div>
<div style=3D"margin-left:40px!important">&ui_print_unbuffered_he=
ader('please wait');
<div>system('date');</div>
<div>print "<BR>\n";</div>
<div>sleep(5);</div>
<div>system('date');</div>=20
<div> print "<BR>first line\n<BR>";</div>
<div>sleep(5);</div>
<div>system('date');</div>
<div>print "<BR>second line\n<BR>";</div>
<div><br></div>
<div>footer();</div>
<div> <br> </div>
<div># redirect('index.cgi');<br></div>
</div>
<div style=3D"margin-left:40px!important"><br></div>
<div style=3D"margin-left:0px!important">marty<br></div>
</div>
<div class=3D"gmail_extra"><br><br>
<div class=3D"gmail_quote">
On Wed, May 21, 2014 at 1:47 PM, Jamie Cameron <span dir=3D"ltr"><<a hre=
f=3D"http://reply_mail.cgi?new=3D1&to=3Djcameron%40webmin%2Ecom" target=
=3D"_blank">[email protected]</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex=
;border-left-width:1px;border-left-color:#cccccc;border-left-style:solid;pa=
dding-left:1ex">=20
<p>Try using un_print_unbuffered_header instead of ui_print_heade=
r=C2=A0</p>=20
<p>On 20/May/2014 21:20 marty leisner <<a href=3D"http://reply=
_mail.cgi?new=3D1&to=3Dmaleisner%40gmail%2Ecom" target=3D"_blank">malei=
[email protected]</a>> wrote ..
</p>
<div>
<div>=20
<blockquote type=3D"cite">=20
<div dir=3D"ltr">=20
<div>=20
<div>=20
<div>=20
<div>I'm having a problem where my page is deli=
vered on the network at the same time -- after the delay (I used wireshark =
to <br></div>=20
<div>monitor this)<br></div>=20
<div><br></div>What I want tried is:<br> <br>ui_pri=
nt_header('please wait');<br>=20
</div>=20
<div>footer();<br>sleep(5);<br>print "final\n<=
;BR>";<br><br></div>=20
<div>I would have expected to see the header render, =
a delay, and "final".<br> </div>=20
<div><br></div>=20
<div>Its all happening after the delay.<br><br></div>=
=20
<div>What I really want to do is:<br><br></div>=20
<div>display "please wait"<br></div>=20
<div>run a long command<br></div>=20
<div>redirect to another page (after the command runs=
)<br> <br></div>=20
<div>marty<br></div>=20
</div>=20
</div>=20
</div>=20
<div class=3D"gmail_extra"><br><br>=20
<div class=3D"gmail_quote">On Tue, May 20, 2014 at 4:19 P=
M, Jamie Cameron <span dir=3D"ltr"><<a href=3D"http://reply_mail.cgi?new=
=3D1&to=3Djcameron%40webmin%2Ecom" target=3D"_blank">[email protected]=
m</a>></span> wrote:<br>
=20
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0=
px 0px 0.8ex;border-left-width:1px;border-left-color:#cccccc;border-left-st=
yle:solid;padding-left:1ex">On 20/May/2014 09:27 marty leisner <<a href=
=3D"http://reply_mail.cgi?new=3D1&to=3Dmaleisner%40gmail%2Ecom" target=
=3D"_blank">[email protected]</a>> wrote ..<br>
=20
<div>=20
<div>> When having a custom module in webmin exe=
cute time consuming commands, how<br>
> would I add a<br>
> "please wait" message until the command is finished (without=
user<br>
> interaction).<br>
><br>
> I.e.:<br>
><br>
> start_please_wait();<br>
> system("long_command");<br>
> stop_please_wait();<br> <br> </div>=20
</div>In some modules, I've had Webmin print out =
a series of dots (one per second)<br>
while performing some long operation. The code is like :<br> <br>
print "Doing something slow ..";<br>
launch_slow_op_in_background();<br>
while(!done_slow_op()) {<br>
=C2=A0 sleep(1);<br>
=C2=A0 print ".";<br>
=C2=A0 }<br>
print "<br>\n";<br>
print ".. done<p>\n";<br> <br>
=C2=A0- Jamie<br> <br>
---------------------------------------------------------------------------=
---<br>
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE=
<br>
Instantly run your Selenium tests across 300+ browser/OS combos.<br>
Get unparalleled scalability from the best Selenium testing platform availa=
ble<br>
Simple to use. Nothing to install. Get started now for free."<br> <a h=
ref=3D"http://p.sf.net/sfu/SauceLabs" target=3D"_blank">http://p.sf.net/sfu=
/SauceLabs</a><br>
-<br>
Forwarded by the Webmin development list at <a href=3D"http://reply_mail.cg=
i?new=3D1&to=3Dwebmin%2Ddevel%40webmin%2Ecom" target=3D"_blank">webmin-=
[email protected]</a><br>
To remove yourself from this list, go to<br> <a href=3D"http://lists.source=
forge.net/lists/listinfo/webadmin-devel" target=3D"_blank">http://lists.sou=
rceforge.net/lists/listinfo/webadmin-devel</a><br>=20
</blockquote>=20
</div><br>=20
</div>=20
</blockquote><br>=20
</div>
</div><br>-------------------------------------------------------=
-----------------------<br>
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE=
<br>
Instantly run your Selenium tests across 300+ browser/OS combos.<br>
Get unparalleled scalability from the best Selenium testing platform availa=
ble<br>
Simple to use. Nothing to install. Get started now for free."<br> <a h=
ref=3D"http://p.sf.net/sfu/SauceLabs" target=3D"_blank">http://p.sf.net/sfu=
/SauceLabs</a><br>-<br>
Forwarded by the Webmin development list at <a href=3D"http://reply_mail.cg=
i?new=3D1&to=3Dwebmin%2Ddevel%40webmin%2Ecom" target=3D"_blank">webmin-=
[email protected]</a><br>
To remove yourself from this list, go to<br> <a href=3D"http://lists.source=
forge.net/lists/listinfo/webadmin-devel" target=3D"_blank">http://lists.sou=
rceforge.net/lists/listinfo/webadmin-devel</a><br> <br>
</blockquote>
</div><br>
</div>=20
</blockquote><br>
</div></div><br>-----------------------------------------------------------=
-------------------<br>
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE=
<br>
Instantly run your Selenium tests across 300+ browser/OS combos.<br>
Get unparalleled scalability from the best Selenium testing platform availa=
ble<br>
Simple to use. Nothing to install. Get started now for free."<br>
<a href=3D"http://p.sf.net/sfu/SauceLabs" target=3D"_blank">http://p.sf.net=
/sfu/SauceLabs</a><br>-<br>
Forwarded by the Webmin development list at <a href=3D"mailto:webmin-devel@=
webmin.com" target=3D"_blank">[email protected]</a><br>
To remove yourself from this list, go to<br>
<a href=3D"http://lists.sourceforge.net/lists/listinfo/webadmin-devel" targ=
et=3D"_blank">http://lists.sourceforge.net/lists/listinfo/webadmin-devel</a=
><br>
<br></blockquote></div><br></div></div>
--001a11346f6a6bcbf804fb2c5d98--
--===============5787486405172094320==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
--===============5787486405172094320==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
-
Forwarded by the Webmin development list at [email protected]
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel
--===============5787486405172094320==--