From: lphoward Date: Mon, 14 Oct 2013 20:27:02 +0000 (-0500) Subject: add get_parameters to QueueItem and fix get_queue_items_for_job in Queue X-Git-Tag: v0.2.23~79^2^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74ecf483ccb9e28cf9efac7d5bf6c1a33974b3c8;p=tools%2Fpython-jenkinsapi.git add get_parameters to QueueItem and fix get_queue_items_for_job in Queue --- diff --git a/jenkinsapi/queue.py b/jenkinsapi/queue.py index 92f0d60..4ed5de3 100644 --- a/jenkinsapi/queue.py +++ b/jenkinsapi/queue.py @@ -59,9 +59,9 @@ class Queue(JenkinsBase): def get_queue_items_for_job(self, job_name): if not job_name: - return [QueueItem(**item) for item in self._data['items']] + return [QueueItem(self.jenkins, **item) for item in self._data['items']] else: - return [QueueItem(**item) for item in self._data['items'] + return [QueueItem(self.jenkins, **item) for item in self._data['items'] if item['task']['name'] == job_name] def delete_item(self, queue_item): @@ -88,6 +88,15 @@ class QueueItem(object): """ return self.jenkins[self.task['name']] + def get_parameters(self): + """returns parameters of queue item""" + actions = getattr(self, 'actions', []) + for action in actions: + if type(action) is dict and 'parameters' in action: + parameters = action['parameters'] + return dict([(x['name'], x['value']) for x in parameters]) + return [] + def __repr__(self): return "<%s.%s %s>" % (self.__class__.__module__, self.__class__.__name__, str(self))