]> git.donarmstrong.com Git - biopieces.git/commitdiff
corrected typo
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Sat, 26 Jun 2010 09:47:45 +0000 (09:47 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Sat, 26 Jun 2010 09:47:45 +0000 (09:47 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@995 74ccb610-7750-0410-82ae-013aeee3265d

LICENCE [deleted file]
LICENSE [new file with mode: 0644]
code_ruby/Maasha/lib/biopieces.rb

diff --git a/LICENCE b/LICENCE
deleted file mode 100644 (file)
index a52a6e5..0000000
--- a/LICENCE
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (C) 2007-2008 Martin A. Hansen.
-
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-# http://www.gnu.org/copyleft/gpl.html
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..a52a6e5
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,17 @@
+# Copyright (C) 2007-2008 Martin A. Hansen.
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# http://www.gnu.org/copyleft/gpl.html
index 46fb26b737f123364f44a025b4208b8fd82f9383..1dfb9fb2abe4f5fce5ceb1a5dc1511fe67de5272 100644 (file)
@@ -22,6 +22,7 @@ class Biopieces
     @output = output
     @status = Status.new
     @status.set unless @test
+    #prime_teardown
   end
 
   # Check the integrity of a list of casts, followed by parsion options from argv
@@ -81,35 +82,39 @@ class Biopieces
     path
   end
 
-  def do_at_exit
-    @in.close  if @in.respond_to?  :close
-    @out.close if @out.respond_to? :close
-
+  def prime_teardown
     exit_status = "OK"
 
-  rescue SignalException => exception
-    if exception.class.to_s.upcase =~ /INT/
-      exit_status = "INTERRUPTED"
-    elsif exception.to_s.upcase =~ /TERM/
-      exit_status = "TERMINATED"
-    elsif exception.to_s.upcase =~ /QUIT/
-      exit_status = "QUIT"
+    # Install signal handlers
+    %w( INT TERM QUIT ).each do |signal| 
+      Signal.trap(signal) do
+        exit_status = signal
+        exit
+      end
     end
 
-  rescue Exception => exception
-    exit_status = "DIED"
-
-  $stderr.puts exception
-  $stderr.puts exception.backtrace
+    at_exit do
+      begin
+        @in.close  if @in.respond_to?  :close
+        @out.close if @out.respond_to? :close
 
-  ensure
-    status = Status.new
-    FileUtils.remove_entry_secure(status.get_tmpdir)
-    status.log(exit_status)
-    status.delete
+      rescue Exception => exception
+        case exit_status
+        when 'INT'  then exit_status = 'INTERRUPTED'
+        when 'TERM' then exit_status = 'TERMINATED'
+        end
+        exit_status = "DIED" unless exit_status =~ /INT|TERM|QUIT/
+        $stderr.puts exit_status
+        $stderr.puts exception.backtrace
+
+      ensure
+        status = Status.new
+        FileUtils.remove_entry_secure(status.get_tmpdir)
+        status.log(exit_status)
+        status.delete
+      end
+    end
   end
-
-  at_exit {do_at_exit}
 end
 
 
@@ -614,4 +619,53 @@ class Stream < IO
 end
 
 
+# Stuff to be done at begin such as setting the exit status
+# and signal handlers
+def do_at_begin
+  status = Status.new
+  status.set
+  exit_status = "OK"
+
+  # Install signal handlers
+  %w( INT TERM QUIT ).each do |signal| 
+    Signal.trap(signal) do
+      exit_status = signal
+      exit
+    end
+  end
+
+  exit_status
+end
+
+# Make sure that file streams are closed, tmpdir removed, and
+# exit status is written to log file.
+def do_at_exit(exit_status)
+  at_exit do
+    begin
+      @in.close  if @in.respond_to?  :close
+      @out.close if @out.respond_to? :close
+    rescue Exception => exception
+      $stderr.puts "Exception caught!"   # DEBUG
+      case exit_status
+      when 'INT'  then exit_status = 'INTERRUPTED'
+      when 'TERM' then exit_status = 'TERMINATED'
+      end
+      exit_status = "DIED" unless exit_status =~ /INT|TERM|QUIT/
+      $stderr.puts exit_status
+      $stderr.puts exception.backtrace
+
+    ensure
+      status = Status.new
+      FileUtils.remove_entry_secure(status.get_tmpdir)
+      status.log(exit_status)
+      status.delete
+      puts "EXIT STATUS: #{exit_status}"
+    end
+  end
+end
+
+exit_status = do_at_begin
+do_at_exit(exit_status)
+
+
 __END__