list: Implement --ignore command line option
authorEd Bartosh <eduard.bartosh@intel.com>
Thu, 12 Jun 2014 12:54:45 +0000 (15:54 +0300)
committerEduard Bartosh <eduard.bartosh@intel.com>
Fri, 13 Jun 2014 19:28:30 +0000 (22:28 +0300)
This option gives user possibility to ignore broken state of
packages. For Tizen:Common and Tizen:IVI it's must have currently
as _aggregate packages are broken in prerelease projects because
of OBS bug. This causes wrong status reported for all submissions.

Change-Id: Iaac19a922a4b5996aff8d7cd277f20ec6868794c
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
repa.1
repa/list.py

diff --git a/repa.1 b/repa.1
index c4e2d58..dadeb4b 100644 (file)
--- a/repa.1
+++ b/repa.1
@@ -90,7 +90,7 @@ Turn on colorized output
 .\"
 .\" The "list" command description
 .\"
-.SS \fBlist\fR [\-\-help] [\-\-processes <processes>] [\-\-showurls]
+.SS \fBlist\fR [\-\-help] [\-\-processes <processes>] [\-\-showurls] [\-\-ignore <regexp>]
 
 .RS 2
 List submissions in the following format:
@@ -140,6 +140,12 @@ Show OBS and download urls in the output. It's switched off by default.
 Note, that this parameter can also be specified in \fIrepa\fR configuration file.
 .RE
 
+.PP
+.B \-\-ignore <regexp>
+.RS 2
+Ignore packaging failures for specified regexp. <regexp> is a slash-separated string <repository>/<architecture>/<package>, for example arm.*/armv7./.*_aggregate.
+Note, that this parameter can also be specified in \fIrepa\fR configuration file.
+.RE
 
 .PP
 .\"
@@ -380,6 +386,9 @@ color = off
 .RS 2
 showurls = off
 .RE
+.RS 2
+ignore = arm-.*/armv7./.*_aggregate$
+.RE
 
 
 .RS 2
@@ -387,7 +396,7 @@ Mandatory options: apiurl, apiuser, apipasswd and project
 .RE
 
 .RS 2
-Some options (project, processes, colorize, showurls) can be overridden by commandline options (--project, --processes, --colorize, --showurls)
+Some options (project, processes, colorize, showurls, ignore) can be overridden by commandline options (--project, --processes, --colorize, --showurls, --ignore)
 .RE
 
 .SH BUGS
index 28f602d..654672e 100755 (executable)
@@ -31,21 +31,26 @@ Get list of submissions.
 
 import sys
 import json
+import re
 
 from repa.common import (OBS_PROJECT_PREFIX, Colorizer,
                          get_download_url, get_obs_url)
 from repa.obs import OBS
 from repa.main import sub_main
 
-def get_status(meta, colorizer, build_results=None):
+def get_status(meta, colorizer, build_results=None, ignore=''):
     """Get overall status by analyzing package and image build status."""
     if build_results:
         codes = set()
-        for target in build_results.itervalues():
+        pkgstatus = {}
+        for (repo, arch), target in build_results.iteritems():
             codes.add(target.get('code'))
             codes.add(target.get('state'))
             for pkginfo in target['packages']:
-                codes.add(pkginfo[1])
+                # ignore packages if they match ignore regexp
+                if not (ignore and re.match(ignore, "%s/%s/%s" % \
+                                           (repo, arch, pkginfo[0]))):
+                    codes.add(pkginfo[1])
 
         statuses = [('broken', ('red', 'broken source')),
                     ('unresolvable', ('red', 'unresolvable packages')),
@@ -81,7 +86,7 @@ def show_urls(meta):
 
 
 def list_submissions(obs, target, processes, is_colorize=False,
-                     showurls=False):
+                     showurls=False, ignore=''):
     """List submissions and groups."""
     colorizer = Colorizer(is_colorize)
     # submissions
@@ -95,7 +100,8 @@ def list_submissions(obs, target, processes, is_colorize=False,
             continue
         projects = [project.split('/')[-1] for project in meta['projects']]
         print '%-37s %-37s %s' % (meta['git_tag'], \
-              get_status(meta, colorizer, build_results), ','.join(projects))
+              get_status(meta, colorizer, build_results, ignore),
+              ','.join(projects))
         if showurls:
             show_urls(meta)
 
@@ -127,13 +133,15 @@ class List(object):
         parser.add_argument('--showurls', action='store_true',
                             help='show OBS and download urls',
                             default=config.get('showurls', '').lower() == 'on')
+        parser.add_argument('--ignore', default=config.get('ignore', ''),
+                            help='ignore package failures by regexp')
 
     @staticmethod
     def run(argv):
         """Command line entry point. Called from [sub_]main"""
         obs = OBS(argv.apiurl, argv.apiuser, argv.apipasswd)
         return list_submissions(obs, argv.project, argv.processes,
-                                argv.colorize, argv.showurls)
+                                argv.colorize, argv.showurls, argv.ignore)
 
 
 if __name__ == '__main__':