stdout problem example

19 views
Skip to first unread message

Thomas Braunl

unread,
Jun 7, 2018, 5:43:05 AM6/7/18
to thonny
Here is my problem in a nutshell.
Python program calling an external script which prints to stdout:
from subprocess import call
call(["ls", "-l"])

This works fine, if started from a shell, but in Thonny this generates an error message:

>>> %Run randrive.py
Error handling message: Traceback (most recent call last):
  File "/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/thonny/running.py", line 645, in _listen_stdout
    msg = parse_message(data)
  File "/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/thonny/common.py", line 148, in parse_message
    return eval(msg_string.encode("ASCII").decode("UTF-7"))
  File "<string>", line 1
    total 112
            ^
SyntaxError: invalid syntax

Thank you, Thomas

Aivar Annamaa

unread,
Jun 7, 2018, 5:58:09 AM6/7/18
to thonny
Hi Thomas!

Thonny's backend is supposed to capture all output generated by the programs run by the user. Apparently `subprocess.call` avoids this capture. I created an issue for this and I'll try to resolve it in coming weeks: https://bitbucket.org/plas/thonny/issues/442/output-generated-by-a-subprocess-escapes

best regards,
Aivar
Reply all
Reply to author
Forward
0 new messages