def download(build_set)
to_download = []
if build_set.size == 1
to_download << build_set.first
else
to_download = choose do |menu|
menu.choices *build_set do |i| [i] end
menu.choice("All of them.") { build_set }
menu.choice("None.") { exit 0 }
menu.prompt = "Which appliance do you want to download?"
end
end
to_download.each do |b|
puts "Going to download #{b.to_s}"
d = Downloader.new(b.download_url.sub("https:", "http:"),"Downloading")
if File.exists? d.filename
if @shell.no?("Do you want to overwrite file #{d.filename}? (y/n)")
exit 0
end
end
begin
d.start
Utils::execute_printing_progress "Calculating md5sum" do
digest = Digest::MD5.file d.filename
raise "digest check not passed" if digest.to_s != b.checksum.md5
end
rescue
STDOUT.puts
STDERR.puts
STDERR.flush
STDERR.puts $!
exit 1
end
end
end