[Apt-listbugs-commits] [apt-listbugs] 01/02: add QueryStep option and retry one pkg at a time

Francesco Poli frx-guest at moszumanska.debian.org
Fri Aug 14 09:52:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

frx-guest pushed a commit to branch master
in repository apt-listbugs.

commit a2b47ff9247cb3c73ec061857fd4465e1b4af8bc
Author: Francesco Poli (wintermute) <invernomuto at paranoici.org>
Date:   Tue Aug 11 00:01:13 2015 +0200

    add QueryStep option and retry one pkg at a time
---
 bin/apt-listbugs              |  8 ++++++++
 debian/changelog              |  8 ++++++++
 lib/aptlistbugs/debian/bts.rb | 22 ++++++++++++++++++----
 lib/aptlistbugs/logic.rb      | 13 +++++++++++--
 4 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/bin/apt-listbugs b/bin/apt-listbugs
index ae8f558..cbc1b43 100755
--- a/bin/apt-listbugs
+++ b/bin/apt-listbugs
@@ -236,6 +236,14 @@ notable configuration options are
   nothing. A possible suggested value is "FTBFS", since those bugs tend
   to not affect the user.
 
+: AptListbugs::QueryStep
+
+  Maximum number of packages to be queried (on the Debian Bug Tracking
+  System) in a single batch. Default value is 200. The query operation is
+  performed in batches of at most QueryStep packages, for performance
+  reasons; setting a lower value may slow down apt-listbugs, but may
+  increase reliability on poor network links.
+
 : AptListbugs::ParseStep
 
   Maximum number of bug reports to be queried (on the Debian Bug Tracking
diff --git a/debian/changelog b/debian/changelog
index 5d05acb..be45d91 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+apt-listbugs (0.1.18) UNRELEASED; urgency=medium
+
+  * added QueryStep configuration option; on network errors, apt-listbugs
+    now proposes to the user to retry one package at a time (as well as
+    one bug report at a time)
+
+ -- Francesco Poli (wintermute) <invernomuto at paranoici.org>  Mon, 10 Aug 2015 22:42:49 +0200
+
 apt-listbugs (0.1.17) unstable; urgency=medium
 
   * fixed "Does not uses proxy from Acquire::http::ProxyAutoDetect":
diff --git a/lib/aptlistbugs/debian/bts.rb b/lib/aptlistbugs/debian/bts.rb
index 5b31d1b..4f43c6f 100644
--- a/lib/aptlistbugs/debian/bts.rb
+++ b/lib/aptlistbugs/debian/bts.rb
@@ -2,7 +2,7 @@
 # bts.rb - ruby interface for debian bts
 # Copyright (C) 2002       Masato Taruishi <taru at debian.org>
 # Copyright (C) 2006-2007  Junichi Uekawa <dancer at debian.org>
-# Copyright (C) 2013-2014  Francesco Poli <invernomuto at paranoici.org>
+# Copyright (C) 2013-2015  Francesco Poli <invernomuto at 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
@@ -56,18 +56,32 @@ module Debian
           bugs.fetch(0, "# ???")
         end
 
-        def parse(ma_copies, parsestep, severities = ["critical", "grave"])
+        def parse(ma_copies, querystep, parsestep, severities = ["critical", "grave"])
           require 'aptlistbugs/debian/btssoap'
           soap = Debian::BTSSOAP::Soap.new(@host, @port)
           sa = Debian::BTSSOAP::StringArray.new
           bugs = Debian::Bugs.new
+          reqbugs = []
 
           # 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)
+          # affecting the given package names, in batches of querystep
+          # packages
+          names.each { |nm|
+            sa << nm
+            if sa.length >= querystep
+              soap.get_bugs('severity', severities,
+                             'package', sa).each { |b| reqbugs << b }
+              sa = Debian::BTSSOAP::StringArray.new
+            end
+          }
+          if sa.length != 0
+            soap.get_bugs('severity', severities,
+                           'package', sa).each { |b| reqbugs << b }
+            sa = Debian::BTSSOAP::StringArray.new
+          end
 
           # the total number of bugs
           max = reqbugs.length
diff --git a/lib/aptlistbugs/logic.rb b/lib/aptlistbugs/logic.rb
index 1e42891..a5c3356 100644
--- a/lib/aptlistbugs/logic.rb
+++ b/lib/aptlistbugs/logic.rb
@@ -89,6 +89,7 @@ class AppConfig
     @show_downgrade = false
     @hostname = "bugs.debian.org"
     @port = 80
+    @querystep = 200
     @parsestep = 200
     @quiet = false
     @command = nil
@@ -114,7 +115,7 @@ class AppConfig
   end
 
   attr_accessor :severity, :stats, :quiet, :title
-  attr_accessor :show_downgrade, :hostname, :tag, :fbugs, :parsestep
+  attr_accessor :show_downgrade, :hostname, :tag, :fbugs, :querystep, :parsestep
   attr_accessor :frontend, :pin_priority, :yes, :ignore_regexp, :force_pin
   attr_reader :command, :parser, :querybts, :ignore_bugs, :system_ignore_bugs, :browser, :arrow
 
@@ -128,6 +129,10 @@ class AppConfig
       end
     end
 
+    if /qb='(.*)'/ =~ `apt-config #{@apt_conf} shell qb AptListbugs::QueryStep`
+      @querystep = $1.to_i if $1.to_i > 0
+    end
+
     if /qb='(.*)'/ =~ `apt-config #{@apt_conf} shell qb AptListbugs::ParseStep`
       @parsestep = $1.to_i if $1.to_i > 0
     end
@@ -916,9 +921,10 @@ module Factory
       # TRANSLATORS: this sentence, followed by the translation of "Done" (see above) should fit in less than 79 columns to work well with default width terminals
       yield _("Retrieving bug reports..."), "0%"
       begin
+        config.frontend.puts " Using QueryStep = #{config.querystep}" if $DEBUG
         config.frontend.puts " Using ParseStep = #{config.parsestep}" if $DEBUG
         # obtain the array of bugs
-        bugs = config.parser.parse(ma_copies, config.parsestep, config.severity) { |pct|
+        bugs = config.parser.parse(ma_copies, config.querystep, config.parsestep, config.severity) { |pct|
           yield _("Retrieving bug reports..."), pct
         }
       rescue SOAP::HTTPStreamError => exception
@@ -927,6 +933,7 @@ module Factory
         $stderr.puts _("E: ") + _("HTTP GET failed")
         retrycount -= 1
         if config.frontend.yes_or_no?(_("Retry downloading bug information?")) && retrycount > 0
+          config.querystep = 1 if config.querystep != 1 && config.frontend.yes_or_no?(_("One package at a time?"))
           config.parsestep = 1 if config.parsestep != 1 && config.frontend.yes_or_no?(_("One bug report at a time?"))
           retry
         end
@@ -938,6 +945,7 @@ module Factory
         $stderr.puts _("E: ") + _("Empty stream from SOAP")
         retrycount -= 1
         if config.frontend.yes_or_no?(_("Retry downloading bug information?")) && retrycount > 0
+          config.querystep = 1 if config.querystep != 1 && config.frontend.yes_or_no?(_("One package at a time?"))
           config.parsestep = 1 if config.parsestep != 1 && config.frontend.yes_or_no?(_("One bug report at a time?"))
           retry
         end
@@ -955,6 +963,7 @@ module Factory
         end
         retrycount -= 1
         if config.frontend.yes_or_no?(_("Retry downloading bug information?")) && retrycount > 0
+          config.querystep = 1 if config.querystep != 1 && config.frontend.yes_or_no?(_("One package at a time?"))
           config.parsestep = 1 if config.parsestep != 1 && config.frontend.yes_or_no?(_("One bug report at a time?"))
           retry
         end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/apt-listbugs/apt-listbugs.git



More information about the Apt-listbugs-commits mailing list