Improve unicode support

Printed job urls with unicode are now clickable

Avoids unicode decode errors in logging due on
systems, likely python27 systems where
default encoding is ascii.

Change-Id: I17041de05a4388c7b95a9ca04477043424458c67
This commit is contained in:
Sorin Sbarnea
2018-06-17 15:22:25 +01:00
parent d9c6655389
commit 144ace119b
2 changed files with 15 additions and 2 deletions

View File

@@ -17,7 +17,6 @@ import io
import os
import logging
import platform
import sys
from stevedore import extension
import yaml
@@ -141,6 +140,18 @@ class JenkinsJobs(object):
def main():
# utf-8 workaround for avoiding unicode errors in stdout/stderr
# see https://stackoverflow.com/a/2001767/99834
import codecs
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
sys.stderr = codecs.getwriter('utf8')(sys.stderr)
# end of workaround
argv = sys.argv[1:]
jjb = JenkinsJobs(argv)
jjb.execute()