catch invalid apiurl exception in buildservice module
authorZhang Qiang <qiang.z.zhang@intel.com>
Mon, 11 Jun 2012 08:56:13 +0000 (16:56 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Mon, 11 Jun 2012 08:56:13 +0000 (16:56 +0800)
gitbuildsys/buildservice.py
gitbuildsys/cmd_remotebuild.py

index b1dabe3..1be16ca 100644 (file)
@@ -240,6 +240,8 @@ class BuildService(object):
                     raise RuntimeError, 'Current user has no write permission for specified oscrc: %s' % oscrc
 
                 raise # else
+            except urllib2.URLError:
+                raise errors.ObsError("invalid service apiurl: %s" % apiurl)
         else:
             conf.get_config()
 
index 98bafe4..65a72d7 100644 (file)
@@ -110,15 +110,12 @@ def do(opts, args):
 
     prj = obspkg.ObsProject(target_prj, apiurl = APISERVER, oscrc = oscrcpath)
     msger.info('checking status of obs project: %s ...' % target_prj)
-    try:
-        if prj.is_new():
-            if opts.target_obsprj and not target_prj.startswith('home:%s:' % USER):
-                msger.error('no permission to create project %s, only subpackage '\
-                        'of home:%s is allowed ' % (target_prj, USER))
-            msger.info('creating %s for package build ...' % target_prj)
-            prj.branch_from(base_prj)
-    except errors.ObsError, exc:
-        msger.error('%s' % exc)
+    if prj.is_new():
+        if opts.target_obsprj and not target_prj.startswith('home:%s:' % USER):
+            msger.error('no permission to create project %s, only subpackage '\
+                    'of home:%s is allowed ' % (target_prj, USER))
+        msger.info('creating %s for package build ...' % target_prj)
+        prj.branch_from(base_prj)
 
     msger.info('checking out %s/%s to %s ...' % (target_prj, spec.name, tmpdir))