I have python script which display Unicode message to the terminal while executing. So i want to display that message in the web page while the process runs. I was able to run the script through Popen package but its communicate() method which receives the output of the scripts can't receive Unicode text.
UnicodeEncodeError: \'charmap\' codec can\'t encode characters in position 12-15: character maps to <undefined>\r\n'
So i try to pass the message as bytes which can pass through it but i can't decode it later to discuss about this question go to: How to decode a string representation of a bytes object?
But Now in this post i want to know the way to pass Unicode text through Popen.communicate()
My code here is
from subprocess import Popen, PIPE
scripts = os.path.join(os.getcwd(), 'scripts')
p = Popen(["python", "tasks.py"],bufsize=0, cwd=scripts, stdout=PIPE, stderr=PIPE)
out,err = p.communicate()