Catch osc exceptions in obs.py:get_projects
authorEd Bartosh <eduard.bartosh@intel.com>
Mon, 17 Mar 2014 13:33:17 +0000 (15:33 +0200)
committerEduard Bartosh <eduard.bartosh@intel.com>
Mon, 17 Mar 2014 20:22:10 +0000 (22:22 +0200)
Catch OSCError exceptions and raises RepaException with the meaningful
error message. RepaException is processed in main.py and prints error
message to stderr.

Fixes: #1708
Change-Id: I966013766e2756d64edf02c9cc6ac51d42f3a525
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Reviewed-on: https://otctools.jf.intel.com/review/10671
Tested-by: OTC Tools Tester <ed.bartosh@linux.intel.com>
repa/obs.py

index 6d4e85815434fb58153f4eb4517efa5e014b408e..a4f74136b98b4e0865eab5a26adf45beaf3358a3 100644 (file)
@@ -45,6 +45,8 @@ from osc import core
 from gitbuildsys.oscapi import OSC, ObsError, OSCError
 from gitbuildsys.utils import Temp
 
+from repa.common import RepaException
+
 
 OSCRC_TEMPLATE = """[general]
 apiurl = %(apiurl)s
@@ -77,11 +79,20 @@ class OBS(OSC):
 
     def get_projects(self, regexp=''):
         """List projects with attributes."""
-        for project in core.meta_get_project_list(self.apiurl):
+        try:
+            projects = core.meta_get_project_list(self.apiurl)
+        except OSCError as err:
+            raise RepaException("cat't get list of projects from %s: %s" %
+                                (self.apiurl, err))
+
+        for project in projects:
             if regexp and not re.match(regexp, project):
                 continue
-            yield project, self.get_description(project)
-
+            try:
+                yield project, self.get_description(project)
+            except OSCError as err:
+                raise RepaException("Can't get a description from %s: %s" %
+                                    (project, err))
 
     def get_build_results(self, prj):
         """Get project build results."""