diff options
author | Aleksey Maksimov <ctpeko3a@gmail.com> | 2014-04-10 23:26:35 +0800 |
---|---|---|
committer | Aleksey Maksimov <ctpeko3a@gmail.com> | 2014-04-10 23:26:35 +0800 |
commit | 59da1e221b4d9a9294efae007d7df0e0710ff77c (patch) | |
tree | 4aab762f96a7bcaff9ae9d4735fe9c422fb005a1 /jenkinsapi/queue.py | |
parent | 997aa4d796c688379985d6b8ea23ff83de0f3881 (diff) | |
download | python-jenkinsapi-59da1e221b4d9a9294efae007d7df0e0710ff77c.tar.gz python-jenkinsapi-59da1e221b4d9a9294efae007d7df0e0710ff77c.tar.bz2 python-jenkinsapi-59da1e221b4d9a9294efae007d7df0e0710ff77c.zip |
Fix for issue #268 and unit tests for it
Diffstat (limited to 'jenkinsapi/queue.py')
-rw-r--r-- | jenkinsapi/queue.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/jenkinsapi/queue.py b/jenkinsapi/queue.py index 4ed5de3..d0efc5b 100644 --- a/jenkinsapi/queue.py +++ b/jenkinsapi/queue.py @@ -57,11 +57,13 @@ class Queue(JenkinsBase): else: raise UnknownQueueItem(item_id) - def get_queue_items_for_job(self, job_name): + def get_queue_items_for_job(self, job_name=''): if not job_name: - return [QueueItem(self.jenkins, **item) for item in self._data['items']] + return [QueueItem(self.jenkins, **item) + for item in self._data['items']] else: - return [QueueItem(self.jenkins, **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): @@ -74,8 +76,8 @@ class Queue(JenkinsBase): class QueueItem(object): """ - Flexible class to handle queue items. If the Jenkins API changes this support - those changes + Flexible class to handle queue items. + If the Jenkins API changes this support those changes """ def __init__(self, jenkins, **kwargs): @@ -94,11 +96,13 @@ class QueueItem(object): 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 dict([(x['name'], x.get('value', None)) + for x in parameters]) return [] def __repr__(self): - return "<%s.%s %s>" % (self.__class__.__module__, self.__class__.__name__, str(self)) + return "<%s.%s %s>" % (self.__class__.__module__, + self.__class__.__name__, str(self)) def __str__(self): return "%s #%i" % (self.task['name'], self.id) |