Added conversions from bytes to strings
authorAleksey Maksimov <ctpeko3a@gmail.com>
Sun, 2 Mar 2014 10:06:00 +0000 (18:06 +0800)
committerAleksey Maksimov <ctpeko3a@gmail.com>
Sun, 2 Mar 2014 10:06:00 +0000 (18:06 +0800)
jenkinsapi_utils/jenkins_launcher.py

index b91b92d33955d0fa9073ad15e77c9e780e9c1bcc..fc4fa514cabdd124d97cc9e31958fcae0d105e28 100644 (file)
@@ -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