Method: ArduinoCI::ArduinoDownloader#download
- Defined in:
- lib/arduino_ci/arduino_downloader.rb
#download ⇒ bool
Download the package_url to package_file
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/arduino_ci/arduino_downloader.rb', line 95 def download # Turned off ssl verification # This should be acceptable because it won't happen on a user's machine, just CI # define a progress-bar printer chunk_size = 1024 * 1024 * 1024 total_size = 0 dots = 0 dot_printer = lambda do |size| total_size += size needed_dots = (total_size / chunk_size).to_i unprinted_dots = needed_dots - dots @output.print("." * unprinted_dots) if unprinted_dots.positive? dots = needed_dots end URI.open(package_url, ssl_verify_mode: 0, progress_proc: dot_printer) do |url| File.open(package_file, 'wb') { |file| file.write(url.read) } end rescue Net::OpenTimeout, Net::ReadTimeout, OpenURI::HTTPError, URI::InvalidURIError => e @output.puts "\nArduino force-install failed downloading #{package_url}: #{e}" end |