]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixing status
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Sat, 6 Jun 2009 15:22:43 +0000 (15:22 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Sat, 6 Jun 2009 15:22:43 +0000 (15:22 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@486 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/split_vals
code_perl/Maasha/Biopieces.pm
code_perl/Maasha/Common.pm

index bdd8104bf5855e6c0ff6f0bfd55af7b034cd146e..f7249f864d9332d84f8ba6cde82617827eb35dbd 100755 (executable)
@@ -33,7 +33,7 @@ use Maasha::Biopieces;
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, @vals, $i );
+my ( $options, $in, $out, $record, @vals, $i );
 
 $options = Maasha::Biopieces::parse_options(
     [
@@ -68,26 +68,22 @@ while ( $record = Maasha::Biopieces::get_record( $in ) )
     Maasha::Biopieces::put_record( $record, $out );
 }
 
+Maasha::Biopieces::close_stream( $in );
+Maasha::Biopieces::close_stream( $out );
+
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
 BEGIN
 {
-    $run_time_beg = Maasha::Biopieces::run_time();
-
-    Maasha::Biopieces::log_biopiece();
+    Maasha::Biopieces::status_set();
 }
 
 
 END
 {
-    Maasha::Biopieces::close_stream( $in );
-    Maasha::Biopieces::close_stream( $out );
-
-    $run_time_end = Maasha::Biopieces::run_time();
-
-    Maasha::Biopieces::run_time_print( $run_time_beg, $run_time_end, $options );
+    Maasha::Biopieces::status_log();
 }
 
 
index 44369a8ad626b4a373c389cf498e64b32df1caa6..414c630a44a74763a0943258a32efdc13da2fcbc 100644 (file)
@@ -56,6 +56,59 @@ $SIG{ 'INT' }     = \&sig_handler;
 $SIG{ 'TERM' }    = \&sig_handler;
 
 
+sub status_set
+{
+    my ( $time_stamp, $script, $user, $pid, $file, $fh );
+
+    $time_stamp = Maasha::Common::time_stamp();
+    $user       = Maasha::Common::get_user();
+    $script     = Maasha::Common::get_scriptname();
+    $pid        = Maasha::Common::get_processid();
+
+    $file = "$ENV{ 'BP_TMP' }/" . join( ".", $user, $script, $pid ) . ".status";
+    $fh   = Maasha::Filesys::file_write_open( $file );
+
+    print $fh join( ";", $time_stamp, join( " ", @ARGV ) ) . "\n";
+
+    close $fh;
+}
+
+
+sub status_log
+{
+    my ( $time0, $time1, $script, $user, $pid, $file, $fh, $elap, $fh_global, $fh_local, $line, $args );
+
+    $time1      = Maasha::Common::time_stamp();
+    $user       = Maasha::Common::get_user();
+    $script     = Maasha::Common::get_scriptname();
+    $pid        = Maasha::Common::get_processid();
+
+    $file = "$ENV{ 'BP_TMP' }/" . join( ".", $user, $script, $pid ) . ".status";
+    $fh   = Maasha::Filesys::file_read_open( $file );
+    $line = <$fh>;
+    chomp $line;
+    close $fh;
+
+    unlink $file;
+
+    ( $time0, $args ) = split /;/, $line;
+
+    $elap = Maasha::Common::time_stamp_diff( $time0, $time1 );
+
+    $fh_global  = Maasha::Filesys::file_append_open( "$ENV{ 'BP_LOG' }/biopieces.log" );
+    $fh_local   = Maasha::Filesys::file_append_open( "$ENV{ 'HOME' }/.biopieces.log" );
+
+    print $fh_global join( "\t", $time0, $time1, $elap, $user, $script, $args ) . "\n";
+    print $fh_local  join( "\t", $time0, $time1, $elap, $user, "$script $args" ) . "\n";
+
+    $fh_global->autoflush( 1 );
+    $fh_local->autoflush( 1 );
+
+    close $fh_global;
+    close $fh_local;
+}
+
+
 sub log_biopiece
 {
     # Martin A. Hansen, January 2008.
index d998d80299f011bc7843a2ee69ed82246c1a1f47..83c963301942ff9e01a27e4f3a624c22f9b142e6 100644 (file)
@@ -601,6 +601,51 @@ sub time_stamp
 }
 
 
+sub time_stamp_diff
+{
+    # Martin A. Hansen, June 2009.
+
+    # Return the difference between two time stamps in
+    # the time stamp format.
+
+    my ( $t0,   # time stamp 0
+         $t1,   # time stamp 1
+       ) = @_;
+
+    # Returns a time stamp string.
+
+    my ( $year0, $mon0, $day0, $hour0, $min0, $sec0,
+         $year1, $mon1, $day1, $hour1, $min1, $sec1,
+         $year,  $mon,  $day,  $hour,  $min,  $sec );
+
+    $t0 =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/;
+    $year0 = $1;
+    $mon0  = $2;
+    $day0  = $3;
+    $hour0 = $4;
+    $min0  = $5;
+    $sec0  = $6;
+
+    $t1 =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/;
+    $year1 = $1;
+    $mon1  = $2;
+    $day1  = $3;
+    $hour1 = $4;
+    $min1  = $5;
+    $sec1  = $6;
+
+    $year = $year1 - $year0;
+    $mon  = $mon1  - $mon0;
+    $day  = $day1  - $day0; 
+    $hour = $hour1 - $hour0;
+    $min  = $min1  - $min0;
+    $sec  = $sec1  - $sec0;
+
+    #return "$year-$mon-$day $hour:$min:$sec";
+    return join( ":", sprintf( "%02d", $hour ), sprintf( "%02d", $min ), sprintf( "%02d", $sec ) );
+}
+
+
 sub process_running
 {
     # Martin A. Hansen, July 2008.