Fix database upgrade.

This commit is contained in:
Alexandre Rosenfeld
2011-01-10 14:14:31 +00:00
parent 90b829136b
commit 608932d8ff
3 changed files with 83 additions and 38 deletions

View File

@@ -71,6 +71,52 @@ function logging($message, $filename = NULL) {
}
}
function progress($done, $total, $size=30) {
static $start_time;
// if we go over our bound, just ignore it
if($done > $total) return;
if(empty($start_time)) $start_time=time();
$now = time();
$perc=(double)($done/$total);
$bar=floor($perc*$size);
$status_bar="\r[";
$status_bar.=str_repeat("=", $bar);
if($bar<$size){
$status_bar.=">";
$status_bar.=str_repeat(" ", $size-$bar);
} else {
$status_bar.="=";
}
$disp=number_format($perc*100, 0);
$status_bar.="] $disp% $done/$total";
$rate = ($now-$start_time)/$done;
$left = $total - $done;
$eta = round($rate * $left, 2);
$elapsed = $now - $start_time;
$status_bar.= " remaining: ".number_format($eta)." sec. elapsed: ".number_format($elapsed)." sec.";
echo "$status_bar ";
flush();
// when done, send a newline
if($done == $total) {
echo "\n";
}
}
function get_workspaces_from_args($args, $includeAll = true) {
$opts = parse_args($args);
$workspaces = array();