

Output from a subprocess so that you can more reliably use

'''This is a simple class that collects and aggregates the Line = self.qo.get_nowait() # or q.get(timeout=.1) Line = self.qe.get_nowait() # or q.get(timeout=.1) If not self.p.stderr or self.p.stderr.closed:

If not self.p.stdout or self.p.stdout.closed: While nning and self.p.stdin is not None: Slight modification of this code should give you exactly what you are looking for. A much more difficult problem because windows doesn't follow any standard but their own. Here is something that I worked on to do what you want in windows. What does that mean? How can i emulate a terminal with python that allows me to control an interactive shell or run blender and communicate with the console? Sometimes (like for 'ls') I only get this error: b'ls\nbash-3.2$ exit\n'. The second time it gives me a ValueError: I/O operation on closed file. (b'Applications\nusr\nvar\n', b'bash: no job control in this shell\nbash-3.2$ ls /\nbash-3.2$ exit\n'). That should spawn an interactive shell that i can use like a terminal, doesen't it?īut either way i can't keep the connection open, and using the last example I can call sp.communicate once, giving me the following output(in this case for 'ls /') and some errors: Sp = subprocess.Popen(, stdout = subprocess.PIPE, stdin = subprocess.PIPE, stderr = subprocess.PIPE) and then print(sp.communicate(command.encode())). That works fine for most things but not for anything interactive. I used to execute commands using stream = os.popen(command) and then print (stream.read()). But to write game engine scripts in blender the console, which usually opens in the terminal you started blender with, is crucial.įor just doing simple things like deleting, renaming etc. I've been trying to write a basic terminal emulation script, because for some reason i've got no terminal access on my mac.
