2010-11-10 22:54:56 +00:00
|
|
|
#! /usr/bin/env php
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// query a job created with demo_submit
|
|
|
|
//
|
2023-11-19 21:31:52 +00:00
|
|
|
// usage: bin/demo_query jobname
|
2010-11-10 22:54:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
chdir("html/ops");
|
|
|
|
require_once("../inc/boinc_db.inc");
|
2023-11-19 21:31:52 +00:00
|
|
|
require_once("../inc/common_defs.inc");
|
|
|
|
require_once("../inc/result.inc");
|
2010-11-10 22:54:56 +00:00
|
|
|
chdir("../..");
|
|
|
|
|
2023-11-19 21:31:52 +00:00
|
|
|
function main($wu_name) {
|
|
|
|
$wu = BoincWorkunit::lookup("name='$wu_name'");
|
|
|
|
if (!$wu) {
|
|
|
|
die("no such job: $wu_name\n");
|
|
|
|
}
|
2010-11-10 22:54:56 +00:00
|
|
|
|
|
|
|
if ($wu->error_mask) {
|
2023-12-22 21:30:41 +00:00
|
|
|
echo sprintf("Job failed: %s\n",
|
2023-11-19 21:31:52 +00:00
|
|
|
wu_error_mask_str($wu->error_mask)
|
|
|
|
);
|
|
|
|
return;
|
2010-11-10 22:54:56 +00:00
|
|
|
}
|
2023-11-19 21:31:52 +00:00
|
|
|
switch ($wu->assimilate_state) {
|
|
|
|
case ASSIMILATE_INIT:
|
|
|
|
echo "Job is in progress.\n";
|
|
|
|
break;
|
|
|
|
case ASSIMILATE_READY:
|
2023-12-22 21:30:41 +00:00
|
|
|
echo "Job is waiting for assimilation.\n";
|
2023-11-19 21:31:52 +00:00
|
|
|
break;
|
|
|
|
case ASSIMILATE_DONE:
|
2010-11-10 22:54:56 +00:00
|
|
|
$result = BoincResult::lookup_id($wu->canonical_resultid);
|
|
|
|
$host = BoincHost::lookup_id($result->hostid);
|
|
|
|
$user = BoincUser::lookup_id($result->userid);
|
|
|
|
echo "Job completed\n"
|
|
|
|
." Host $host->id ($host->os_name, $host->p_vendor)\n"
|
|
|
|
." User $user->id ($user->name)\n"
|
|
|
|
;
|
2023-12-22 21:30:41 +00:00
|
|
|
$xmlout = simplexml_load_string(
|
|
|
|
sprintf("<foo>%s</foo>", $result->xml_doc_out)
|
|
|
|
);
|
|
|
|
$ofs = $xmlout->file_info;
|
|
|
|
$nofs = $ofs->count();
|
|
|
|
for ($i=0; $i<$nofs; $i++) {
|
|
|
|
if ($nofs == 1) {
|
|
|
|
$path = "sample_results/$wu_name";
|
|
|
|
} else {
|
|
|
|
$path = sprintf("sample_results/%s_%d", $wu_name, $i);
|
|
|
|
}
|
|
|
|
if (!is_file($path)) {
|
|
|
|
die("output file is missing: $path\n");
|
|
|
|
}
|
|
|
|
echo "Output file $i ($path):\n";
|
|
|
|
readfile($path);
|
2010-11-10 22:54:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-19 21:31:52 +00:00
|
|
|
if ($argc != 2) {
|
|
|
|
die("usage: demo_query jobname\n");
|
|
|
|
}
|
|
|
|
main($argv[1]);
|
2010-11-10 22:54:56 +00:00
|
|
|
?>
|