build.get_console() now returns string in all python versions
authorAleksey Maksimov <ctpeko3a@gmail.com>
Fri, 25 Apr 2014 13:33:31 +0000 (21:33 +0800)
committerAleksey Maksimov <ctpeko3a@gmail.com>
Fri, 25 Apr 2014 13:46:30 +0000 (21:46 +0800)
jenkinsapi/build.py

index a235531cc72ae797e70d9850c429e0aafd2dcd13..30acd3da8f7394ac828bb90dca170c2266561449 100644 (file)
@@ -364,7 +364,16 @@ class Build(JenkinsBase):
         Return the current state of the text console.
         """
         url = "%s/consoleText" % self.baseurl
-        return self.job.jenkins.requester.get_url(url).content.decode('utf-8')
+        content = self.job.jenkins.requester.get_url(url).content
+        # This check was made for Python 3.x
+        # In this version content is a bytes string
+        # By contract this function must return string
+        if isinstance(content, str):
+            return content
+        elif isinstance(content, bytes):
+            return content.decode('utf-8')
+        else:
+            raise JenkinsAPIException('Unknown content type for console')
 
     def stop(self):
         """