Parcourir la source

Removed repetitive date printing and made some formatting fixes.

Lacey Sanderson il y a 8 ans
Parent
commit
5f840f3092

+ 10 - 10
tripal_core/api/tripal_core.jobs.api.inc

@@ -276,11 +276,11 @@ function tripal_max_jobs_exceeded($max_jobs) {
     // No limit on concurrent jobs
     return FALSE;
   }
-  
+
   $num_jobs_running = 0;
-  
-  // Iterate through each job that has not ended and see if it is still running. 
-  // If it is not running but does not have an end_time then set the end time  
+
+  // Iterate through each job that has not ended and see if it is still running.
+  // If it is not running but does not have an end_time then set the end time
   // and set the status to 'Error'
   $sql =  "SELECT * FROM {tripal_jobs} TJ " .
           "WHERE TJ.end_time IS NULL and NOT TJ.start_time IS NULL ";
@@ -430,12 +430,12 @@ function tripal_launch_job($do_parallel = 0, $job_id = NULL, $max_jobs = -1, $si
   // if they are, don't continue, we don't want to have
   // more than one job script running at a time
   if (!$do_parallel and tripal_is_job_running()) {
-    print date('Y-m-d H:i:s') .": Jobs are still running. Use the --parallel=1 option with the Drush command to run jobs in parallel.";
+    print "Jobs are still running. Use the --parallel=1 option with the Drush command to run jobs in parallel.";
     return;
   }
 
   if ($do_parallel && tripal_max_jobs_exceeded($max_jobs)) {
-    print date('Y-m-d H:i:s') .": More than $max_jobs jobs are still running. At least one of these jobs much complete before a new job can start.";
+    print "More than $max_jobs jobs are still running. At least one of these jobs much complete before a new job can start.";
     return;
   }
 
@@ -453,8 +453,8 @@ function tripal_launch_job($do_parallel = 0, $job_id = NULL, $max_jobs = -1, $si
             "ORDER BY priority ASC,job_id ASC";
     $job_res = db_query($sql);
   }
-  print date('Y-m-d H:i:s') .": There are " . $job_res->rowCount() . " jobs queued.\n";
-  
+  print "There are " . $job_res->rowCount() . " jobs queued.\n";
+
   foreach ($job_res as $job) {
     // set the start time for this job
     $record = new stdClass();
@@ -495,7 +495,7 @@ function tripal_launch_job($do_parallel = 0, $job_id = NULL, $max_jobs = -1, $si
       }
     }
 
-    print date('Y-m-d H:i:s') .": Calling: $callback(" . implode(", ", $string_args) . ")\n";
+    print "Calling: $callback(" . implode(", ", $string_args) . ")\n";
     call_user_func_array($callback, $args);
     // set the end time for this job
     $record->end_time = REQUEST_TIME;
@@ -510,7 +510,7 @@ function tripal_launch_job($do_parallel = 0, $job_id = NULL, $max_jobs = -1, $si
     if (tripal_max_jobs_exceeded($max_jobs)) {
       break;
     }
-    
+
     // send an email to the user advising that the job has finished
   }
 }

+ 5 - 8
tripal_core/tripal_core.drush.inc

@@ -278,7 +278,6 @@ function drush_tripal_core_set_user($username) {
     $results = db_query($sql, array(':name' => $username));
     $u = $results->fetchObject();
     if (!$u) {
-      drush_print(date('Y-m-d H:i:s'));
       drush_print('ERROR: Please provide a valid username (--username argument) for running this job.');
       exit;
     }
@@ -287,7 +286,6 @@ function drush_tripal_core_set_user($username) {
     return $u->uid;
   }
   else {
-    drush_print(date('Y-m-d H:i:s'));
     drush_print('ERROR: Please provide a username (--username argument) for running this job.');
     exit;
   }
@@ -325,7 +323,7 @@ function drush_tripal_core_trp_run_jobs() {
 
   drush_tripal_core_set_user($username);
 
-  drush_print("/n" . date('Y-m-d H:i:s'));
+  drush_print("\n" . date('Y-m-d H:i:s'));
   if ($parallel) {
     drush_print("Tripal Job Launcher (in parallel)");
     drush_print("Running as user '$username'");
@@ -384,7 +382,7 @@ function drush_tripal_core_trp_rerun_job() {
   // --username argument for the fture.
   $user = drush_get_option('user');
   $uname = drush_get_option('username');
-  print date('Y-m-d H:i:s') . ": USER: '$user', UNAME: '$uname'\n";
+  print "USER: '$user', USERNAME: '$uname'\n";
   if ($user and is_numeric($user)) {
   }
   elseif ($user) {
@@ -403,7 +401,7 @@ function drush_tripal_core_trp_rerun_job() {
   drush_tripal_core_set_user($username);
   $new_job_id = tripal_rerun_job($job_id, FALSE);
 
-  drush_print("/n" . date('Y-m-d H:i:s'));
+  drush_print("\n" . date('Y-m-d H:i:s'));
   if ($parallel) {
     drush_print("Tripal Job Launcher (in parallel)");
     drush_print("Running as user '$username'");
@@ -459,12 +457,11 @@ function drush_tripal_core_trp_get_currjob() {
         "Module: " . $job->modulename . "\n" .
         "Callback: " . $job->callback . "\n" .
         "Process ID: " . $job->pid . "\n" .
-        "Progress: " . $job->progress . "%\n";
-    drush_print(date('Y-m-d H:i:s'));
+        "Progress: " . $job->progress . "%\n".
+        "Current Date: " . date('Y-m-d H:i:s') . "\n";
     drush_print($output);
   }
   if (!$job_pid) {
-    drush_print(date('Y-m-d H:i:s'));
     drush_print('There are currently no running jobs.');
   }
   //log to the command line with an OK status

+ 1 - 1
tripal_core/tripal_launch_job.php

@@ -49,7 +49,7 @@ if (!$u) {
 global $user;
 $user = user_load($u->uid);
 
-fwrite($stdout, date('Y-m-d' H:i:s) . "\n");
+fwrite($stdout, "\n" . date('Y-m-d' H:i:s) . "\n");
 fwrite($stdout, "Tripal Job Launcher\n");
 fwrite($stdout, "Running as user ' . $username . '\n");
 fwrite($stdout, "-------------------\n");