.
require_once("../inc/translation.inc");
require_once("../inc/dir_hier.inc");
require_once("../inc/common_defs.inc");
// used by app_version_string(), see below
//
global $apps;
global $app_versions;
$apps = array();
$app_versions = array();
function anon_platform_string($result, $rsc_name=null) {
global $apps;
if (!array_key_exists($result->appid, $apps)) {
$app = BoincApp::lookup_id($result->appid);
$apps[$result->appid] = $app;
}
$app = $apps[$result->appid];
$n = $app->user_friendly_name."
". tra("Anonymous platform");
if ($rsc_name) {
$n .= " ($rsc_name)";
}
return $n;
}
function app_version_string($result) {
global $apps, $app_versions;
$id = $result->app_version_id;
switch ($id) {
case 0: return "---";
case ANON_PLATFORM_UNKNOWN:
return anon_platform_string($result);
case ANON_PLATFORM_CPU:
return anon_platform_string($result, tra("CPU"));
case ANON_PLATFORM_NVIDIA:
return anon_platform_string($result, tra("NVIDIA GPU"));
case ANON_PLATFORM_ATI:
return anon_platform_string($result, tra("ATI GPU"));
case ANON_PLATFORM_INTEL:
return anon_platform_string($result, tra("Intel GPU"));
}
if (array_key_exists($id, $app_versions)) {
$av = $app_versions[$id];
$app = $apps[$av->appid];
} else {
$av = BoincAppVersion::lookup_id($id);
if (!$av) {
return tra("Not in DB");
}
$app_versions[$id] = $av;
$app = BoincApp::lookup_id($av->appid);
$apps[$av->appid] = $app;
}
$n = $app->user_friendly_name;
$v = sprintf("%d.%02d", $av->version_num/100, $av->version_num%100);
if ($av->plan_class) {
$c = "($av->plan_class)";
} else {
$c = "";
}
return "$n v$v $c";
}
function result_granted_credit_string($result, $string_to_show) {
if ($result->server_state == RESULT_SERVER_STATE_IN_PROGRESS && $result->granted_credit > 0) {
return $string_to_show;
}
if ($result->server_state <> RESULT_SERVER_STATE_OVER) return "---";
switch($result->outcome) {
case RESULT_OUTCOME_SUCCESS:
switch ($result->validate_state) {
case VALIDATE_STATE_INIT:
case VALIDATE_STATE_INCONCLUSIVE:
return tra("pending");
}
return $string_to_show;
default:
if ($result->granted_credit > 0) {
return $string_to_show;
}
return "---";
}
}
// various states that we allow users to filter on
define("STATE_ALL", 0);
define("STATE_IN_PROGRESS", 1);
define("STATE_PENDING", 2);
define("STATE_INCONCLUSIVE", 3);
define("STATE_VALID", 4);
define("STATE_INVALID", 5);
define("STATE_ERROR", 6);
define("NSTATES", 7);
$state_name = array(
tra("All"),
tra("In progress"),
tra("Validation pending"),
tra("Validation inconclusive"),
tra("Valid"),
tra("Invalid"),
tra("Error"),
);
$state_clause = array(
"",
" and server_state=4 ",
" and server_state=5 and outcome=1 and validate_state=0 ",
" and server_state=5 and outcome=1 and validate_state=4 ",
" and server_state=5 and outcome=1 and validate_state=1 ",
" and server_state=5 and (outcome=6 or (outcome=1 and (validate_state=2 or validate_state=3 or validate_state=5))) ",
" and server_state=5 and (outcome=3 or outcome=4 or outcome=7) ",
);
function state_num($result) {
if ($result->server_state == RESULT_SERVER_STATE_IN_PROGRESS) return 1;
if ($result->server_state == RESULT_SERVER_STATE_OVER && $result->outcome == RESULT_OUTCOME_SUCCESS) {
if ($result->validate_state == VALIDATE_STATE_INIT) {
return STATE_PENDING;
}
if ($result->validate_state == VALIDATE_STATE_INCONCLUSIVE) {
return STATE_INCONCLUSIVE;
}
}
if ($result->server_state == RESULT_SERVER_STATE_OVER
&& $result->outcome == RESULT_OUTCOME_SUCCESS
&& $result->validate_state == VALIDATE_STATE_VALID
) {
return STATE_VALID;
}
if ($result->server_state == RESULT_SERVER_STATE_OVER
&& ($result->outcome == RESULT_OUTCOME_VALIDATE_ERROR
|| ($result->outcome == RESULT_OUTCOME_SUCCESS
&& ($result->validate_state == VALIDATE_STATE_INVALID
|| $result->validate_state == VALIDATE_STATE_NO_CHECK
|| $result->validate_state == VALIDATE_STATE_TOO_LATE
)
)
)
) {
return STATE_INVALID;
}
if ($result->server_state == RESULT_SERVER_STATE_OVER
&& ($result->outcome == RESULT_OUTCOME_CLIENT_ERROR
|| $result->outcome = RESULT_OUTCOME_NO_REPLY
|| $result->outcome = RESULT_OUTCOME_CLIENT_DETACHED
)
) {
return STATE_ERROR;
}
return 0;
}
function state_string($result) {
switch ($result->server_state) {
case RESULT_SERVER_STATE_INACTIVE: return tra("Inactive");
case RESULT_SERVER_STATE_UNSENT: return tra("Unsent");
case RESULT_SERVER_STATE_IN_PROGRESS: return tra("In progress");
case RESULT_SERVER_STATE_OVER:
switch ($result->outcome) {
case RESULT_OUTCOME_SUCCESS:
switch ($result->validate_state) {
case VALIDATE_STATE_INIT: return tra("Completed, waiting for validation");
case VALIDATE_STATE_VALID: return tra("Completed and validated");
case VALIDATE_STATE_INVALID: return tra("Completed, marked as invalid");
case VALIDATE_STATE_NO_CHECK: return tra("Completed, can't validate");
case VALIDATE_STATE_INCONCLUSIVE: return tra("Completed, validation inconclusive");
case VALIDATE_STATE_TOO_LATE: return tra("Completed, too late to validate");
}
return tra("Completed");
case RESULT_OUTCOME_COULDNT_SEND: return tra("Couldn't send");
case RESULT_OUTCOME_CLIENT_ERROR:
if ($result->exit_status == -221
|| $result->exit_status == 202
) {
return tra("Cancelled by server");
}
if ($result->exit_status == -233
|| $result->exit_status == 200
) {
return tra("Not started by deadline - canceled");
}
switch($result->client_state) {
case RESULT_FILES_DOWNLOADING: return tra("Error while downloading");
case RESULT_FILES_DOWNLOADED:
case RESULT_COMPUTE_ERROR: return tra("Error while computing");
case RESULT_FILES_UPLOADING: return tra("Error while uploading");
case RESULT_ABORTED: return tra("Aborted by user");
case RESULT_UPLOAD_FAILED: return tra("Upload failed");
}
return tra("Error");
case RESULT_OUTCOME_NO_REPLY: return tra("Timed out - no response");
case RESULT_OUTCOME_DIDNT_NEED: return tra("Didn't need");
case RESULT_OUTCOME_VALIDATE_ERROR: return tra("Validate error");
case RESULT_OUTCOME_CLIENT_DETACHED: return tra("Abandoned");
}
}
return tra("Unknown");
}
function result_server_state_string($result) {
switch($result->server_state) {
case RESULT_SERVER_STATE_INACTIVE: return tra("Inactive");
case RESULT_SERVER_STATE_UNSENT: return tra("Unsent");
case RESULT_SERVER_STATE_IN_PROGRESS: return tra("In progress");
case RESULT_SERVER_STATE_OVER: return tra("Over");
}
return tra("Unknown");
}
function result_outcome_string($result) {
switch($result->outcome) {
case RESULT_OUTCOME_INIT: return "---";
case RESULT_OUTCOME_SUCCESS: return tra("Success");
case RESULT_OUTCOME_COULDNT_SEND: return tra("Couldn't send");
case RESULT_OUTCOME_CLIENT_ERROR:
if ($result->exit_status <> -221) {
return tra("Computation error");
}
return tra("Redundant result");
case RESULT_OUTCOME_NO_REPLY: return tra("No reply");
case RESULT_OUTCOME_DIDNT_NEED: return tra("Didn't need");
case RESULT_OUTCOME_VALIDATE_ERROR: return tra("Validate error");
case RESULT_OUTCOME_CLIENT_DETACHED: return tra("Abandoned");
}
return tra("Unknown");
}
function result_client_state_string($result) {
switch($result->client_state) {
case RESULT_NEW: return tra("New");
case RESULT_FILES_DOWNLOADING: return tra("Downloading");
case RESULT_FILES_DOWNLOADED: return tra("Processing");
case RESULT_COMPUTE_ERROR: return tra("Compute error");
case RESULT_FILES_UPLOADING: return tra("Uploading");
case RESULT_FILES_UPLOADED: return tra("Done");
case RESULT_ABORTED:
if ($result->exit_status == -221 || $result->exit_status == 202) {
return tra("Cancelled by server");
}
return tra("Aborted by user");
case RESULT_UPLOAD_FAILED: return tra("Upload failed");
}
return tra("Unknown");
}
function validate_state_str($result) {
switch($result->validate_state) {
case VALIDATE_STATE_INIT: return tra("Initial");
case VALIDATE_STATE_VALID: return tra("Valid");
case VALIDATE_STATE_INVALID:
if ($result->exit_status <> -221) {
return tra("Invalid");
}
return tra("Not necessary");
case VALIDATE_STATE_NO_CHECK: return tra("Workunit error - check skipped");
case VALIDATE_STATE_INCONCLUSIVE: return tra("Checked, but no consensus yet");
case VALIDATE_STATE_TOO_LATE: return tra("Task was reported too late to validate");
}
return tra("Unknown");
}
function assimilate_state_str($s) {
switch($s) {
case ASSIMILATE_INIT: return "Initial";
case ASSIMILATE_READY: return "Ready to assimilate";
case ASSIMILATE_DONE: return "Assimilated";
}
return "Unknown";
}
function file_delete_state_str($s) {
switch($s) {
case FILE_DELETE_INIT: return "Initial";
case FILE_DELETE_READY: return "Ready to delete";
case FILE_DELETE_DONE: return "Deleted";
case FILE_DELETE_ERROR: return "Delete Error";
}
return "Unknown";
}
function wu_error_mask_str($s) {
$x = "";
if ($s & WU_ERROR_COULDNT_SEND_RESULT) {
$x = $x." ".tra("Couldn't send result");
$s -= WU_ERROR_COULDNT_SEND_RESULT;
}
if ($s & WU_ERROR_TOO_MANY_ERROR_RESULTS) {
$x = $x." ".tra("Too many errors (may have bug)");
$s -= WU_ERROR_TOO_MANY_ERROR_RESULTS;
}
if ($s & WU_ERROR_TOO_MANY_SUCCESS_RESULTS) {
$x = $x." ".tra("Too many results (may be nondeterministic)");
$s -= WU_ERROR_TOO_MANY_SUCCESS_RESULTS;
}
if ($s & WU_ERROR_TOO_MANY_TOTAL_RESULTS) {
$x = $x." ".tra("Too many total results");
$s -= WU_ERROR_TOO_MANY_TOTAL_RESULTS;
}
if ($s & WU_ERROR_CANCELLED) {
$x = $x." ".tra("WU cancelled");
$s -= WU_ERROR_CANCELLED;
}
if ($s & WU_ERROR_NO_CANONICAL_RESULT) {
$x = $x." ".tra("Canonical result is missing");
$s -= WU_ERROR_NO_CANONICAL_RESULT;
}
if ($s) {
$x = $x." ".tra("Unrecognized Error: %1", $s);
}
if (strlen($x)) {
$x="".$x."";
} else {
$x="";
}
return $x;
}
function result_page_url($info) {
$c = $info->clause;
$o = $info->offset;
$sn = $info->show_names;
$st = $info->state;
$appid = $info->appid;
return "results.php?$c&offset=$o&show_names=$sn&state=$st&appid=$appid";
}
function result_table_start($show_wu_link, $show_host_link, $info) {
start_table();
echo "
".htmlspecialchars($result->stderr_out).""; } function result_navigation($info, $where_clause) { global $state_name; $state_count = array(); $app_count = array(); $x = ""; $apps = BoincApp::enum('deprecated=0 ORDER BY user_friendly_name'); for ($i=0; $i