Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ajax/checkrunnable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$study=$_POST["study"];


#error_log(print_r($_SESSION["nc_sync_paths"],true));
//#error_log(print_r($_SESSION["nc_sync_paths"],true));

if (OC_Neurocloud::is_study_runnable($study)) {
echo "1";
Expand Down
2 changes: 1 addition & 1 deletion ajax/getoutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/*
* max size of output file, to avoid reading a very big output and clogging the network
*/
$MAX_SIZE = 1024 * 512; # "512k of memory should be enough for everyone"
$MAX_SIZE = 1024 * 512; //# "512k of memory should be enough for everyone"
$content = "";
if (OC_Filesystem::is_file($filename) && OC_Filesystem::is_readable($filename)) {
if (OC_Filesystem::filesize($filename) > $MAX_SIZE) {
Expand Down
8 changes: 4 additions & 4 deletions ajax/inplace_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
$prefix = "/tmp/owncloud";
}

# backup current installation
//# backup current installation
echo "Backup of current version in $datadir\n";
exec("tar czf " . $datadir . "/owncloud_bkp$(date +%Y%m%d).tar.gz $root");

# download latest version
//# download latest version
echo "Downloading last version\n";
$curl = curl_init($url);
$fp = fopen("/tmp/owncloud-latest.tar.bz2", "w");
Expand All @@ -42,7 +42,7 @@
curl_close($curl);
fclose($fp);

# TODO: check version MD5
//# TODO: check version MD5
$md5_try = file_get_contents($url . ".md5");
if (strlen($md5_try) > 32) {
$md5_try = substr($md5_try, 0, 32);
Expand All @@ -56,7 +56,7 @@
}


# unpack latest version
//# unpack latest version
echo "Unpacking last version\n";
exec("mkdir $datadir/owncloud_latest; tar -C $datadir/owncloud_latest -xjf /tmp/owncloud-latest.tar.bz2");

Expand Down
6 changes: 3 additions & 3 deletions ajax/job_info_row.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$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
//# 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 {
Expand Down Expand Up @@ -80,7 +80,7 @@
$killjs = OC_Helper::linkTo("neurocloud", "ajax/kill_job.php", array("study" => $file, "jobid" => $job, "redirect" => 1));
$refreshstatusjs = "javascript:refresh_job_status('" . $rowid . "','" . $file . "','" . $job . "','" . $outputid . "')";
$showjobinfojs = "javascript:show_output('" . $outputid . "','". get_job_info_file($file, $job) . "', true)";
#$queueinfojs = "javascript:show_queue_info('" . $outputid . "','". $jobinfo['qsub_jobname'] . "', true)";
//#$queueinfojs = "javascript:show_queue_info('" . $outputid . "','". $jobinfo['qsub_jobname'] . "', true)";
$deletejs = "javascript:delete_results('" . $rowid . "','" . $file . "','" . $job . "')";

$script = isset($jobinfo["script"]) ? basename($jobinfo["script"]) : false;
Expand Down Expand Up @@ -171,4 +171,4 @@
</tr>
<?php
}
?>
?>
4 changes: 2 additions & 2 deletions ajax/updateCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/


# first, clear the "fast" cache, to make sure that missing DB items are inserted/updated
//# first, clear the "fast" cache, to make sure that missing DB items are inserted/updated
OC_Cache::clear();

# then scan the filesystem
//# then scan the filesystem
OC_FileCache::scan("");

echo 'true';
Expand Down
4 changes: 2 additions & 2 deletions appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'order' => 74,
'href' => OC_Helper::linkTo('neurocloud', 'index.php'),
'icon' => OC_Helper::imagePath('neurocloud', 'neurocloud.png'),
'name' => 'Neurocloud'));
'name' => 'NeuroBox'));

/**
* register the classpath
Expand Down Expand Up @@ -60,4 +60,4 @@

OC_FileProxy::register(new NC_FileProxy());

?>
?>
6 changes: 3 additions & 3 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0"?>
<info>
<id>neurocloud</id>
<name>Neurocloud</name>
<description>Neurocloud app description here</description>
<name>NeuroBox</name>
<description>Neurobox app description here</description>
<version>1.0.0</version>
<licence></licence>
<author>Neurocloud developers</author>
<author>Neurobox developers</author>
<require>4.5</require>
<types>
<filesystem />
Expand Down
24 changes: 12 additions & 12 deletions execute.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
require_once 'lib/common.php';


# TODO: SUBSTITUTE WITH REAL CONFIG VALUE !!!
#OC_Config::setValue("nc_exec_env_root" ,"/tmp/neurocloud");
//# TODO: SUBSTITUTE WITH REAL CONFIG VALUE !!!
//#OC_Config::setValue("nc_exec_env_root" ,"/tmp/neurocloud");


function create_job_id($study_name, $script_name) {
Expand Down Expand Up @@ -57,20 +57,20 @@ function create_execution_env($study_name, $script_name) {

OC_Filesystem::mkdir("$study_name/results/$jobid");

# le dir /data e /results sono link simbolici alle vere directory del caso di studio
//# le dir /data e /results sono link simbolici alle vere directory del caso di studio
mkdir($job_dir . "/pipeline");
symlink($datadir, $job_dir . "/data");
symlink($resultsdir, $job_dir . "/results");

# creo il file in cui verrà rediretto lo standard output
//# creo il file in cui verrà rediretto lo standard output
$date = date("Y-m-d H:i:s");
OC_Filesystem::file_put_contents(get_job_output_file($study_name, $jobid), "Standard output for job $jobid, run at $date\n");

$jobinfo = array("jobid" => $jobid, "study" => $study_name);

save_job_info($study_name, $jobid, $jobinfo);

# copia gli script del caso di studio nella pipeline
//# copia gli script del caso di studio nella pipeline
copy_dir($pipelinedir, $job_dir . "/pipeline");

return $jobid;
Expand All @@ -87,7 +87,7 @@ function execute_script_local($workdir, $cmd, $study, $jobid) {

if (chdir($workdir)) {
$outfile = get_absolute_path(get_job_output_file($study, $jobid));
# things that are needed to proc_open, see http://it2.php.net/manual/en/function.proc-open.php
//# things that are needed to proc_open, see http://it2.php.net/manual/en/function.proc-open.php
$pipes = 0;
$descriptors = array(
0 => array('pipe', 'r'),
Expand All @@ -98,7 +98,7 @@ function execute_script_local($workdir, $cmd, $study, $jobid) {

$env["HOME"] = get_local_exec_dir(OC_User::getUser());
$env["PATH"] = $_SERVER["PATH"];
# use a UNIX command to get the current user name
//# use a UNIX command to get the current user name
$env["USER"] = exec("whoami");

chmod($cmd, 0755);
Expand Down Expand Up @@ -155,7 +155,7 @@ function execute_script_remote($study, $jobid, $workdir, $rerun, $cmd, $args = "
$jobid_qsub = 'j' . str_replace(".","_", $jobid);
$orig_cmd = $cmd;

# check if the command is a python script
//# check if the command is a python script
if (is_python_script($cmd) !== false) {
// prepend the python script with our command

Expand All @@ -177,7 +177,7 @@ function execute_script_remote($study, $jobid, $workdir, $rerun, $cmd, $args = "

$cmd = $NC_CONFIG["python-bin"] . " " . $cmd;
} elseif (strpos($cmd, ".sh") !== false) {
#$cmd = "qsub -cwd -l mf=1.4G -N $jobid_qsub -sync y -o results/nc_stdout.log -e results/nc_stdout.log " . $cmd;
//#$cmd = "qsub -cwd -l mf=1.4G -N $jobid_qsub -sync y -o results/nc_stdout.log -e results/nc_stdout.log " . $cmd;
$cmd = "/bin/bash " . $cmd;
$args = $jobid_qsub;
}
Expand Down Expand Up @@ -218,7 +218,7 @@ function execute_script_remote($study, $jobid, $workdir, $rerun, $cmd, $args = "

$space = get_used_space_remote();
if (is_array($space) && (int)$space['percent'] > (int)$NC_CONFIG['minimum_exec_space']) {
# Redirect to neurocloud app index , showing an error message
//# Redirect to neurocloud app index , showing an error message
$link = OC_Helper::linkTo("neurocloud", "index.php", array("error" => "Cannot execute script, low free space in remote server.<br>Contact administration or delete old jobs"));
header("Location: " . $link);
exit();
Expand Down Expand Up @@ -248,15 +248,15 @@ function execute_script_remote($study, $jobid, $workdir, $rerun, $cmd, $args = "
$exec_dir = get_job_exec_dir($job_id);
$pid = execute_script_local($exec_dir, "pipeline" . DIRECTORY_SEPARATOR . $script, $study, $job_id);
}
# Redirect to neurocloud app index , showing an info (or error) message
//# Redirect to neurocloud app index , showing an info (or error) message
if ($pid) {
$link = OC_Helper::linkTo("neurocloud", "index.php", array("jobid" => $job_id, "pid" => $pid, "action" => "launch"));
} else {
$link = OC_Helper::linkTo("neurocloud", "index.php", array("error" => "Cannot launch job, see log for details"));
}
header("Location: " . $link);
} else {
# Redirect to neurocloud app index , showing an error message
//# Redirect to neurocloud app index , showing an error message
$link = OC_Helper::linkTo("neurocloud", "index.php", array("error" => "Sync is in progress, cannot execute script"));
header("Location: " . $link);
}
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
OC_Util::addStyle('neurocloud', "nc");

OC_App::setActiveNavigationEntry( 'neurocloud_index');
$tmpl = new OC_Template( 'neurocloud', 'main', 'user');
$tmpl = new OC_Template('neurocloud', 'main', 'user');

$message = "";
$action = "launch";
Expand Down
22 changes: 11 additions & 11 deletions lib/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function create_ssh_command() {
$host = $NC_CONFIG["remote_host"];
$key = get_private_key_file($user);

# The option BatchMode=yes is used to not asking for password
# StrictHostKeyChecking=no is used to not ask to include the host in .ssh/known_hosts file
//# The option BatchMode=yes is used to not asking for password
//# StrictHostKeyChecking=no is used to not ask to include the host in .ssh/known_hosts file
return "ssh -n -i $key -o BatchMode=yes -o StrictHostKeyChecking=no $user@$host ";
}

Expand Down Expand Up @@ -156,8 +156,8 @@ function get_used_space_remote() {
include "neurocloud/config.inc.php";
$cmd = create_ssh_command() . " df -h " . $NC_CONFIG['remote_mount'];
$lastrow = exec($cmd);
# example of lastrow :
# korempba:/nilab0 2.0T 28G 1.9T 2% /nilab0
//# example of lastrow :
//# korempba:/nilab0 2.0T 28G 1.9T 2% /nilab0

if (is_string($lastrow)) {
$spl = preg_split("/\s+/", $lastrow);
Expand All @@ -166,7 +166,7 @@ function get_used_space_remote() {
$ret["total"] = $spl[1];
$ret["used"] = $spl[2];
$ret["free"] = $spl[3];
$ret["percent"] = substr($spl[4],0,-1); # omit the % character
$ret["percent"] = substr($spl[4],0,-1); //# omit the % character

return $ret;
}
Expand All @@ -181,7 +181,7 @@ function get_used_space_remote() {
*/
function get_user_jobs($user) {
include "neurocloud/config.inc.php";
$basedir = sprintf($NC_CONFIG["local_exec_dir"],$user);
$basedir = sprintf($NC_CONFIG["local_exec_dir"], $user);
$jobs = array();
if (is_dir($basedir)) {
$dh = opendir($basedir);
Expand Down Expand Up @@ -410,25 +410,25 @@ function get_queue_info($qsub_jobname) {
*/

if ($xml->queue_info->job_list->count() == 0 && $xml->job_info->job_list->count() == 0) {
#$return_string = "No running SGE jobs in queue for job_id " . $qsub_jobname;
//#$return_string = "No running SGE jobs in queue for job_id " . $qsub_jobname;
return $return_string;
} else {
#$return_string = "Running SGE jobs:\n";
//#$return_string = "Running SGE jobs:\n";

foreach ($xml->queue_info->job_list as $job) {
// check if the SGE job name contains the generated job id for this neurocloud job
if (strpos($job->JB_name, $qsub_jobname)) {
#$return_string = $return_string . $job->JB_name . "\n";
//#$return_string = $return_string . $job->JB_name . "\n";
$return_string[1] = $return_string[1] + 1;
}
}

#$return_string = $return_string . "\nQueued SGE jobs:\n";
//#$return_string = $return_string . "\nQueued SGE jobs:\n";

foreach ($xml->job_info->job_list as $job) {
// check if the SGE job name contains the generated job id for this neurocloud job
if (strpos($job->JB_name, $qsub_jobname)) {
#$return_string = $return_string . $job->JB_name . "\n";
//#$return_string = $return_string . $job->JB_name . "\n";
$return_string[0] = $return_string[0] + 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public static function is_study_runnable($study) {
$array = PersistentMap::get_paths();
foreach(array_keys($array) as $key) {
if (strpos($key, $study) > 0) {
#$syncing = self::$SYNC_STATUS[$key];
//#$syncing = self::$SYNC_STATUS[$key];
$syncing = $array[$key];
if ($syncing) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
OC_Util::addStyle('neurocloud', "nc");
OC_Util::addScript("neurocloud", "admin");

$tmpl = new OC_Template( 'neurocloud', 'settings');
$tmpl = new OC_Template('neurocloud', 'settings');

return $tmpl->fetchPage();

Expand Down
4 changes: 2 additions & 2 deletions templates/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<tr>

<?php
# TODO: gli script con gli spazi nel nome non sono permessi, perché lanciandoli via SSH vengono parsati come due comandi
//# TODO: gli script con gli spazi nel nome non sono permessi, perché lanciandoli via SSH vengono parsati come due comandi
if (strpos($s, " ") !== false) {
?>

Expand All @@ -90,7 +90,7 @@
</td>
<td>
<?php
if (is_file(get_private_key_file(OC_User::getUser())) || $NC_CONFIG['default_exec_type'] === 'local') { # checking if the user can run scripts
if (is_file(get_private_key_file(OC_User::getUser())) || $NC_CONFIG['default_exec_type'] === 'local') { //# checking if the user can run scripts
?>
<span ><a href="<?php echo $exec_link ?>" title="Click to execute this script">Run</a></span>
&nbsp;
Expand Down
4 changes: 2 additions & 2 deletions templates/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ function get_public_key() {
</script>

<div class="personalblock">
<strong>Neurocloud users public keys</strong>
<strong>NeuroBox users public keys</strong>
<?php
/*
/**
$datadir = OC_Config::getValue("datadirectory");
$files = array();
$dh = opendir($datadir);
Expand Down