summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Maksimov <ctpeko3a@gmail.com>2014-09-19 21:04:24 +0800
committerAleksey Maksimov <ctpeko3a@gmail.com>2014-09-19 21:20:31 +0800
commit6f425d0e57d85ec20f403df96d9b1b9cd77682cf (patch)
treef5c0bb1285b020f4cf9d14d0bfa51973ba9821a8
parent7efadca61a5a57e0a33b97a2b6d51007c9cc2d2f (diff)
downloadpython-jenkinsapi-6f425d0e57d85ec20f403df96d9b1b9cd77682cf.tar.gz
python-jenkinsapi-6f425d0e57d85ec20f403df96d9b1b9cd77682cf.tar.bz2
python-jenkinsapi-6f425d0e57d85ec20f403df96d9b1b9cd77682cf.zip
Replaced _poll_if_needed with lightweight tree calls
-rw-r--r--jenkinsapi/jenkins.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/jenkinsapi/jenkins.py b/jenkinsapi/jenkins.py
index 5d50863..d0708f5 100644
--- a/jenkinsapi/jenkins.py
+++ b/jenkinsapi/jenkins.py
@@ -104,8 +104,8 @@ class Jenkins(JenkinsBase):
"""
Fetch all the build-names on this Jenkins server.
"""
- self._poll_if_needed()
- for info in self._data["jobs"]:
+ jobs = self.poll(tree='jobs[name,url]')['jobs']
+ for info in jobs:
yield info["name"], \
Job(info["url"], info["name"], jenkins_obj=self)
@@ -114,8 +114,8 @@ class Jenkins(JenkinsBase):
Get the jobs information
:return url, name
"""
- self._poll_if_needed()
- for info in self._data["jobs"]:
+ jobs = self.poll(tree='jobs[name,url]')['jobs']
+ for info in jobs:
yield info["url"], info["name"]
def get_job(self, jobname):
@@ -176,8 +176,8 @@ class Jenkins(JenkinsBase):
return self.jobs.rename(jobname, newjobname)
def iterkeys(self):
- self._poll_if_needed()
- for info in self._data["jobs"]:
+ jobs = self.poll(tree='jobs[name,color,url]')['jobs']
+ for info in jobs:
yield info["name"]
def iteritems(self):
@@ -223,16 +223,17 @@ class Jenkins(JenkinsBase):
:param jobname: name of job, str
:return: Job obj
"""
- self._poll_if_needed()
-
- for info in self._data["jobs"]:
+ # We have to ask for 'color' here because folder resolution
+ # relies on it
+ jobs = self.poll(tree='jobs[name,url,color]')['jobs']
+ for info in jobs:
if info["name"] == jobname:
return Job(info["url"], info["name"], jenkins_obj=self)
raise UnknownJob(jobname)
def __len__(self):
- self._poll_if_needed()
- return len(self._data["jobs"])
+ jobs = self.poll(tree='jobs[name]')['jobs']
+ return len(jobs)
def __contains__(self, jobname):
"""