Permalink
Browse files

finally this is ruby 1.9.2 compatible

  • Loading branch information...
1 parent a2629c1 commit d0b1cb994cba569e1aba3162f2d1ba480aa146ac @gr4y committed Jan 23, 2011
Showing with 17 additions and 13 deletions.
  1. +16 −12 hs_encoder.rb
  2. +1 −1 hs_transfer.rb
View
@@ -22,6 +22,7 @@
require 'fileutils'
require 'open3'
+
class HSEncoder
class CommandExecutionException < ::StandardError; end
@@ -57,18 +58,18 @@ def stop_encoding
private
def process_master_encoding(encoding_pipes)
- command = "#{@config['source_command']} #{@config['input_location']}"
+ command = @config['source_command'] % [@config['input_location']]
@log.debug("Executing: #{command}")
stderr_thread = nil
-
- Open3.popen3(command) do |stdin, stdout, stderr|
+ exit_code = -1
+ Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
@stop_stdin = stdin
stderr_thread = Thread.new do
stderr.each("\r") do |line|
if line =~ /ffmpeg/i
- @log.debug("Master encoder: #{line}")
+ @log.info("Master encoder: #{line}")
end
if line =~ /error/i
@@ -83,23 +84,25 @@ def process_master_encoding(encoding_pipes)
out.print output
end
end
+ exit_code = wait_thr.value.exitstatus
end
stderr_thread.join
- @log.debug("Return code from master encoding: #{$?}")
-
+ @log.info("Return code from master encoding: #{exit_code}")
+
encoding_pipes.each do |out|
out.close
end
- raise CommandExecutionException if $?.nil?
+ raise CommandExecutionException if exit_code != 0
end
def execute_ffmpeg_and_segmenter(command, encoding_profile, encoding_pipes)
@log.debug("Executing: #{command}")
- Open3.popen3(command) do |stdin, stdout, stderr|
+ exit_code = -1
+ Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
if encoding_pipes != nil
encoding_pipes << stdin
else
@@ -120,11 +123,12 @@ def execute_ffmpeg_and_segmenter(command, encoding_profile, encoding_pipes)
@log.error("Encoder #{encoding_profile}: #{line}")
end
end
+ exit_code = wait_thr.value.exitstatus
end
- @log.debug("Return code from #{encoding_profile}: #{$?}")
-
- raise CommandExecutionException if $?.nil?
+ @log.debug("Return code from #{encoding_profile}: #{exit_code}")
+
+ raise CommandExecutionException if exit_code != 0
end
def process_encoding(encoding_profile, input_location, encoding_pipes)
@@ -163,7 +167,7 @@ def run_multirate_encoding( encoding_threads )
begin
process_master_encoding(encoding_pipes)
rescue
- @log.error("Master encoding error: #{$!}")
+ @log.error("Master encoding error: #{$!}: #{$@}")
encoding_pipes.each do |out|
begin
View
@@ -58,7 +58,7 @@ def start_transfer_thread
begin
create_index_and_run_transfer(value)
rescue
- @log.error("Error running transfer: #{$!}")
+ @log.error("Error running transfer: #{$!}: #{$@}")
end
end

0 comments on commit d0b1cb9

Please sign in to comment.