Jenkins does not recognize the view requested.
"""
+class UnknownQueueItem( KeyError, JenkinsAPIException):
+ """
+ Jenkins does not recognize the requested queue item
+ """
+
class ArtifactBroken(JenkinsAPIException):
"""
An artifact is broken, wrong
from jenkinsapi.jenkinsbase import JenkinsBase
+from jenkinsapi.exceptions import UnknownQueueItem
import logging
import urlparse
import urllib2
self.jenkins = jenkins_obj
JenkinsBase.__init__(self, baseurl)
+ def __str__(self):
+ return self.baseurl
+
def get_jenkins_obj(self):
return self.jenkins
- def get_queue_items(self, job_name = None):
+ def iteritems(self):
+ for item in self._data['items']:
+ yield item['id'], QueueItem(self.jenkins, **item)
+
+ def keys(self):
+ return [i[0] for i in self.iteritems()]
+
+ def __len__(self):
+ return len(self._data['items'])
+
+ def __getitem__(self, item_id):
+ for id, item in self.iteritems():
+ if id == item_id:
+ return item
+ raise UnknownQueueItem(item_id)
+
+ def get_queue_items_for_job(self, job_name):
if not job_name:
return [QueueItem(**item) for item in self._data['items']]
else:
those changes
"""
- def __init__(self, **kwargs):
- for arg in kwargs:
- setattr(self, arg, kwargs[arg])
+ def __init__(self, jenkins, **kwargs):
+ self.jenkins = jenkins
+ self.__dict__.update(kwargs)
+ def getJob(self):
+ """
+ Return the job associated with this queue item
+ """
+ return self.jenkins[self.task['name']]
\ No newline at end of file