summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalim Fadhley <sal@stodge.org>2014-08-03 00:14:39 +0100
committerSalim Fadhley <sal@stodge.org>2014-08-03 00:14:39 +0100
commit1654ed3e2c15f0188cec7964bd7d4a9571686697 (patch)
treea1ab6f7510819b481a536ce081e58cc2cb778dde
parent64c3a27e78cb712a0d3a159b663f9d6396dde263 (diff)
downloadpython-jenkinsapi-1654ed3e2c15f0188cec7964bd7d4a9571686697.tar.gz
python-jenkinsapi-1654ed3e2c15f0188cec7964bd7d4a9571686697.tar.bz2
python-jenkinsapi-1654ed3e2c15f0188cec7964bd7d4a9571686697.zip
Fix many more bugs
-rw-r--r--jenkinsapi/jenkinsbase.py7
-rw-r--r--jenkinsapi/queue.py8
-rw-r--r--jenkinsapi_tests/systests/test_nodes.py20
3 files changed, 17 insertions, 18 deletions
diff --git a/jenkinsapi/jenkinsbase.py b/jenkinsapi/jenkinsbase.py
index 1aeccfb..605bba8 100644
--- a/jenkinsapi/jenkinsbase.py
+++ b/jenkinsapi/jenkinsbase.py
@@ -59,11 +59,8 @@ class JenkinsBase(object):
def _poll(self):
url = self.python_api_url(self.baseurl)
- try:
- return self.get_data(url)
- except Exception as e:
- import pdb
- pdb.set_trace()
+ return self.get_data(url)
+
def get_data(self, url, params=None):
requester = self.get_jenkins_obj().requester
diff --git a/jenkinsapi/queue.py b/jenkinsapi/queue.py
index 22d5178..523b4b7 100644
--- a/jenkinsapi/queue.py
+++ b/jenkinsapi/queue.py
@@ -1,7 +1,7 @@
"""
Queue module for jenkinsapi
"""
-
+from requests import HTTPError
from jenkinsapi.jenkinsbase import JenkinsBase
from jenkinsapi.custom_exceptions import UnknownQueueItem, NotBuiltYet
import logging
@@ -117,14 +117,14 @@ class QueueItem(JenkinsBase):
self.__class__.__name__, str(self))
def __str__(self):
- return "%s Queue #%i" % (self._data['task']['name'], self._data['id'])
+ return "%s Queue #%i" % (self._data['name'], self._data['id'])
def get_build(self):
build_number = self.get_build_number()
job_name = self.get_job_name()
return self.jenkins[job_name][build_number]
- def block_until_complete(self, delay=15):
+ def block_until_complete(self, delay=5):
build = self.block_until_building(delay)
return build.block_until_complete(delay=delay)
@@ -132,7 +132,7 @@ class QueueItem(JenkinsBase):
while True:
try:
return self.poll().get_build()
- except NotBuiltYet:
+ except (NotBuiltYet, HTTPError):
time.sleep(delay)
continue
diff --git a/jenkinsapi_tests/systests/test_nodes.py b/jenkinsapi_tests/systests/test_nodes.py
index 2d92268..4c021f2 100644
--- a/jenkinsapi_tests/systests/test_nodes.py
+++ b/jenkinsapi_tests/systests/test_nodes.py
@@ -16,15 +16,17 @@ log = logging.getLogger(__name__)
class TestNodes(BaseSystemTest):
def test_invoke_job_parameterized(self):
- node_name = random_string()
- self.jenkins.create_node(node_name)
- self.assertTrue(self.jenkins.has_node(node_name))
-
- N = self.jenkins.get_node(node_name)
- self.assertEquals(N.baseurl, self.jenkins.get_node_url(node_name))
-
- self.jenkins.delete_node(node_name)
- self.assertFalse(self.jenkins.has_node(node_name))
+ node_name = "param_" + random_string()
+ try:
+ self.jenkins.create_node(node_name)
+ self.assertTrue(self.jenkins.has_node(node_name))
+
+ N = self.jenkins.get_node(node_name)
+ self.assertEquals(N.baseurl, self.jenkins.get_node_url(node_name))
+
+ finally:
+ self.jenkins.delete_node(node_name)
+ self.assertFalse(self.jenkins.has_node(node_name))
def test_online_offline(self):
"""