new stuff that I forgot to commit yesterday
authorsalimfadhley <sal@stodge.org>
Mon, 10 Jun 2013 21:05:31 +0000 (22:05 +0100)
committersalimfadhley <sal@stodge.org>
Mon, 10 Jun 2013 21:05:31 +0000 (22:05 +0100)
jenkinsapi/jenkins.py
jenkinsapi/jenkinsbase.py

index 6654ab5..bf4f3ec 100644 (file)
@@ -10,6 +10,7 @@ from utils.urlopener import mkurlopener, mkopener, NoAuto302Handler
 
 from jenkinsapi import config
 from jenkinsapi.job import Job
+from jenkinsapi.nodes import Nodes
 from jenkinsapi.node import Node
 from jenkinsapi.queue import Queue
 from jenkinsapi.view import View
@@ -84,6 +85,10 @@ class Jenkins(JenkinsBase):
         # This only ever needs to work on the base object
         return '%s/createItem' % self.baseurl
 
+    def get_nodes_url(self):
+        # This only ever needs to work on the base object
+        return '%s/computer' % self.baseurl
+
     def get_jobs(self):
         """
         Fetch all the build-names on this Jenkins server.
@@ -244,6 +249,10 @@ class Jenkins(JenkinsBase):
         self._poll
         return self
 
+    def get_nodes(self):
+        url = self.get_nodes_url()
+        return Nodes(url, self)
+
     def create_view(self, str_view_name, person=None):
         """
         Create a view
index ddb54ec..de6cd81 100644 (file)
@@ -3,7 +3,7 @@ import urllib2
 import logging
 import pprint
 from jenkinsapi import config
-
+from jenkinsapi.exceptions import JenkinsAPIException
 log = logging.getLogger(__name__)
 
 class JenkinsBase(object):
@@ -62,11 +62,9 @@ class JenkinsBase(object):
         response = requester.get_url(url)
         try:
             return eval(response.text)
-        except SyntaxError:
+        except Exception:
             log.exception('Inappropriate content found at %s' % url)
-            raise
-        except TypeError:
-            raise
+            raise JenkinsAPIException('Cannot parse %s' % url)
 
     @classmethod
     def python_api_url(cls, url):