always raise errors.ObsError in oscapi module instead of OSCError
authorZhang Qiang <qiang.z.zhang@intel.com>
Mon, 20 Aug 2012 08:30:55 +0000 (16:30 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Mon, 20 Aug 2012 08:35:25 +0000 (16:35 +0800)
OSCError can't be catched and backtrace would be printed.

gitbuildsys/oscapi.py

index 7153fe9..2b76c20 100644 (file)
@@ -52,7 +52,7 @@ class OSC(object):
             except OSError, err:
                 if err.errno == 1:
                     # permission problem, should be the chmod(0600) issue
-                    raise RuntimeError('Current user has no write permission '\
+                    raise errors.ObsError('Current user has no write permission '\
                                        'for specified oscrc: %s' % oscrc)
 
                 raise # else
@@ -73,7 +73,7 @@ class OSC(object):
             return method(url, data=data, file=filep)
         except (urllib2.URLError, M2Crypto.m2urllib2.URLError,
                 M2Crypto.SSL.SSLError, ssl.SSLError), err:
-            raise OSCError(str(err))
+            raise errors.ObsError(str(err))
 
     def copy_project(self, src, target, rewrite=False):
         """
@@ -115,14 +115,14 @@ class OSC(object):
             core.edit_meta('prj', path_args=quote_plus(target), data=meta)
         except (urllib2.URLError, M2Crypto.m2urllib2.URLError,
                 M2Crypto.SSL.SSLError), err:
-            raise OSCError("Can't set meta for %s: %s" % (target, str(err)))
+            raise errors.ObsError("Can't set meta for %s: %s" % (target, str(err)))
 
         # copy project config
         try:
             config = core.show_project_conf(self.apiurl, src)
         except (urllib2.URLError, M2Crypto.m2urllib2.URLError,
                 M2Crypto.SSL.SSLError), err:
-            raise OSCError("Can't get config from project %s: %s" \
+            raise errors.ObsError("Can't get config from project %s: %s" \
                            % (src, str(err)))
 
         url = core.make_meta_url("prjconf", quote_plus(target),
@@ -130,7 +130,7 @@ class OSC(object):
         try:
             self.core_http(core.http_PUT, url, data=''.join(config))
         except OSCError, err:
-            raise OSCError("can't copy config from %s to %s: %s" \
+            raise errors.ObsError("can't copy config from %s to %s: %s" \
                            % (src, target, err))
 
     def exists(self, prj, pkg=''):
@@ -152,7 +152,7 @@ class OSC(object):
                                   M2Crypto.SSL.SSLError), err:
             pass
         if err:
-            raise OSCError("can't check if %s/%s exists: %s" % (prj, pkg, err))
+            raise errors.ObsError("can't check if %s/%s exists: %s" % (prj, pkg, err))
 
         return True
 
@@ -181,7 +181,7 @@ class OSC(object):
                 self.core_http(core.http_PUT, put_url, filep=fpath)
             self.core_http(core.http_POST, url, data=xml)
         except OSCError, err:
-            raise OSCError("can't commit files to %s/%s: %s" % (prj, pkg, err))
+            raise errors.ObsError("can't commit files to %s/%s: %s" % (prj, pkg, err))
 
     def remove_files(self, prj, pkg, fnames=None):
         """
@@ -200,7 +200,7 @@ class OSC(object):
             try:
                 self.core_http(core.http_DELETE, url)
             except OSCError, err:
-                raise OSCError("can\'t remove files from %s/%s: %s" \
+                raise errors.ObsError("can\'t remove files from %s/%s: %s" \
                                % (prj, pkg, err))
 
     def create_package(self, prj, pkg):
@@ -213,7 +213,7 @@ class OSC(object):
         try:
             self.core_http(core.http_PUT, url, data=meta)
         except OSCError, err:
-            raise OSCError("can't create %s/%s: %s" % (prj, pkg, err))
+            raise errors.ObsError("can't create %s/%s: %s" % (prj, pkg, err))
 
     def get_results(self, prj, pkg):
         """Get package build results."""
@@ -222,7 +222,7 @@ class OSC(object):
             build_status = core.get_results(self.apiurl, prj, pkg)
         except (urllib2.URLError, M2Crypto.m2urllib2.URLError,
                 M2Crypto.SSL.SSLError), err:
-            raise OSCError("can't get %s/%s build results: %s" \
+            raise errors.ObsError("can't get %s/%s build results: %s" \
                            % (prj, pkg, str(err)))
 
         for res in build_status:
@@ -238,7 +238,7 @@ class OSC(object):
         try:
             log = self.core_http(core.http_GET, url).read()
         except OSCError, err:
-            raise OSCError("can't get %s/%s build log: %s" % (prj, pkg, err))
+            raise errors.ObsError("can't get %s/%s build log: %s" % (prj, pkg, err))
 
         return log.translate(None, "".join([chr(i) \
                                             for i in range(10) + range(11,32)]))