Exemple #1
0
function handle_result($resultid)
{
    $r = BoincResult::lookup_id($resultid);
    $w = BoincWorkunit::lookup_id($r->workunitid);
    $rs = BoincResult::enum("workunitid={$r->workunitid} and validate_state=1");
    $app_version_ids = array();
    foreach ($rs as $r) {
        show_result($r, $w);
        $app_version_ids[] = $r->app_version_id;
    }
    $app_version_ids = array_unique($app_version_ids);
    foreach ($app_version_ids as $avid) {
        show_av($avid);
    }
}
Exemple #2
0
function boinc_preprocess_views_view(&$vars, $hook)
{
    switch ($vars['name']) {
        case 'boinc_account_computers':
            switch ($vars['display_id']) {
                case 'page_1':
                case 'panel_pane_1':
                    $vars['empty'] = boincwork_views_host_list_empty_text();
                    break;
                case 'page_2':
                    $vars['empty'] = boincwork_views_host_list_empty_text('active');
                    break;
                case 'block_1':
                    $vars['empty'] = boincwork_views_host_list_empty_text('preferences');
                    break;
                default:
            }
            break;
        case 'boinc_account_tasks_all':
            $vars['empty'] = boincwork_views_task_list_empty_text();
            break;
        case 'boinc_friends':
            if ($vars['display_id'] == 'block_1') {
                $vars['header'] = boincuser_views_friends_block_header();
            }
            break;
        case 'boinc_host_list':
            if ($vars['display_id'] == 'page_2') {
                $vars['empty'] = boincwork_views_host_list_empty_text();
            } elseif ($vars['display_id'] == 'page_1') {
                $vars['empty'] = boincwork_views_host_list_empty_text('active');
            }
            break;
        case 'boinc_task':
            // Load view object (view data is not available in header / footer); execute view query
            $view = views_get_current_view();
            $view->execute();
            $result = reset($view->result);
            // Display the stderr output in the footer
            $vars['footer'] = '<h3>' . bts('Stderr output') . '</h3>';
            $vars['footer'] .= '<pre>' . htmlspecialchars($result->result_stderr_out) . '</pre>';
            break;
        case 'boinc_teams':
            if ($vars['display_id'] == 'panel_pane_3') {
                $team_id = arg(2);
                $vars['header'] = boincteam_manage_admins_panel_header($team_id);
            }
            break;
        case 'boinc_workunit':
            ob_start();
            // Get the workunit ID from the URL
            $result_id = arg(1);
            require_boinc(array('util', 'boinc_db'));
            $wu = BoincWorkunit::lookup_id($result_id);
            project_workunit($wu);
            // Output of project_workunit() gets caught in the buffer
            $vars['footer'] = ob_get_clean();
        default:
    }
}
Exemple #3
0
function get_wu_output_files($wu_id, $auth_str)
{
    $wu = BoincWorkunit::lookup_id($wu_id);
    if (!$wu) {
        die("no workunit {$wu_id}");
    }
    $batch = BoincBatch::lookup_id($wu->batch);
    if (!$batch) {
        die("no batch {$wu->batch}");
    }
    $user = BoincUser::lookup_id($batch->user_id);
    if (!$user) {
        die("no user {$batch->user_id}");
    }
    $x = md5($user->authenticator . $wu_id);
    echo "user authenticator= {$user->authenticator}, wu_id={$wu_id}<br/>";
    if ($x != $auth_str) {
        die("bad auth str: x={$x}, auth_str={$auth_str}");
    }
    $zip_basename = tempnam("/tmp", "boinc_wu_" . $wu->name . "_");
    $zip_filename = $zip_basename . ".zip";
    $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
    $upload_dir = parse_config(get_config(), "<upload_dir>");
    if (!$wu->canonical_resultid) {
        die("no canonical result for wu {$wu->name}");
    }
    $result = BoincResult::lookup_id($wu->canonical_resultid);
    $names = get_outfile_names($result);
    foreach ($names as $name) {
        $path = dir_hier_path($name, $upload_dir, $fanout);
        if (is_file($path)) {
            system("nice -9 zip -jq {$zip_basename} {$path}");
        }
    }
    do_download($zip_filename);
    unlink($zip_filename);
    unlink($zip_basename);
}
Exemple #4
0
function query_job($r)
{
    xml_start_tag("query_job");
    list($user, $user_submit) = authenticate_user($r, null);
    $job_id = (int) $r->job_id;
    $wu = BoincWorkunit::lookup_id($job_id);
    if (!$wu) {
        xml_error(-1, "no such job");
    }
    $batch = BoincBatch::lookup_id($wu->batch);
    if ($batch->user_id != $user->id) {
        xml_error(-1, "not owner");
    }
    $results = BoincResult::enum("workunitid={$job_id}");
    foreach ($results as $result) {
        echo "    <instance>\n        <name>{$result->name}</name>\n        <id>{$result->id}</id>\n        <state>" . state_string($result) . "</state>\n";
        if ($result->server_state == 5) {
            // over?
            $paths = get_outfile_paths($result);
            foreach ($paths as $path) {
                if (is_file($path)) {
                    $size = filesize($path);
                    echo "        <outfile>\n            <size>{$size}</size>\n        </outfile>\n";
                }
            }
        }
        echo "</instance>\n";
    }
    echo "</query_job>\n";
}
Exemple #5
0
function handle_query_job($user)
{
    $wuid = get_int('wuid');
    $wu = BoincWorkunit::lookup_id($wuid);
    if (!$wu) {
        error_page("no such job");
    }
    page_head("Job {$wuid}");
    echo "\n        <a href=workunit.php?wuid={$wuid}>Workunit details</a> &middot;\n        <a href=submit.php?action=query_batch&batch_id={$wu->batch}>Batch {$wu->batch}</a>\n    ";
    // show input files
    //
    echo "<h2>Input files</h2>\n";
    $x = "<in>" . $wu->xml_doc . "</in>";
    $x = simplexml_load_string($x);
    start_table();
    table_header("Logical name<br><p class=\"text-muted\">(click to view)</p>", "Size (bytes)", "MD5");
    foreach ($x->workunit->file_ref as $fr) {
        $pname = (string) $fr->file_name;
        $lname = (string) $fr->open_name;
        foreach ($x->file_info as $fi) {
            if ((string) $fi->name == $pname) {
                table_row("<a href={$fi->url}>{$lname}</a>", $fi->nbytes, $fi->md5_cksum);
                break;
            }
        }
    }
    end_table();
    echo "<h2>Instances</h2>\n";
    start_table();
    table_header("Instance ID<br><p class=\"text-muted\">click for result page</p>", "State", "Output files<br><p class=\"text-muted\">click to view the file</p>");
    $results = BoincResult::enum("workunitid={$wuid}");
    $upload_dir = parse_config(get_config(), "<upload_dir>");
    $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
    foreach ($results as $result) {
        echo "<tr>\n            <td><a href=result.php?resultid={$result->id}>{$result->id} &middot; {$result->name} </a></td>\n            <td>" . state_string($result) . "</td>\n            <td>\n";
        $i = 0;
        if ($result->server_state == 5) {
            $names = get_outfile_names($result);
            $i = 0;
            foreach ($names as $name) {
                $url = boinc_get_output_file_url($user, $result, $i++);
                $path = dir_hier_path($name, $upload_dir, $fanout);
                $s = stat($path);
                $size = $s['size'];
                echo "<a href={$url}>{$name} </a> (" . number_format($size) . " bytes)<br/>";
            }
            $i++;
        }
        echo "</td></tr>\n";
    }
    end_table();
    echo "<p><a href=submit.php>Return to job control page</a>\n";
    page_tail();
}
Exemple #6
0
//
// BOINC 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
//
// This file was modified by contributors of "BOINC Web Tweak" project.
// show summary of a workunit
require_once "../inc/util.inc";
require_once "../inc/boinc_db.inc";
require_once "../inc/result.inc";
$wuid = get_int("wuid");
$wu = BoincWorkunit::lookup_id($wuid);
if (!$wu) {
    error_page("Can't find workunit");
}
page_head("Workunit {$wuid}");
$app = BoincApp::lookup_id($wu->appid);
start_table();
row2("name", $wu->name);
row2("application", $app->user_friendly_name);
row2("created", time_str($wu->create_time));
if ($wu->canonical_resultid) {
    row2('canonical result', '<a href="result.php?resultid=$wu->canonical_resultid">$wu->canonical_resultid</a>');
    row2("granted credit", format_credit($wu->canonical_credit));
}
// if app is using adaptive replication and no canonical result yet,
// don't show anything more
Exemple #7
0
function delete_results()
{
    db_init();
    $f = fopen('dbc_out.dat', 'r');
    while (1) {
        $x = fgets($f);
        if (!$x) {
            break;
        }
        $n = sscanf($x, "%d", $resid);
        if ($n != 1) {
            echo "bad line: {$x}\n";
            continue;
        }
        $result = BoincResult::lookup_id($resid);
        if (!$result) {
            echo "no result {$resultid}\n";
            continue;
        }
        $wu = BoincWorkunit::lookup_id($result->workunitid);
        if ($wu) {
            echo "result has WU: {$resid}\n";
            continue;
        }
        echo "deleting {$resid}\n";
        // uncomment the following to actually delete
        die("edit script to enable deletion\n");
        //_mysql_query("delete from result where id=$resid");
    }
}
Exemple #8
0
function handle_query_job($user)
{
    $wuid = get_int('wuid');
    page_head("Job {$wuid}");
    echo "<a href=workunit.php?wuid={$wuid}>View workunit page</a>\n";
    // show input files
    //
    echo "<h2>Input files</h2>\n";
    $wu = BoincWorkunit::lookup_id($wuid);
    $x = "<in>" . $wu->xml_doc . "</in>";
    $x = simplexml_load_string($x);
    start_table();
    table_header("Logical name<br><span class=note>(click to view)</span>", "Size (bytes)", "MD5");
    $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
    foreach ($x->workunit->file_ref as $fr) {
        $pname = (string) $fr->file_name;
        $lname = (string) $fr->open_name;
        $dir = filename_hash($pname, $fanout);
        $path = "../../download/{$dir}/{$pname}";
        $md5 = md5_file($path);
        $s = stat($path);
        $size = $s['size'];
        table_row("<a href=/download/{$dir}/{$pname}>{$lname}</a>", $size, $md5);
    }
    end_table();
    echo "<h2>Instances</h2>\n";
    start_table();
    table_header("Instance ID<br><span class=note>click for result page</span>", "State", "Output files<br><span class=note>click to view the file</span>");
    $results = BoincResult::enum("workunitid={$wuid}");
    foreach ($results as $result) {
        echo "<tr>\n            <td><a href=result.php?resultid={$result->id}>{$result->id} | {$result->name} </a></td>\n            <td>" . state_string($result) . "</td>\n            <td>\n";
        $i = 0;
        if ($result->server_state == 5) {
            $names = get_outfile_names($result);
            $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
            $i = 0;
            foreach ($names as $name) {
                $url = boinc_get_output_file_url($user, $result, $i++);
                $path = dir_hier_path($name, "../../upload", $fanout);
                $s = stat($path);
                $size = $s['size'];
                echo "<a href={$url}>{$name} </a> (" . number_format($size) . " bytes)<br/>";
            }
            $i++;
        }
        echo "</td></tr>\n";
    }
    end_table();
    echo "<p><a href=submit.php>Return to job control page</a>\n";
    page_tail();
}
Exemple #9
0
function get_gpu_list($vendor, $alt_vendor = null)
{
    $clause = "plan_class like '%{$vendor}%'";
    if ($alt_vendor) {
        $clause .= " or plan_class like '%{$alt_vendor}%'";
    }
    $avs = BoincAppVersion::enum($clause);
    if (count($avs) == 0) {
        return null;
    }
    $av_ids = "";
    foreach ($avs as $av) {
        $av_ids .= "{$av->id}, ";
    }
    $av_ids .= "0";
    $t = time() - 30 * 86400;
    //echo "start enum $vendor $av_ids\n";
    $results = BoincResult::enum("app_version_id in ({$av_ids}) and create_time > {$t} and elapsed_time>100 limit 500");
    //echo "end enum\n";
    $total = array();
    $win = array();
    $linux = array();
    $mac = array();
    foreach ($results as $r) {
        $h = BoincHost::lookup_id($r->hostid);
        if (!$h) {
            continue;
        }
        $wu = BoincWorkunit::lookup_id($r->workunitid);
        if (!$wu) {
            continue;
        }
        $v = "";
        if ($vendor == "cuda") {
            $v = "CUDA";
        } else {
            if ($vendor == "intel_gpu") {
                $v = "INTEL";
            } else {
                $v = "CAL";
            }
        }
        $model = get_gpu_model($h->serialnum, $v);
        if (!$model) {
            continue;
        }
        add_model($model, $r, $wu, $total);
        if (strstr($h->os_name, "Windows")) {
            add_model($model, $r, $wu, $win);
        }
        if (strstr($h->os_name, "Linux")) {
            add_model($model, $r, $wu, $linux);
        }
        if (strstr($h->os_name, "Darwin")) {
            add_model($model, $r, $wu, $mac);
        }
    }
    $x = new StdClass();
    $x->total = $total;
    $x->win = $win;
    $x->linux = $linux;
    $x->mac = $mac;
    return $x;
}
Exemple #10
0
function show_wu($wu_id)
{
    page_head("Workunit credit");
    $wu = BoincWorkunit::lookup_id($wu_id);
    $app = BoincApp::lookup_id($wu->appid);
    start_table();
    row2("App", "<a href=credit.php?app_id={$app->id}>{$app->user_friendly_name}</a>");
    end_table();
    echo "Results";
    start_table();
    table_header("Host", "App version", "Elapsed", "FLOPS est");
    $results = BoincResult::enum("workunitid={$wu->id} and validate_state=1");
    foreach ($results as $r) {
        table_row("<a href=credit.php?host_id={$r->hostid}>{$r->hostid}</a>", av_string($r->app_version_id), $r->elapsed_time, $r->flops_estimate);
    }
    end_table();
    page_tail();
}
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
// delete results without a corresponding workunit.
// (in principle these shouldn't exist)
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
require_once "../inc/boinc_db.inc";
$ndel = 0;
while (1) {
    $rs = BoincResult::enum("true order by id limit 100");
    $found = false;
    foreach ($rs as $r) {
        $wu = BoincWorkunit::lookup_id($r->workunitid);
        if ($wu) {
            echo "{$r->id} has a WU\n";
            $found = true;
            break;
        } else {
            echo "{$r->id} has no WU - deleting\n";
            $ndel++;
            $r->delete();
        }
    }
    if ($found) {
        break;
    }
}
echo "Done - deleted {$ndel} results\n";