handle UnicodeDecodeError when looking for python to fix #68

This commit is contained in:
Alan Hamlett 2016-09-22 10:24:20 +02:00
parent 9bab00fd8b
commit a326046733

View file

@ -54,7 +54,7 @@ if is_py2:
try: try:
return unicode(text) return unicode(text)
except: except:
return text return text.decode('utf-8', 'replace')
elif is_py3: elif is_py3:
def u(text): def u(text):
@ -71,7 +71,7 @@ elif is_py3:
try: try:
return str(text) return str(text)
except: except:
return text return text.decode('utf-8', 'replace')
else: else:
raise Exception('Unsupported Python version: {0}.{1}.{2}'.format( raise Exception('Unsupported Python version: {0}.{1}.{2}'.format(
@ -314,7 +314,7 @@ def find_python_in_folder(folder, headless=True):
path = os.path.realpath(os.path.join(folder, 'python')) path = os.path.realpath(os.path.join(folder, 'python'))
if headless: if headless:
path = u(path) + u('w') path = u(path) + u('w')
log(DEBUG, u('Looking for Python at: {0}').format(path)) log(DEBUG, u('Looking for Python at: {0}').format(u(path)))
try: try:
process = Popen([path, '--version'], stdout=PIPE, stderr=STDOUT) process = Popen([path, '--version'], stdout=PIPE, stderr=STDOUT)
output, err = process.communicate() output, err = process.communicate()