From 59d4e3c5f008acbcd8f768931c3b6280fbca3082 Mon Sep 17 00:00:00 2001 From: Aleksey Maksimov Date: Sun, 2 Mar 2014 18:06:00 +0800 Subject: [PATCH] Added conversions from bytes to strings --- jenkinsapi_utils/jenkins_launcher.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jenkinsapi_utils/jenkins_launcher.py b/jenkinsapi_utils/jenkins_launcher.py index b91b92d..fc4fa51 100644 --- a/jenkinsapi_utils/jenkins_launcher.py +++ b/jenkinsapi_utils/jenkins_launcher.py @@ -78,7 +78,12 @@ class JenkinsLancher(object): config_dest = os.path.join(self.jenkins_home, 'config.xml') config_dest_file = open(config_dest, 'w') config_source = pkg_resources.resource_string('jenkinsapi_tests.systests', 'config.xml') - config_dest_file.write(config_source.encode('UTF-8')) + try: + config_dest_file.write(config_source.encode('UTF-8')) + except AttributeError: + # Python 3.x + config_dest_file.write(config_source.decode('UTF-8')) + def install_plugins(self): for i, url in enumerate(self.plugin_urls): @@ -147,6 +152,9 @@ class JenkinsLancher(object): while True: try: streamName, line = self.q.get(block=True, timeout=timeout) + # Python 3.x + if isinstance(line, bytes): + line = line.decode('UTF-8') except Queue.Empty: log.warn("Input ended unexpectedly") break -- 2.34.1