if STDIN.tty?
input = self.new(StringIO.new)
else
- input = self.new(STDIN, stdio = true)
+ input = self.new(STDIN, true)
end
elsif File.exists? input
- ios = File.open(input, mode='r')
+ ios = File.open(input, 'r')
begin
ios = Zlib::GzipReader.new(ios)
# Records are written to STDOUT (default) or file.
def self.open_output(output)
if output.nil?
- output = self.new(STDOUT, stdio = true)
+ output = self.new(STDOUT, true)
elsif not output.is_a? IO
- output = self.new(File.open(output, mode='w'))
+ output = self.new(File.open(output, 'w'))
end
output
option_parser.parse!(@argv)
if print_usage_full?
- print_usage_and_exit(full=true)
+ print_usage_and_exit(true)
elsif print_usage_short?
print_usage_and_exit
end
def set
time0 = Time.new.strftime("%Y-%m-%d %X")
- File.open(path, mode="w") do |fh|
+ File.open(path, "w") do |fh|
fh.puts [time0, ARGV.join(" ")].join(";")
end
end
def set_tmpdir(tmpdir_path)
status = ""
- File.open(path, mode="r") do |fh|
+ File.open(path, "r") do |fh|
status = fh.read.chomp
end
status = "#{status};#{tmpdir_path}\n"
- File.open(path, mode="w") do |fh|
+ File.open(path, "w") do |fh|
fh << status
end
end
# Extract the temporary directory path from the status file,
# and return this or nil if not found.
def get_tmpdir
- File.open(path, mode="r") do |fh|
+ File.open(path, "r") do |fh|
tmpdir_path = fh.read.chomp.split(";").last
return tmpdir_path if File.directory?(tmpdir_path)
end
script = File.basename($0)
stream = File.open(path)
- time0, args, tmp_dir = stream.first.split(";")
+ time0, args = stream.first.split(";")
stream.close
elap = time_diff(time0, time1)
command = [script, args].join(" ")
log_file = File.join(ENV["BP_LOG"], "biopieces.log")
- File.open(log_file, mode = "a") { |file| file.puts [time0, time1, elap, user, exit_status, command].join("\t") }
+ File.open(log_file, "a") { |file| file.puts [time0, time1, elap, user, exit_status, command].join("\t") }
end
# Delete status file.
script = File.basename($0)
pid = $$
path = File.join(ENV["BP_TMP"], [user, script, pid, "status"].join("."))
+
+ path
end
# Get the elapsed time from the difference between two time stamps.