Fix minor bugs
authorHuang Hao <hao.h.huang@intel.com>
Mon, 10 Sep 2012 08:05:35 +0000 (16:05 +0800)
committerHuang Hao <hao.h.huang@intel.com>
Mon, 10 Sep 2012 08:05:35 +0000 (16:05 +0800)
- catch ValueError for url given by --repository
- prompt user if can't find obs api
- use empty password if no passwd item found for obs

Change-Id: I5c8942619cf11a019b1964c235c7f90edb78a8ee

gitbuildsys/cmd_build.py
gitbuildsys/cmd_remotebuild.py

index 354c483..b090df4 100644 (file)
@@ -243,7 +243,14 @@ def do(opts, args):
             repos = configmgr.get_current_profile().get_repos()
 
         if opts.repositories:
-            repos.extend([ SafeURL(i) for i in opts.repositories ])
+            for i in opts.repositories:
+                try:
+                    opt_repo = SafeURL(i)
+                except ValueError, err:
+                    msger.warning('Invalid repo %s: %s' % (i, str(err)))
+                else:
+                    repos.append(opt_repo)
+
         if not repos:
             msger.error('No package repository specified.')
 
index e7077f4..b87d3d3 100644 (file)
@@ -66,8 +66,11 @@ def do(opts, args):
         msger.error('Invalid arguments, see gbs remotebuild -h for more info')
 
     apiurl = configmgr.get_current_profile().get_api()
-    if not apiurl or not apiurl.user:
-        msger.error('empty user is not allowed for remotebuild, '\
+    if not apiurl:
+        msger.error('no obs api found, please add it to gbs conf and try again')
+
+    if not apiurl.user:
+        msger.error('empty user is not allowed for remotebuild, '
                     'please add user/passwd to gbs conf, and try again')
 
     if opts.commit and opts.include_all:
@@ -110,13 +113,14 @@ def do(opts, args):
     else:
         target_prj = opts.target_obsprj
 
+    api_passwd = apiurl.passwd if apiurl.passwd else ''
     # Create temporary oscrc
     oscrc = OSCRC_TEMPLATE % {
                 "http_debug": 1 if msger.get_loglevel() == 'debug' else 0,
                 "debug": 1 if msger.get_loglevel() == 'verbose' else 0,
                 "apiurl": apiurl,
                 "user": apiurl.user,
-                "passwdx": encode_passwd(apiurl.passwd),
+                "passwdx": encode_passwd(api_passwd),
             }
 
     tmpdir     = configmgr.get('tmpdir', 'general')