Python subprocess call background3/6/2024 I’m looking for a cross-platform solution. (Without the coloring, we’re missing the issue). In : subprocess.check_output('python test.py')Īnd now a picture to show the coloring in check_call, but not in check_output. In : subprocess.check_call('python test.py') Print(Fore.GREEN + "Hello world!" + Fore.RESET)Īnd playing in the interpreter: In : import subprocess Test.py: from colorama import Fore, init as colorama_init If I skip trying to save the data, colors work fine. Is there any way to allow those codes to come through so I can forward them to stdout (while still getting the output in a buffer in real time). I noticed that I never see color codes (ANSI?) make it through. I was doing this via something like this: process = subprocess.Popen(Ĭmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUTĪs time goes on I read in a byte at a time and save it to a buffer and send it to stdout. Ultimately I want to be able to run a subprocess, save the output in real time and output any colored output to the terminal.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |