GUI.pyw: fixed an obscure bug triggered by Unicode literals
This commit is contained in:
parent
cebfbba68e
commit
499866323b
1 changed files with 7 additions and 2 deletions
|
@ -61,6 +61,11 @@ def wrap_elem(line):
|
|||
|
||||
def run_tool(tool,queue,command):
|
||||
"""Runs a maintenance tool with the desired arguments and pushes the output in the supplied queue"""
|
||||
# set the encoding for the subprocess
|
||||
# otherwise, with the new Unicode literals used by the wml tools,
|
||||
# we may get UnicodeDecodeErros
|
||||
env=os.environ
|
||||
env['PYTHONIOENCODING']="utf8"
|
||||
if sys.platform=="win32":
|
||||
# Windows wants a string, Linux wants a list and Polly wants a cracker
|
||||
# Windows wants also strings flavoured with double quotes
|
||||
|
@ -72,7 +77,7 @@ def run_tool(tool,queue,command):
|
|||
si=subprocess.STARTUPINFO()
|
||||
si.dwFlags=subprocess.STARTF_USESHOWWINDOW|subprocess.SW_HIDE # to avoid showing a DOS prompt
|
||||
try:
|
||||
output=subprocess.check_output(' '.join(wrapped_line),stderr=subprocess.STDOUT,startupinfo=si)
|
||||
output=subprocess.check_output(' '.join(wrapped_line),stderr=subprocess.STDOUT,startupinfo=si,env=env)
|
||||
queue.put_nowait(output)
|
||||
except subprocess.CalledProcessError as error:
|
||||
# post the precise message and the remaining output as a tuple
|
||||
|
@ -80,7 +85,7 @@ def run_tool(tool,queue,command):
|
|||
else: # STARTUPINFO is not available, nor needed, outside of Windows
|
||||
queue.put_nowait(' '.join(command)+"\n")
|
||||
try:
|
||||
output=subprocess.check_output(command,stderr=subprocess.STDOUT)
|
||||
output=subprocess.check_output(command,stderr=subprocess.STDOUT,env=env)
|
||||
queue.put_nowait(output)
|
||||
except subprocess.CalledProcessError as error:
|
||||
# post the precise message and the remaining output as a tuple
|
||||
|
|
Loading…
Add table
Reference in a new issue