add a bulk_query method to let us get back more than one item

extend gerritlib so that we have a query method to get more
complicated query sets. Would rather use gerritlib than raw ssh
commands for this, and this makes it possible.

Change-Id: I467011f027cfc3d594db5f95bb7a5ff46e79b1a8
This commit is contained in:
Sean Dague 2013-06-19 16:52:07 -04:00
parent 81a0066752
commit 5dd2df5eb8
1 changed files with 20 additions and 0 deletions

View File

@ -161,6 +161,26 @@ class Gerrit(object):
pprint.pformat(data)))
return data
def bulk_query(self, query):
cmd = 'gerrit query --format json %s"' % (
query)
out, err = self._ssh(cmd)
if not out:
return False
lines = out.split('\n')
if not lines:
return False
data = []
for line in lines:
if line:
data.append(json.loads(line))
if not data:
return False
self.log.debug("Received data from Gerrit query: \n%s" % (
pprint.pformat(data)))
return data
def _ssh(self, command):
client = paramiko.SSHClient()
client.load_system_host_keys()