[Reportbug-commits] [reportbug] 03/03: in case of an error accessing the BTS, throw a new exception, and catch it in the main program, and display a message about it

Sandro Tosi morph at moszumanska.debian.org
Sat Aug 29 20:49:37 UTC 2015


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

morph pushed a commit to branch master
in repository reportbug.

commit 4ece52c2a2f16ee912523aa77f815496ebda03e9
Author: Sandro Tosi <morph at debian.org>
Date:   Sat Aug 29 21:49:26 2015 +0100

    in case of an error accessing the BTS, throw a new exception, and catch it in the main program, and display a message about it
---
 bin/reportbug           | 4 +++-
 debian/changelog        | 5 ++++-
 reportbug/debbugs.py    | 8 ++++++--
 reportbug/exceptions.py | 4 ++++
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/bin/reportbug b/bin/reportbug
index c5b5345..58fd9d9 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -56,7 +56,7 @@ from reportbug.tempfiles import (
     )
 from reportbug.exceptions import (
     UINotImportable, UINotImplemented,
-    NoNetwork, NoPackage, NoBugs, NoReport,
+    NoNetwork, NoPackage, NoBugs, NoReport, QuertBTSError,
     )
 from reportbug import submit
 from reportbug import checkversions
@@ -1739,6 +1739,8 @@ class UI(object):
                 else:
                     ewrite('Nothing new to report; exiting.\n')
                 return
+            except QuertBTSError:
+                ewrite('Error accessing the BTS, no bugs information available.\n')
 
             if self.options.queryonly and not exinfo:
                 return
diff --git a/debian/changelog b/debian/changelog
index 40cb991..302fff2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,8 +6,11 @@ reportbug (6.6.5) UNRELEASED; urgency=medium
   * debian/control
     - set dep on python-debianbts to the version implementing the paged access
       to BTS; Closes: #796759
+  * bin/reportbug, reportbug/{debbugs.py, exceptions.py}
+    - in case of an error accessing the BTS, throw a new exception, and catch it
+      in the main program, and display a message about it
 
- -- Sandro Tosi <morph at debian.org>  Sat, 29 Aug 2015 21:46:46 +0100
+ -- Sandro Tosi <morph at debian.org>  Sat, 29 Aug 2015 21:48:09 +0100
 
 reportbug (6.6.4) unstable; urgency=medium
 
diff --git a/reportbug/debbugs.py b/reportbug/debbugs.py
index 272a651..3efab9e 100644
--- a/reportbug/debbugs.py
+++ b/reportbug/debbugs.py
@@ -43,6 +43,7 @@ from collections import defaultdict
 import checkversions
 from exceptions import (
     NoNetwork,
+    QuertBTSError,
     )
 from urlutils import open_url
 
@@ -1285,8 +1286,11 @@ def get_reports(package, timeout, system='debian', mirrors=None, version=None,
         else:
             bugs = map(int, package)
 
-        # retrieve bugs and generate the hierarchy
-        stats = debianbts.get_status(bugs)
+        try:
+            # retrieve bugs and generate the hierarchy
+            stats = debianbts.get_status(bugs)
+        except:
+            raise QuertBTSError
 
         d = defaultdict(list)
         for s in stats:
diff --git a/reportbug/exceptions.py b/reportbug/exceptions.py
index 9a28117..51e2c42 100644
--- a/reportbug/exceptions.py
+++ b/reportbug/exceptions.py
@@ -57,3 +57,7 @@ class InvalidRegex(reportbug_exception):
 # Lame empty exception used later to save some coding
 class NoMessage(reportbug_exception):
     pass
+
+# There was a problem accessing BTS
+class QuertBTSError(reportbug_exception):
+    pass
\ No newline at end of file

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



More information about the Reportbug-commits mailing list