stdout

Synchronized reading data from Process's empty stdout causes deadlock [duplicate]

我的未来我决定 提交于 2019-12-12 01:24:46
问题 This question already has an answer here : Reading from a process, StreamReader.Peek() not working as expected (1 answer) Closed 3 years ago . I am having trouble setting up a c# application that creates and interacts with a python process1. A simplistic example is given below. EDIT: Further research on SO unveiled that my question is a possible duplicate. A potentially related known bug in the .NET Framework is duscussed here and here. It seems that back in 2014 the only easy workaround is

Nodejs child_process spawn calling python script with sleep

烂漫一生 提交于 2019-12-12 00:26:47
问题 I'm testing on nodejs child_process module to read the stdout from my python script. However, I noticed when my python emit message between every second. The nodejs callback can only collect the stdout at the end of the python script ends. Python Script import time for i in range(0,5): ····print i ····time.sleep(0.5) and the nodejs script is var cp = require('child_process'); var spw = cp.spawn('python', ['tql.py']), str = ""; spw.stdout.on('data', function (data) { str+= data; console.log

Intercepting console output which originated from Tess4J

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 23:44:31
问题 I am trying to intercept the red Empty page!! message that gets printed to my screen when using Tess4J . I wrote a short interceptor class that overrides print and println and replaced stdout and stderr to check for this string: private static class Interceptor extends PrintStream { public Interceptor(OutputStream out) { super(out, true); } @Override public void print(String s) { if ( !s.contains("Empty page!!") ) super.print(s); } @Override public void println(String s) { if ( !s.contains(

Display stderr in a pyqt QMessageBox

喜你入骨 提交于 2019-12-11 22:08:11
问题 I want to capture stderr output from my PyQt script and display it in a QMessageBox. I found these posts and tried them, but none really worked for me: Display python console messages in QMessageBox Redirecting stdout and stderr to a PyQt4 QTextEdit from a secondary thread PYQT: How to capture output of python's interpreter and display it in QEditText? I was having a couple problems. First, a single error seems to be sent as a series of separate stderr messages (at least in Python 3.4). This

Python3 - ascii/utf-8/iso-8859-1 can't decode byte 0xe5 (Swedish characters)

一个人想着一个人 提交于 2019-12-11 21:23:15
问题 I've tried io , repr() etc, they don't work! Problem inputting å ( \xe5 ) : (None of these work) import sys print(sys.stdin.read(1)) sys.stdin = io.TextIOWrapper(sys.stdin.detach(), errors='replace', encoding='iso-8859-1', newline='\n') print(sys.stdin.read(1)) x = sys.stdin.buffer.read(1) print(x.decode('utf-8')) They all give me roughly UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe5 in position 0: unexpected end of data Also tried starting Python with: export PYTHONIOENCODING=utf

How can I suppress Unix's “command not found” output?

假装没事ソ 提交于 2019-12-11 18:18:54
问题 My goal: when I type in something that's not a valid Unix command, it gets fed to a special function instead of displaying the "Command not found" message. I found this post, which got me halfway there. trap 'if ! type -t $BASH_COMMAND >/dev/null; then special_function $BASH_COMMAND; fi' DEBUG This allows me to run my special function. However the "Command not found" error still appears afterwards. Is there any way I can tell Bash to suppress that message? Either in this command, or inside

bash - redirect specific output from 2nd script back to stdin of 1st program?

☆樱花仙子☆ 提交于 2019-12-11 13:23:37
问题 I have a little program, let's call it "program" by simplicity which has "normal" behaviour. It takes information from the stdin (normally typed in by the user in the keyboard) and prints out via stdout/stderr. I want to automate a process and therefore redirect stdout/stderr into "my little bash script" (which could also be another program in C/C++). It takes it as it's standard input and filters it. This means leaving out unimportant information.. and adding further information generated by

stderr and stdout - not buffered vs. buffered?

人盡茶涼 提交于 2019-12-11 13:14:01
问题 I was writing a small program that had various console output strings depending upon different events. As I was looking up the best way to send these messages I came across something that was a bit confusing. I have read that stderr is used to shoot messages directly to the console - not buffered . While, in contrast, I read that stdout is buffered and is typically used to redirect messages to various streams? , that may or may not be error messages, to an output file or some other medium.

Paramiko - Running commands in “background”

萝らか妹 提交于 2019-12-11 13:05:41
问题 I've successfully implemented Paramiko using exec_command, however, the command I'm running on the remote machine(s) can sometimes take several minutes to complete. During this time my Python script has to wait for the remote command to complete and receive stdout. My goal is to let the remote machine "run in the background", and allow the local Python script to continue once it sends the command via exec_command. I'm not concerned with stdout at this point, I'm just interested in bypassing

The stdout/stderr in python notebooks

前提是你 提交于 2019-12-11 12:16:30
问题 I'm using python 3 and recently I was able to interface a FORTRAN solver for some type of optimization problems (thanks to eryksun here on stack overflow). The little issue that is getting on the way is that the solver output in the python notebook (jupyter) does not show up. Note that the solver returns the right solution, but it doesn't display its progress nor any mesages. Although, if call the same FORTRAN solver from a julia notebook, I can see the output in the julia notebook. The