write a regular expression to parse build server results
authorZhang Qiang <qiang.z.zhang@intel.com>
Mon, 21 Jan 2013 23:32:20 +0000 (18:32 -0500)
committerZhang Qiang <qiang.z.zhang@intel.com>
Wed, 23 Jan 2013 16:34:30 +0000 (11:34 -0500)
If no build results, report correct no build results info

Change-Id: I0f8e09a584ec1ab7bab238229347755cefd5b073

gitbuildsys/cmd_remotebuild.py
gitbuildsys/oscapi.py

index 89421eb..693a68d 100644 (file)
@@ -186,8 +186,11 @@ def main(args):
                 for arch in status[build_repo]:
                     stat = status[build_repo][arch]
                     results.append('%-15s%-15s%-15s' % (build_repo, arch, stat))
-            log.info('build results from build server:\n%s' \
-                       % '\n'.join(results))
+            if results:
+                log.info('build results from build server:\n%s' \
+                          % '\n'.join(results))
+            else:
+                log.info('no build results from build server')
             return 0
 
     except OSCError, err:
index 8a46158..2e5a0d5 100644 (file)
@@ -23,6 +23,7 @@ Only APIs which are required by cmd_remotebuild present here.
 """
 
 import os
+import re
 import urllib2
 import M2Crypto
 from M2Crypto.SSL.Checker import SSLVerificationError
@@ -325,8 +326,16 @@ class OSC(object):
                            % (prj, pkg, str(err)))
 
         for res in build_status:
-            repo, arch, status = res.split()
-            results[repo][arch] = status
+            # This regular expression is created for parsing the
+            # results of of core.get_results()
+            stat_re = re.compile(r'^(?P<repo>\S+)\s+(?P<arch>\S+)\s+'
+                                  '(?P<status>\S*)$')
+            mo = stat_re.match(res)
+            if mo:
+                results[mo.group('repo')][mo.group('arch')] = mo.group('status')
+            else:
+                logger.warning('not valid build status received: %s' % res)
+
         return results
 
     def get_buildlog(self, prj, pkg, repo, arch):