function is_job_running($study, $jobid) { $jobinfo = get_job_info($study, $jobid); if (!is_array($jobinfo)) { return false; } if (!isset($jobinfo['status'])) { // status is not set: the job could be still running return true; } if ($jobinfo['status'] === JobStatus::$FINISHED || $jobinfo['status'] === JobStatus::$KILLED) { return false; } return false; }
function do_exit($jobid, $pid, $message) { $redirect = isset($_GET["redirect"]); $url = isset($_GET["url"]) ? $_GET["url"] : OC_Helper::linkTo("neurocloud", "index.php", array("jobid" => $jobid, "pid" => $pid, "message" => $message, "action" => "kill")); if ($redirect) { header("Location: " . $url); } else { echo $message; exit; } } $user = isset($_GET["user"]) ? $_GET["user"] : false; $study = isset($_GET["study"]) ? $_GET["study"] : false; $jobid = $_GET["jobid"]; if ($study !== false) { $jobinfo = get_job_info($study, $jobid); } elseif ($user !== false) { $jobinfo = get_temp_job_info($user, $jobid); } if ($jobinfo === false) { echo "ERROR: cannot find job info"; exit; } $killtree_path = get_kill_script(OC_User::getUser()); if ($killtree_path === false) { do_exit($jobid, null, "ERROR"); } if (!isset($jobinfo["exec_type"])) { $jobinfo["exec_type"] = "local"; // default execution type is local execution }
exit; } $job = $_GET['jobid']; $file = $_GET['study']; $outputid = $_GET['outputid']; $rowid = $_GET['rowid']; # check if we have to print the <tr> elements (we do not print them if this file is called from a AJAX call if (isset($_GET["print_tr"])) { $print_tr = $_GET["print_tr"]; } else { $print_tr = true; // default true } $filelink = OC_Helper::linkTo('files', '', array("dir" => "{$file}/results/{$job}")); $output_file = get_job_output_file($file, $job); $jobinfo = get_job_info($file, $job); // obtain the precedent status $precstatus = isset($jobinfo['status']) ? $jobinfo['status'] : JobStatus::$RUNNING; $qsub_jobname = $jobinfo["qsub_jobname"]; // obtain the current status (potentially slow operation, calls ssh/qstat) $status = get_job_status($jobinfo); $sgequeued = 0; $sgerunning = 0; if ($status == JobStatus::$FINISHED || $status === JobStatus::$KILLED) { if ($precstatus !== $status) { $jobinfo['status'] = $status; // get_job_status returned FINISHED or KILLED, we save that info in the job JSON save_job_info($file, $job, $jobinfo); } if (!isset($jobinfo["usedspace"])) { // calculate space used by temp dir + results
<?php /* * refresh_job_status * Created on: Feb 4, 2013 4:11:53 PM * * Copyright 2013 EnginSoft S.p.A. * All rights reserved */ require_once 'neurocloud/lib/common.php'; if (isset($_POST["study"]) && isset($_POST["jobid"])) { $study = $_POST["study"]; $jobid = $_POST["jobid"]; echo get_job_status(get_job_info($study, $jobid)); } else { echo "ERROR"; } exit;
<?php /** * Created by PhpStorm. * User: robert * Date: 11/21/15 * Time: 8:33 PM */ include 'includes.php'; //Get the data from the REST call $job_id = $_GET['job_id']; $api_key = $_GET['api_key']; //Confirm the API key is valid, if it is go get the info for the job id. If the job doesn't exist throw 400. If the API Key //isn't valid throw a 404 if (validate_api_key($api_key) == true) { if ($result = json_decode(get_job_info($job_id)) != 0) { print $result; } else { http_response_code(400); } } else { http_response_code(404); }