class Bicho::CLI::Commands::Attachments
Command
to display bug information.
Public Instance Methods
do(global_opts, opts, args)
click to toggle source
# File lib/bicho/cli/commands/attachments.rb, line 65 def do(global_opts, opts, args) client = ::Bicho::Client.new(global_opts[:bugzilla]) client.get_bugs(*args).each do |bug| if opts[:download] download(bug, opts[:supportconfig]) else t.say("Bug #{t.color(bug.id.to_s, :headline)} has #{bug.attachments.size} attachments") end end 0 end
Private Instance Methods
download(bug, supportconfig_only)
click to toggle source
check for supportconfigs and download
# File lib/bicho/cli/commands/attachments.rb, line 37 def download(bug, supportconfig_only) bug.attachments.each do |attachment| filename = "bsc#{bug.id}-#{attachment.id}-#{attachment.props['file_name']}" if supportconfig_only next unless attachment.content_type == 'application/x-gzip' || attachment.content_type == 'application/x-bzip-compressed-tar' next unless attachment.summary =~ /supportconfig/i end t.say("Downloading to #{t.color(filename, :even_row)}") begin data = attachment.data File.open(filename, 'w') do |f| f.write data.read end rescue StandardError => e t.say("#{t.color('Error:', :error)} Download of #{filename} failed: #{e}") raise end end end