summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Woods <wwoods@redhat.com>2009-09-22 16:27:50 -0400
committerWill Woods <wwoods@redhat.com>2009-09-22 16:27:50 -0400
commit7bbe07f39b3c90d31f17853f99d88e083fb84c79 (patch)
treeec8aa20196a5e885ad7b0aafcd3cc6f6fd36fce0
parent3123eb2ca6dcb6ab2aec487dd33fca872716bac2 (diff)
downloadisrawhidebroken-7bbe07f39b3c90d31f17853f99d88e083fb84c79.tar.gz
israwhidebroken-7bbe07f39b3c90d31f17853f99d88e083fb84c79.tar.xz
israwhidebroken-7bbe07f39b3c90d31f17853f99d88e083fb84c79.zip
Simplify return code
-rw-r--r--israwhidebroken/client.py23
1 files changed, 6 insertions, 17 deletions
diff --git a/israwhidebroken/client.py b/israwhidebroken/client.py
index 02ba4c8..53c41ef 100644
--- a/israwhidebroken/client.py
+++ b/israwhidebroken/client.py
@@ -36,23 +36,18 @@ def treedata_from_url(url):
pass
return treedata
+# XXX TODO: if 'exc' in r: raise appropriate error?
class IRBClient(BaseClient):
def get_tests(self):
'''Returns a list of known tests'''
r = self.send_request('/get_tests')
- if 'tests' in r:
- return r['tests']
- else:
- pass # FIXME raise an exception or something
+ return r.get('tests')
def get_trees(self, *args, **kw):
'''Get a list of trees that match all the given parameters:
id, compose_id, arch, tree_time, repodata_time'''
r = self.send_request('/get_trees', req_params=kw)
- if 'trees' in r:
- return r['trees']
- else:
- pass # FIXME raise an exception or something
+ return r.get('trees')
def add_tree(self, *args, **kw):
'''Add a new tree to israwhidebroken.
@@ -65,21 +60,15 @@ class IRBClient(BaseClient):
if type(kw['arch']) is not str:
raise ValueError, 'arch must be str'
r = self.send_request('/add_tree', auth=True, req_params=kw)
- if 'tree' in r:
- return r['tree']
- else:
- pass # FIXME raise an exception or something
-
+ return r.get('tree')
+
def add_result(self, treeid, testid, result, detail_url=None):
'''Add a test result to the database. Returns result id on success.'''
params = {'treeid':treeid, 'testid':testid, 'result': result}
if detail_url:
params['detail_url'] = detail_url
r = self.send_request('/add_result', auth=True, req_params=params)
- if 'id' in r:
- return r['id']
- else:
- pass # FIXME raise an exception or something
+ return r.get('id')
def report_result(self, testid, tree_data, result, add_tree=False):
'''Convenience method that will look up the tree using tree_data and