require 'open3'
require 'pp'
-
# Biopieces are command line scripts and uses OptionParser to parse command line
# options according to a list of casts. Each cast prescribes the long and short
# name of the option, the type, if it is mandatory, the default value, and allowed
path
end
- at_exit {
- $stderr.puts "All done, time to make sure to close streams, remove tmpdir, and log entry."
-
+ at_exit do
@in.close if @in.respond_to? :close
@out.close if @out.respond_to? :close
- FileUtils.remove_entry_secure(@status.get_tmpdir)
- @status.log
- @status.delete
- }
+
+ status = Status.new
+ FileUtils.remove_entry_secure(status.get_tmpdir)
+
+ status.log(@exit_status)
+ status.delete
+ end
end
end
# Write the Biopiece status to the log file.
- def log(status="OK")
+ def log(exit_status)
time1 = Time.new.strftime("%Y-%m-%d %X")
user = ENV["USER"]
script = File.basename($0, ".rb")
command = [script, args].join(" ")
log_file = ENV["BP_LOG"] + "/biopieces.log"
- File.open(log_file, mode="a") { |file| file.puts [time0, time1, elap, user, status, command].join("\t") }
+ File.open(log_file, mode="a") { |file| file.puts [time0, time1, elap, user, exit_status, command].join("\t") }
end
# Delete status file.
end
end
+
__END__