catch TypeError and IOError if passwdx with wrong format
authorZhang Qiang <qiang.z.zhang@intel.com>
Thu, 28 Jun 2012 07:31:30 +0000 (15:31 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Thu, 28 Jun 2012 07:31:30 +0000 (15:31 +0800)
gitbuildsys/cmd_build.py
gitbuildsys/conf.py

index 7c9dbf2..7ce9891 100644 (file)
@@ -308,7 +308,10 @@ def do(opts, args):
                     key, val = item.split(':', 1)
                     if key == 'passwdx':
                         key = 'passwd'
-                        val = base64.b64decode(val).decode('bz2')
+                        try:
+                            val = base64.b64decode(val).decode('bz2')
+                        except (TypeError, IOError), err:
+                            raise errors.ConfigError('passwdx: %s' % err)
                     repo_auth[key] = val
                 if 'user' in repo_auth:
                     repos[url]['user'] = repo_auth['user']
index 41b5107..f816b0f 100644 (file)
@@ -413,7 +413,10 @@ distconf = $build__distconf
             opt = 'passwdx'
             val = self._get(opt, section)
             if val:
-                return base64.b64decode(val).decode('bz2')
+                try:
+                    return base64.b64decode(val).decode('bz2')
+                except (TypeError, IOError), err:
+                    raise errors.ConfigError('passwdx:%s' % err)
             else:
                 return val
         else: