From: Aleksey Maksimov Date: Sun, 2 Mar 2014 10:06:00 +0000 (+0800) Subject: Added conversions from bytes to strings X-Git-Tag: v0.2.23~23^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=59d4e3c5f008acbcd8f768931c3b6280fbca3082;p=tools%2Fpython-jenkinsapi.git Added conversions from bytes to strings --- 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