From 290a3f0f90f3a0464c0f4016cf03018eafc59e4c Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Wed, 28 Jul 2010 16:04:27 +0200 Subject: [PATCH] added new command 'osc distributions' added new command 'osc distributions' to get info about active and discontinued distributions. --- osc/commandline.py | 18 ++++++++++++++++++ osc/core.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/osc/commandline.py b/osc/commandline.py index dbfcb5d5..ed549c6c 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -3173,6 +3173,24 @@ Please submit there instead, or use --nodevelproject to force direct submission. print '\n'.join(get_repositories(apiurl)) + @cmdln.alias('dists') + @cmdln.option('-d', '--discontinued', action='store_true', + help='show discontinued distributions') + def do_distributions(self, subcmd, opts, *args): + """${cmd_name}: Shows all available distributions + + This command shows the available distributions. For active distributions + it shows the name, project and name of the repository. + + usage: + osc distributions + + ${cmd_option_list} + """ + apiurl = self.get_api_url() + + print '\n'.join(get_distibutions(apiurl, opts.discontinued)) + @cmdln.hide(1) def do_results_meta(self, subcmd, opts, *args): print "Command results_meta is obsolete. Please use: osc results --xml" diff --git a/osc/core.py b/osc/core.py index 21ad2b45..aae4afb4 100644 --- a/osc/core.py +++ b/osc/core.py @@ -3647,6 +3647,45 @@ def get_repositories(apiurl): return r +def get_distibutions(apiurl, discon=False): + r = [] + + if discon: + result_line_templ = '%(name)-25s %(project)s' + f = http_GET(makeurl(apiurl, ['build'])) + root = ET.fromstring(''.join(f)) + + for node in root.findall('entry'): + if node.get('name').startswith('DISCONTINUED:'): + rmap = {} + rmap['name'] = node.get('name').replace('DISCONTINUED:','').replace(':', ' ') + rmap['project'] = node.get('name') + r.append (result_line_templ % rmap) + + r.insert(0,'distribution project') + r.insert(1,'------------ -------') + + else: + result_line_templ = '%(name)-25s %(project)-25s %(reponame)s' + f = http_GET(makeurl(apiurl, ['distributions'])) + root = ET.fromstring(''.join(f)) + + for node in root.findall('distribution'): + rmap = {} + for node2 in node.findall('name'): + rmap['name'] = node2.text + for node3 in node.findall('project'): + rmap['project'] = node3.text + for node4 in node.findall('reponame'): + rmap['reponame'] = node4.text + r.append(result_line_templ % rmap) + + r.insert(0,'distribution project reponame') + r.insert(1,'------------ ------- --------') + + return r + + # old compat lib call def get_platforms_of_project(apiurl, prj): return get_repositories_of_project(apiurl, prj)