-
Notifications
You must be signed in to change notification settings - Fork 452
/
demo_query
executable file
·67 lines (61 loc) · 1.77 KB
/
demo_query
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /usr/bin/env php
<?php
// query a job created with demo_submit
//
// usage: bin/demo_query jobname
chdir("html/ops");
require_once("../inc/boinc_db.inc");
require_once("../inc/common_defs.inc");
require_once("../inc/result.inc");
chdir("../..");
function main($wu_name) {
$wu = BoincWorkunit::lookup("name='$wu_name'");
if (!$wu) {
die("no such job: $wu_name\n");
}
if ($wu->error_mask) {
echo sprintf("Job failed: %s\n",
wu_error_mask_str($wu->error_mask)
);
return;
}
switch ($wu->assimilate_state) {
case ASSIMILATE_INIT:
echo "Job is in progress.\n";
break;
case ASSIMILATE_READY:
echo "Job is waiting for assimilation.\n";
break;
case ASSIMILATE_DONE:
$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"
;
$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);
}
break;
}
}
if ($argc != 2) {
die("usage: demo_query jobname\n");
}
main($argv[1]);
?>