Ejemplo n.º 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_res($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);
    }
}
Ejemplo n.º 2
0
function handle_get_output($r, $batch)
{
    $wus = BoincWorkUnit::enum("batch={$batch->id}");
    $outdir = "/tmp/tree_threader_output_" . $batch->id;
    @mkdir($outdir);
    foreach ($wus as $wu) {
        if (!$wu->canonical_resultid) {
            continue;
        }
        $result = BoincResult::lookup_id($wu->canonical_resultid);
        if (!$result) {
            continue;
        }
        $paths = get_outfile_paths($result);
        if (sizeof($paths) < 1) {
            continue;
        }
        // there's only one output file
        //
        $path = $paths[0];
        // unzip it into a directory in /tmp
        //
        $dir = "/tmp/{$wu->name}";
        @mkdir($dir);
        $cmd = "cd {$dir}; unzip -q {$path}";
        $ret = system($cmd);
        if ($ret === false) {
            error("can't unzip output file");
        }
        $cmd = "cp {$dir}/ali/* {$outdir}";
        $ret = system($cmd);
        if ($ret === false) {
            error("can't copy output files");
        }
        //system("rm -rf $dir");
    }
    $cmd = "zip -r -q {$outdir} {$outdir}";
    $ret = system($cmd);
    if ($ret === false) {
        error("can't zip output files");
    }
    $fname = "tree_threader_output_" . $batch->id . ".zip";
    @symlink($outdir, "../../download/{$fname}");
    $config = simplexml_load_string(file_get_contents("../../config.xml"));
    $download_url = trim((string) $config->config->download_url);
    echo "<tt_reply>\n<url>{$download_url}/{$fname}</url>\n</tt_reply>\n";
}
Ejemplo n.º 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);
}
Ejemplo n.º 4
0
function query_completed_job($r)
{
    xml_start_tag("query_completed_job");
    list($user, $user_submit) = authenticate_user($r, null);
    $job_name = (string) $r->job_name;
    $job_name = BoincDb::escape_string($job_name);
    $wu = BoincWorkunit::lookup("name='{$job_name}'");
    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");
    }
    echo "<completed_job>\n";
    echo "   <error_mask>{$wu->error_mask}</error_mask>\n";
    if ($wu->canonical_resultid) {
        $result = BoincResult::lookup_id($wu->canonical_resultid);
        echo "   <canonical_resultid>{$wu->canonical_resultid}</canonical_resultid>\n";
    } else {
        $results = BoincResult::enum("workunitid={$job_id}");
        foreach ($results as $r) {
            switch ($r->outcome) {
                case 1:
                case 3:
                case 6:
                    $result = $r;
                    break;
            }
        }
        if ($result) {
            echo "   <error_resultid>{$result->id}</error_resultid>\n";
        }
    }
    if ($result) {
        echo "   <exit_status>{$result->exit_status}</exit_status>\n";
        echo "   <elapsed_time>{$result->elapsed_time}</elapsed_time>\n";
        echo "   <cpu_time>{$result->cpu_time}</cpu_time>\n";
        echo "   <stderr_out><![CDATA[\n";
        echo htmlspecialchars($result->stderr_out);
        echo "   ]]></stderr_out>\n";
    }
    echo "</completed_job>\n        </query_completed_job>\n    ";
}
Ejemplo n.º 5
0
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// 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/>.
// show a result
require_once "../inc/util.inc";
require_once "../inc/result.inc";
$x = get_int("resultid", true);
if ($x) {
    $result = BoincResult::lookup_id($x);
} else {
    $x = get_str("result_name");
    $result = BoincResult::lookup_name($x);
}
if (!$result) {
    error_page(tra("No such task:") . " " . htmlspecialchars($x));
    // the htmlspecialchars prevents XSS
}
page_head(tra("Task") . " " . htmlspecialchars($x));
show_result($result);
page_tail();
Ejemplo n.º 6
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");
    }
}
Ejemplo n.º 7
0
// names = name1,name2,...
require_once "../inc/util.inc";
require_once "../inc/xml.inc";
function result_xml($r)
{
    echo "\n    <result>\n        <id>{$r->id}</id>\n        <create_time>{$r->create_time}</create_time>\n        <workunitid>{$r->workunitid}</workunitid>\n        <server_state>{$r->server_state}</server_state>\n        <outcome>{$r->outcome}</outcome>\n        <client_state>{$r->client_state}</client_state>\n        <hostid>{$r->hostid}</hostid>\n        <userid>{$r->userid}</userid>\n        <report_deadline>{$r->report_deadline}</report_deadline>\n        <sent_time>{$r->sent_time}</sent_time>\n        <received_time>{$r->received_time}</received_time>\n        <name>{$r->name}</name>\n        <cpu_time>{$r->cpu_time}</cpu_time>\n        <batch>{$r->batch}</batch>\n        <file_delete_state>{$r->file_delete_state}</file_delete_state>\n        <validate_state>{$r->validate_state}</validate_state>\n        <granted_credit>{$r->granted_credit}</granted_credit>\n        <app_version_num>{$r->app_version_num}</app_version_num>\n        <appid>{$r->appid}</appid>\n        <exit_status>{$r->exit_status}</exit_status>\n        <elapsed_time>{$r->elapsed_time}</elapsed_time>\n        <flops_estimate>{$r->flops_estimate}</flops_estimate>\n        <peak_working_set_size>{$r->peak_working_set_size}</peak_working_set_size>\n        <peak_swap_size>{$r->peak_swap_size}</peak_swap_size>\n        <peak_disk_usage>{$r->peak_disk_usage}</peak_disk_usage>\n    </result>\n";
}
BoincDb::get(true);
// read-only; use replica DB if possible
xml_header();
echo "<results>\n";
$ids = get_str("ids", true);
if ($ids) {
    $ids = explode(",", $ids);
    foreach ($ids as $id) {
        $result = BoincResult::lookup_id($id);
        if ($result) {
            result_xml($result);
        } else {
            echo "<error>ID {$id} unknown</error>\n";
        }
    }
} else {
    $names = get_str("names", true);
    $names = explode(",", $names);
    foreach ($names as $name) {
        $result = BoincResult::lookup_name($name);
        if ($result) {
            result_xml($result);
        } else {
            echo "<error>name {$name} unknown</error>\n";
Ejemplo n.º 8
0
function handle_get_output($r, $batch)
{
    global $log;
    $timestamp = date("Y-m-d H:i", time());
    $wus = BoincWorkUnit::enum("batch={$batch->id}");
    $outdir = "/tmp/treeThreader_result_" . $batch->id;
    @mkdir($outdir);
    foreach ($wus as $wu) {
        if (!$wu->canonical_resultid) {
            continue;
        }
        $result = BoincResult::lookup_id($wu->canonical_resultid);
        if (!$result) {
            continue;
        }
        $paths = get_outfile_paths($result);
        if (sizeof($paths) < 1) {
            continue;
        }
        // there's only one output file
        //
        $path = $paths[0];
        // unzip it into a directory in /tmp
        //
        $dir = "/tmp/{$wu->name}";
        @mkdir($dir);
        $cmd = "cd {$dir}; unzip -q {$path}";
        system($cmd, $ret);
        if ($ret != 0) {
            error("can't unzip output file");
        }
        $cmd = "cp {$dir}/Aln/* {$outdir}";
        system($cmd, $ret);
        if ($ret != 0) {
            error("can't copy output files");
        }
        system("rm -rf {$dir}");
    }
    $cmd = "zip -r -q {$outdir} {$outdir}";
    system($cmd, $ret);
    if ($ret != $ret) {
        error("can't zip output files");
    }
    $fname = "treeThreader_result_" . $batch->id . ".zip";
    $treeThreader_dir = "treeThreaderResult";
    if (!is_dir("../../download/{$treeThreader_dir}")) {
        mkdir("../../download/{$treeThreader_dir}");
    }
    @symlink("/tmp/{$fname}", "../../download/{$treeThreader_dir}/{$fname}");
    system("rm -fr {$outdir}");
    $config = simplexml_load_string(file_get_contents("../../config.xml"));
    $download_url = trim((string) $config->config->download_url);
    echo "<tt_reply>\n<url>{$download_url}/{$treeThreader_dir}/{$fname}</url>\n</tt_reply>\n";
    $log_msg = "{$timestamp}\tuser {$batch->user_id} downloads results for batch {$batch->id} : {$download_url}/{$treeThreader_dir}/{$fname}\n";
    fwrite($log, $log_msg);
}