bin/tracksperanto in tracksperanto-1.9.2 vs bin/tracksperanto in tracksperanto-1.9.3
- old
+ new
@@ -3,29 +3,41 @@
#
# Translate a 2D track file from a single format to many others
#
# == Usage
#
-# tracksperanto -f ShakeScript /Films/Blockbuster/Shots/001/script.shk -w 1920 -h 1080
+# tracksperanto -f ShakeScript -w 1920 -h 1080 /Films/Blockbuster/Shots/001/script.shk
#
# == Author
# Julik <me@julik.nl>
-require File.dirname(__FILE__) + '/../lib/tracksperanto'
+require File.dirname(__FILE__) + '/../lib/tracksperanto' unless defined?(Tracksperanto)
require 'optparse'
require 'rubygems'
require 'progressbar'
+require "net/http"
+require "open-uri"
+require "timeout"
-# Sane defaults
-reader_klass_name = nil
-width = nil
-height = nil
+def version_check
+ Timeout::timeout(2) do
+ begin
+ version_info = open("http://rubygems.org/api/v1/gems/tracksperanto.xml").string.scan(/<version>(.+)<\/version>/).to_s
+ int_available, int_present = [version_info, Tracksperanto::VERSION].map{|v| v.scan(/(\d+)/).to_s.to_i }
+ if int_available > int_present
+ puts "Your version of Tracksperanto is probably out of date (the current version is #{version_info}, but you have #{Tracksperanto::VERSION})."
+ puts "Please consider updating (run 'gem update tracksperanto')"
+ end
+ rescue OpenURI::HTTPError => e
+ end
+ end
+end
options = {}
+$notice = "Please consider a small donation to keep Tracksperanto going. http://guerilla-di.org/source-and-license/"
$middlewares = []
writer_klass_name = nil
-reader_name = "ShakeScript"
readers = Tracksperanto.importer_names
writers = Tracksperanto.exporter_names
op = OptionParser.new
@@ -54,37 +66,37 @@
op.on("--version", "Show the version and exit") do |v|
puts "Tracksperanto v.#{Tracksperanto::VERSION} running on Ruby #{RUBY_VERSION} on #{RUBY_PLATFORM}"
puts "Copyright 2008-#{Time.now.year} by Guerilla-DI (Julik Tarkhanov and contributors)"
puts "For questions and support contact info#{64.chr}guerilla-di.org"
+ puts $notice
+ version_check()
exit(0)
end
begin
op.parse!
rescue OptionParser::MissingArgument => e
- STDERR.puts "Unknown argument: #{e.message}"
+ $stderr.puts "Unknown argument: #{e.message}"
puts parser
exit(-1)
end
input_file = ARGV.pop
-if !input_file
- STDERR.puts "No input file provided - should be the last argument. Also use the --help option."
+unless input_file
+ $stderr.puts "No input file provided - should be the last argument. Also use the --help option."
exit(-1)
end
-pbar = ProgressBar.new("Converting", 100)
-pipe = Tracksperanto::Pipeline::Base.new(:progress_block => lambda{|p,m| pbar.set(p.to_i) }, :middleware_tuples => $middlewares)
-
-if writer_klass_name
- begin
- pipe.exporters = [Tracksperanto.get_exporter(writer_klass_name)]
- rescue NameError
- STDERR.puts "Unknown exporter #{writer_klass_name}. Available exporters: #{writers.join(", ")}"
- exit(-1)
- end
+unless File.exist?(input_file)
+ $stderr.puts "Input file #{input_file} does not exist"
+ exit(-1)
end
+pbar = ProgressBar.new("Converting", 100, $stderr)
+pipe = Tracksperanto::Pipeline::Base.new(:progress_block => lambda{|p,m| pbar.set(p) }, :middleware_tuples => $middlewares)
+pipe.exporters = [Tracksperanto.get_exporter(writer_klass_name)] if writer_klass_name
pipe.run(input_file, options)
pbar.finish
-puts ("Converted #{pipe.converted_points} trackers with #{pipe.converted_keyframes} keys")
+
+puts "Converted #{pipe.converted_points} trackers with #{pipe.converted_keyframes} keys. #{$notice}"
+version_check()
\ No newline at end of file