logging fix for invalid response
authorKyle <kyle.rockman@mac.com>
Mon, 27 Jan 2014 20:01:11 +0000 (14:01 -0600)
committerKyle <kyle.rockman@mac.com>
Mon, 27 Jan 2014 20:01:11 +0000 (14:01 -0600)
jenkinsapi/jenkinsbase.py

index bc5624ba776e93714220c639f96654f4fec4aa61..eadfc6e83ef6748d631967aa9cf83f3eef811b0d 100644 (file)
@@ -6,7 +6,6 @@ import ast
 import logging
 from jenkinsapi import config
 from jenkinsapi.custom_exceptions import JenkinsAPIException
-log = logging.getLogger(__name__)
 
 
 class JenkinsBase(object):
@@ -61,10 +60,12 @@ class JenkinsBase(object):
     def get_data(self, url, params=None):
         requester = self.get_jenkins_obj().requester
         response = requester.get_url(url, params)
+        if response.status_code != 200 :
+            response.raise_for_status()
         try:
             return ast.literal_eval(response.text)
         except Exception:
-            log.exception('Inappropriate content found at %s', url)
+            logging.exception('Inappropriate content found at %s', url)
             raise JenkinsAPIException('Cannot parse %s' % response.content)
 
     @classmethod