From 659911c42b4b02a53c23adff493e40b6d78b139c Mon Sep 17 00:00:00 2001 From: Aleksey Maksimov Date: Fri, 25 Apr 2014 21:33:31 +0800 Subject: [PATCH] build.get_console() now returns string in all python versions --- jenkinsapi/build.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/jenkinsapi/build.py b/jenkinsapi/build.py index a235531..30acd3d 100644 --- a/jenkinsapi/build.py +++ b/jenkinsapi/build.py @@ -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): """ -- 2.34.1