From: Ed Bartosh Date: Wed, 14 Aug 2013 15:40:07 +0000 (+0300) Subject: OBS: Added new APIs X-Git-Tag: 0.1~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=811ad0e7261e68fb43fcbcf3272d4cd1b9c8d930;p=tools%2Frepa.git OBS: Added new APIs get_source_packages, get_binary_packages and aggregate_packages APIs have been added to OBS class. All of added APIs are generic enough to go to oscapi. All of them are going to be used by repa group subcommand. Change-Id: I65597edfcad74687a45e9b22d81666f421354e47 Signed-off-by: Ed Bartosh Reviewed-on: https://otctools.jf.intel.com/review/5899 Tested-by: OTC Tools Tester --- diff --git a/repa/obs.py b/repa/obs.py index d672f86..e0d1ef0 100644 --- a/repa/obs.py +++ b/repa/obs.py @@ -5,7 +5,7 @@ Copyright (C) Intel Corporation 2013 Licence: GPL version 2 Author: Ed Bartosh -OBS module. +OBS module. Interface module to access Open Build System. This module is a intermediate step for new APIs @@ -13,10 +13,12 @@ to oscapi. As soon as APIs are mature enough they should be contributed to oscapi. """ +import sys import re from base64 import b64encode from xml.etree import cElementTree as ET +from StringIO import StringIO from osc import core @@ -80,6 +82,31 @@ class OBS(OSC): if node.get('code') != 'excluded': pkgresults.append((node.get('package'), code)) buildres[key]['packages'] = pkgresults - + return buildres + + def get_source_packages(self, prj): + """Get list of binary packages in the project.""" + return iter(core.meta_get_packagelist(self.apiurl, prj)) + + + def get_binary_packages(self, prj): + """Get list of binary packages in the project.""" + for repo in core.get_repos_of_project(self.apiurl, prj): + yield (repo.name, repo.arch), core.get_binarylist(self.apiurl, + prj, + repo.name, + repo.arch) + + @staticmethod + def aggregate_package(src_project, src_package, dst_project, + dst_package): + """Aggregate package. Wraps core.aggregate_pack.""" + saved = sys.stdout + sys.stdout = StringIO() + try: + core.aggregate_pac(src_project, src_package, + dst_project, dst_package) + finally: + sys.stdout = saved