Commit 88ef17c4 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Flyspray #120: Fix several problems that were causing log output from

various template operations to get lost. Also fixed the code in
mungelog.js that was supposed to handle bailing out if there was no
response from the server in a reasonable amount of time; if that code
had been working, no one would have even noticed all the other problems!

Also some cleanup in parts of mungelog.js and showlogfile_sup.php3;
slowly migrating parts of this to emulab_sup.js since we use some of
the same code in other places.
parent 48984321
...@@ -408,8 +408,6 @@ if (! ($debug || $foreground)) { ...@@ -408,8 +408,6 @@ if (! ($debug || $foreground)) {
TBdbfork(); TBdbfork();
} }
sleep(60);
# #
# When in waitmode, must put ourselves in another process group so that # When in waitmode, must put ourselves in another process group so that
# an interrupt to the parent will not have any effect on the backend. # an interrupt to the parent will not have any effect on the backend.
......
...@@ -444,6 +444,9 @@ sub ParseArgs() ...@@ -444,6 +444,9 @@ sub ParseArgs()
if (defined($options{"w"})) { if (defined($options{"w"})) {
$waitmode = 1; $waitmode = 1;
} }
if (defined($options{"f"})) {
$foreground = 1;
}
} }
# #
......
...@@ -59,12 +59,10 @@ function GraphChange(which) { ...@@ -59,12 +59,10 @@ function GraphChange(which) {
return false; return false;
} }
function SetupOutputArea(id) { function GetMaxHeight(id) {
var Iframe = document.getElementById(id); var Iframe = document.getElementById(id);
var IframeDoc = IframeDocument(id);
var winheight = 0; var winheight = 0;
var yoff = 0; var yoff = 0;
// This tells us the total height of the browser window. // This tells us the total height of the browser window.
if (window.innerHeight) // all except Explorer if (window.innerHeight) // all except Explorer
...@@ -80,19 +78,79 @@ function SetupOutputArea(id) { ...@@ -80,19 +78,79 @@ function SetupOutputArea(id) {
// Now get the Y offset of the outputframe. // Now get the Y offset of the outputframe.
yoff = Iframe.offsetTop; yoff = Iframe.offsetTop;
if (winheight != 0) {
// Now calculate how much room is left and make the iframe
// big enough to use most of the rest of the window.
if (yoff != 0)
winheight = winheight - (yoff + 175);
else
winheight = winheight * 0.7;
}
return winheight;
}
function SetupOutputArea(id) {
var Iframe = document.getElementById(id);
var IframeDoc = IframeDocument(id);
var winheight = GetMaxHeight(id);
IframeDoc.open(); IframeDoc.open();
IframeDoc.write('<html><head><base href=$BASEPATH/></head><body><pre id=outputarea></pre></body></html>'); IframeDoc.write('<html><head><base href=$BASEPATH/></head><body><pre id=outputarea></pre></body></html>');
IframeDoc.close(); IframeDoc.close();
if (winheight != 0) Iframe.style.border = "2px solid";
Iframe.height = winheight;
Iframe.width = "100%";
Iframe.scrolling = "auto";
Iframe.frameBorder = "1";
}
function HideFrame(id) {
var Iframe = document.getElementById(id);
var IframeDoc = IframeDocument(id);
Iframe.style.border = "0px none";
Iframe.frameBorder = 0;
Iframe.height = 0;
Iframe.width = 0;
Iframe.scrolling = "no";
}
function ShowDownLoader(id) {
var Iframe = document.getElementById(id);
var IframeDoc = IframeDocument(id);
var winheight = 0;
var yoff = 0;
// This tells us the total height of the browser window.
if (window.innerHeight) // all except Explorer
winheight = window.innerHeight;
else if (document.documentElement &&
document.documentElement.clientHeight)
// Explorer 6 Strict Mode
winheight = document.documentElement.clientHeight;
else if (document.body)
// other Explorers
winheight = document.body.clientHeight;
// Now get the Y offset of the outputframe.
yoff = Iframe.offsetTop;
if (winheight != 0) {
// Now calculate how much room is left and make the iframe // Now calculate how much room is left and make the iframe
// big enough to use most of the rest of the window. // big enough to use most of the rest of the window.
if (yoff != 0) if (yoff != 0)
winheight = winheight - (yoff + 175); winheight = winheight - (yoff + 175);
else else
winheight = winheight * 0.7; winheight = winheight * 0.7;
}
Iframe.height = winheight;
Iframe.style.border = "2px solid";
Iframe.height = winheight;
Iframe.width = "100%";
Iframe.scrolling = "auto";
Iframe.frameBorder = "1";
} }
/* @return The innerHeight of the window. */ /* @return The innerHeight of the window. */
......
...@@ -1114,7 +1114,6 @@ function STARTBUSY($msg) { ...@@ -1114,7 +1114,6 @@ function STARTBUSY($msg) {
echo "<center>\n"; echo "<center>\n";
echo "<b>$msg</b> ...<br>\n"; echo "<b>$msg</b> ...<br>\n";
echo "This will take a few moments; please be <em>patient</em>.<br>\n"; echo "This will take a few moments; please be <em>patient</em>.<br>\n";
echo "<br>\n";
echo "<img id='busy' src='busy.gif'>". echo "<img id='busy' src='busy.gif'>".
"<span id='loading'> Working ...</span>"; "<span id='loading'> Working ...</span>";
echo "<br><br>\n"; echo "<br><br>\n";
......
...@@ -19,7 +19,7 @@ var lastLine = ""; // The last line of the download text. ...@@ -19,7 +19,7 @@ var lastLine = ""; // The last line of the download text.
var getPNodeProgress = 0; var getPNodeProgress = 0;
var nextState = LOG_STATE_LOADING; // The state of the log download. var nextState = LOG_STATE_LOADING; // The state of the log download.
var docTriesLeft = 2; // Tries before giving up on getting the document. var docTriesLeft = 5; // Tries before giving up on getting the document.
var lastError = -2; var lastError = -2;
var maxLineLength = 110; var maxLineLength = 110;
...@@ -44,10 +44,15 @@ function GetPNodes_cb(data) { ...@@ -44,10 +44,15 @@ function GetPNodes_cb(data) {
} }
/* Clear the various 'loading' indicators. */ /* Clear the various 'loading' indicators. */
function ml_loadFinished() { function ml_loadFinished(done) {
clearInterval(upInterval); clearInterval(upInterval);
ClearLoadingIndicators("<center><b>Done!</b></center>"); if (done) {
ClearLoadingIndicators("<center><b>Done!</b></center>");
}
else {
ClearLoadingIndicators(" ");
}
nextState = LOG_STATE_LOADED; nextState = LOG_STATE_LOADED;
} }
...@@ -166,6 +171,11 @@ function ml_handleReadyState(state) { ...@@ -166,6 +171,11 @@ function ml_handleReadyState(state) {
var oa = idoc.getElementById('outputarea'); var oa = idoc.getElementById('outputarea');
var dl = document.getElementById('downloader'); var dl = document.getElementById('downloader');
if (docTriesLeft < 0) {
/* Already decided we were broken; just ignore */
return;
}
if ((rt = ml_getBodyText(dl)) == null) { if ((rt = ml_getBodyText(dl)) == null) {
/* /*
* Browsers that do not support DOMs for text/plain files or are a * Browsers that do not support DOMs for text/plain files or are a
...@@ -175,25 +185,26 @@ function ml_handleReadyState(state) { ...@@ -175,25 +185,26 @@ function ml_handleReadyState(state) {
*/ */
docTriesLeft -= 1; docTriesLeft -= 1;
if (docTriesLeft < 0) { if (docTriesLeft < 0) {
/* Give up, turn off the spinner and */ /* Give up, turn off the spinner */
ml_loadFinished(); ml_loadFinished(0);
/* ... try to make the iframe visible. */ /* Hide the outputarea */
dl.border = 1; HideFrame("outputframe");
dl.width = "90%";
dl.height = 500;
dl.style.width = "90%";
dl.style.height = 500;
dl.style.border = 1;
}
/* Make the downloader frame visible. */
var winheight = GetMaxHeight('downloader');
dl.style.border = "2px solid";
dl.height = winheight;
dl.width = "100%";
dl.scrolling = "auto";
dl.frameBorder = "1";
}
return; return;
} }
if (state == LOG_STATE_LOADED) { if (state == LOG_STATE_LOADED) {
ml_loadFinished(); ml_loadFinished(1);
} }
if (state == LOG_STATE_LOADING || state == LOG_STATE_LOADED) { if (state == LOG_STATE_LOADING || state == LOG_STATE_LOADED) {
......
...@@ -93,43 +93,6 @@ function STARTLOG($pid, $eid) ...@@ -93,43 +93,6 @@ function STARTLOG($pid, $eid)
global $BASEPATH; global $BASEPATH;
STARTWATCHER($pid, $eid); STARTWATCHER($pid, $eid);
echo "<script type='text/javascript' language='javascript'>\n";
echo "function SetupOutputArea() {
var Iframe = document.getElementById('outputframe');
var IframeDoc = IframeDocument('outputframe');
var winheight = 0;
var yoff = 0;
// This tells us the total height of the browser window.
if (window.innerHeight) // all except Explorer
winheight = window.innerHeight;
else if (document.documentElement &&
document.documentElement.clientHeight)
// Explorer 6 Strict Mode
winheight = document.documentElement.clientHeight;
else if (document.body)
// other Explorers
winheight = document.body.clientHeight;
// Now get the Y offset of the outputframe.
yoff = Iframe.offsetTop;
IframeDoc.open();
IframeDoc.write('<html><head><base href=$BASEPATH/></head><body><pre id=outputarea></pre></body></html>');
IframeDoc.close();
if (winheight != 0)
// Now calculate how much room is left and make the iframe
// big enough to use most of the rest of the window.
if (yoff != 0)
winheight = winheight - (yoff + 175);
else
winheight = winheight * 0.7;
Iframe.height = winheight;
}
</script>\n";
echo "<center>\n"; echo "<center>\n";
echo "<img id='busy' src='busy.gif'> echo "<img id='busy' src='busy.gif'>
...@@ -147,16 +110,16 @@ function STARTLOG($pid, $eid) ...@@ -147,16 +110,16 @@ function STARTLOG($pid, $eid)
</script>\n"; </script>\n";
echo "<script type='text/javascript' language='javascript'>\n"; echo "<script type='text/javascript' language='javascript'>\n";
echo "SetupOutputArea();\n"; echo "SetupOutputArea('outputframe');\n";
echo "exp_pid = \"$pid\";\n"; echo "exp_pid = \"$pid\";\n";
echo "exp_eid = \"$eid\";\n"; echo "exp_eid = \"$eid\";\n";
echo "</script> echo "</script><div>
<iframe id='downloader' name='downloader' width=0 height=0 <iframe id='downloader' name='downloader' width=0 height=0
src='spewlogfile.php3?pid=$pid&eid=$eid' src='spewlogfile.php3?pid=$pid&eid=$eid'
onload='ml_handleReadyState(LOG_STATE_LOADED);' onload='ml_handleReadyState(LOG_STATE_LOADED);'
border=0 style='width:0px; height:0px; border: 0px'> border=0 frameborder=0>
</iframe>\n"; </iframe></div>\n";
} }
# See if this request is to one of the above functions. Does not return # See if this request is to one of the above functions. Does not return
......
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