summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Bartosh <eduard.bartosh@intel.com>2014-05-11 23:29:50 +0300
committerEd Bartosh <eduard.bartosh@intel.com>2014-05-19 11:14:46 +0300
commitf052eff527bdd666a302a0b93c57fcc7c07e076f (patch)
tree7558f0acfbd84b691d3d82a1892241513561cddc
parent53852242b91bed291d90878579447798eb29b8d2 (diff)
downloadrepa-f052eff527bdd666a302a0b93c57fcc7c07e076f.tar.gz
repa-f052eff527bdd666a302a0b93c57fcc7c07e076f.tar.bz2
repa-f052eff527bdd666a302a0b93c57fcc7c07e076f.zip
obs: Implement get_srs function
Implemented get_srs to get SRs from the project. Optionally SRs can be filtered by package and comma-separated list of statuses. Change-Id: If003f25e1d54742e13cd1c1d1418598ee4baea15 Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
-rw-r--r--repa/obs.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/repa/obs.py b/repa/obs.py
index be052e7..1dd8870 100644
--- a/repa/obs.py
+++ b/repa/obs.py
@@ -181,3 +181,27 @@ class OBS(OSC):
"""Set SR state."""
return core.change_request_state(self.apiurl, reqid, state,
message=message, force=force)
+
+ def get_srs(self, prj, states=None, pkg=None):
+ """
+ Get SRs for the project (and package).
+
+ Args:
+ prj (str): OBS project name
+ states (str): comma-separated list of states, e.g. 'new,accepted'
+ pkg (str): package name
+
+ Yields:
+ id, state, description of found SRs
+ """
+ query = 'view=collection&types=submit&project=%s' % prj
+ if states:
+ query += '&states=%s' % states
+ if pkg:
+ query += '&package=%s' % pkg
+ url = core.makeurl(self.apiurl, ['request'], query)
+
+ root = ET.parse(self.core_http(core.http_GET, url))
+ for sr in root.findall('request'):
+ yield sr.get('id'), sr.find('state').get('name'), \
+ sr.find('description').text