1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#
# bts.rb - ruby interface for debian bts
# Copyright (C) 2002 Masato Taruishi <taru@debian.org>
# Copyright (C) 2006-2007 Junichi Uekawa <dancer@debian.org>
# Copyright (C) 2013-2014 Francesco Poli <invernomuto@paranoici.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Currently, this interface has only acquires to create bugs.
require 'debian/bug'
require 'net/http'
require 'uri.rb'
require 'find'
require 'zlib'
require 'thread'
module Debian
module BTS
class Parser
def initialize(host, port)
@host = host
@port = port
end
# use SOAP interface to obtain the index.
class SoapIndex < Parser
def initialize(host, port)
@host = host
@port = port
@indexes = {}
@buf = nil
end
def parse_bug(bugnum)
require 'debian/btssoap'
soap = Debian::BTSSOAP::Soap.new(@host, @port)
sa = Debian::BTSSOAP::StringArray.new
# query the BTS about the given bug number
sa << bugnum
bugs = soap.get_status(sa)
bugs.fetch(0, "# ???")
end
def parse(ma_copies, parsestep, severities = ["critical", "grave"])
require 'debian/btssoap'
soap = Debian::BTSSOAP::Soap.new(@host, @port)
sa = Debian::BTSSOAP::StringArray.new
bugs = Debian::Bugs.new
# obtain a list of package names
names = ma_copies.keys
# query the BTS: ask for a list of bug numbers of given severities
# affecting the given package names
reqbugs = soap.get_bugs('severity', severities, 'package', names)
# the total number of bugs
max = reqbugs.length
# progressed amount
offset_i = 0
# process each bug number and get contents, in batches of
# parsestep bugs
reqbugs.each { |bug|
sa << bug
if sa.length > parsestep
soap.get_status(sa, ma_copies).each { |b| bugs << b }
offset_i += sa.length
sa = Debian::BTSSOAP::StringArray.new
pct = "#{((offset_i).to_f*100/max.to_f).to_i}%"
pct = "#{pct} ##{bug}" if parsestep == 1
yield pct
end
}
soap.get_status(sa, ma_copies).each { |b| bugs << b }
bugs
end
end
end
end
end
|