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:
parent
d9c6655389
commit
144ace119b
@ -22,6 +22,7 @@ import logging
|
||||
import os
|
||||
from pprint import pformat
|
||||
import re
|
||||
from six.moves.urllib.parse import quote
|
||||
import time
|
||||
import xml.etree.ElementTree as XML
|
||||
|
||||
@ -116,7 +117,8 @@ class JenkinsManager(object):
|
||||
# returns job name or url based on config option
|
||||
if self._jjb_config.builder['print_job_urls']:
|
||||
return self._jjb_config.jenkins['url'] + \
|
||||
'/job/' + '/job/'.join(job_name.split('/')) + '/'
|
||||
'/job/' + quote(
|
||||
'/job/'.join(job_name.split('/')).encode('utf8')) + '/'
|
||||
else:
|
||||
return job_name
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user