remote_submit script: exit with nonzero status if error

Also, suppress warnings from simplexml_load_string()
This commit is contained in:
David Anderson 2013-07-16 13:18:46 -07:00
parent e3fc1bf37d
commit 3faf18c7b4
3 changed files with 21 additions and 14 deletions

View File

@ -97,8 +97,10 @@ function do_http_op($req, $xml, $op) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$reply = curl_exec($ch);
if (!$reply) return array(null, "HTTP error");
$r = simplexml_load_string($reply);
if (!$r) return array(null, "Can't parse reply XML: <pre>".htmlentities($reply)."</pre>");
$r = @simplexml_load_string($reply);
if (!$r) {
return array(null, "Can't parse reply XML:\n$reply");
}
$e = (string)$r->error_msg;
if ($e) {
return array(null, $e);

View File

@ -57,7 +57,7 @@ function handle_main() {
$req->project = $project;
$req->authenticator = $auth;
list($batches, $errmsg) = boinc_query_batches($req);
if ($errmsg) error_page($errmsg);
if ($errmsg) error_page(htmlentities($errmsg));
page_head("Job submission and control");
@ -270,7 +270,7 @@ function handle_create_action() {
if ($get_estimate) {
$req = form_to_request($project, $auth);
list($e, $errmsg) = boinc_estimate_batch($req);
if ($errmsg) error_page($errmsg);
if ($errmsg) error_page(htmlentities($errmsg));
page_head("Batch estimate");
echo sprintf("Estimate: %.0f seconds", $e);
echo "<p><a href=submit_example.php>Return to job control page</a>\n";
@ -278,7 +278,7 @@ function handle_create_action() {
} else {
$req = form_to_request($project, $auth);
list($id, $errmsg) = boinc_submit_batch($req);
if ($errmsg) error_page($errmsg);
if ($errmsg) error_page(htmlentities($errmsg));
page_head("Batch submitted");
echo "Batch created, ID: $id\n";
echo "<p><a href=submit_example.php>Return to job control page</a>\n";
@ -294,7 +294,7 @@ function handle_query_batch() {
$req->authenticator = $auth;
$req->batch_id = get_int('batch_id');
list($batch, $errmsg) = boinc_query_batch($req);
if ($errmsg) error_page($errmsg);
if ($errmsg) error_page(htmlentities($errmsg));
page_head("Batch $req->batch_id");
start_table();
@ -368,7 +368,7 @@ function handle_query_job() {
$req->authenticator = $auth;
$req->job_id = get_int('job_id');
list($reply, $errmsg) = boinc_query_job($req);
if ($errmsg) error_page($errmsg);
if ($errmsg) error_page(htmlentities($errmsg));
page_head("Job $req->job_id");
echo "<a href=$project/workunit.php?wuid=$req->job_id>View workunit page on BOINC server</a>\n";
@ -421,7 +421,7 @@ function handle_abort_batch() {
$req->authenticator = $auth;
$req->batch_id = get_int('batch_id');
$errmsg = boinc_abort_batch($req);
if ($errmsg) error_page($errmsg);
if ($errmsg) error_page(htmlentities($errmsg));
page_head("Batch aborted");
echo "<p><a href=submit_example.php>Return to job control page</a>\n";
page_tail();
@ -449,7 +449,7 @@ function handle_retire_batch() {
$req->authenticator = $auth;
$req->batch_id = get_int('batch_id');
$errmsg = boinc_retire_batch($req);
if ($errmsg) error_page($errmsg);
if ($errmsg) error_page(htmlentities($errmsg));
page_head("Batch retired");
echo "<p><a href=submit_example.php>Return to job control page</a>\n";
page_tail();

View File

@ -6,12 +6,13 @@
require_once("submit.inc");
define("PROJECT", "http://casathome.ihep.ac.cn");
define("PROJECT", "http://casathome.ihep.ac.cn/");
define("APP_NAME", "uppercase");
define("LOCAL_DIR", "");
function usage() {
global $argv;
die("
echo "
Usage:
$argv[0] submit sequence_file (submit 1 job, print batch ID)
$argv[0] query batch_id (get the status of a specific batch)
@ -20,11 +21,12 @@ $argv[0] query all (get the status of all batches)
$argv[0] get_output batch_id (show URL of output file)
$argv[0] abort batch_id (abort a batch)
$argv[0] retire batch_id (retire a batch)
\n");
";
exit(1);
}
function get_auth() {
return trim(file_get_contents("auth"));
return trim(file_get_contents(LOCAL_DIR."auth"));
}
function handle_submit() {
@ -44,6 +46,7 @@ function handle_submit() {
list($id, $errmsg) = boinc_submit_batch($req);
if ($errmsg) {
echo "Error: $errmsg\n";
exit(1);
} else {
echo "batch ID: $id\n";
}
@ -97,7 +100,7 @@ function handle_query() {
list($batches, $errmsg) = boinc_query_batches($req);
if ($errmsg) {
echo "Error: $errmsg\n";
return;
exit(1);
}
if ($argv[2] == 'all') {
foreach ($batches as $batch) {
@ -142,6 +145,7 @@ function handle_abort() {
$errmsg = boinc_abort_batch($req);
if ($errmsg) {
echo "Error: $errmsg\n";
exit(1);
} else {
echo "Batch aborted\n";
}
@ -156,6 +160,7 @@ function handle_retire() {
$errmsg = boinc_retire_batch($req);
if ($errmsg) {
echo "Error: $errmsg\n";
exit(1);
} else {
echo "Batch retired\n";
}