stdout

Differentiate between error and standard terminal log with ffmpeg - nodejs

|▌冷眼眸甩不掉的悲伤 提交于 2020-02-21 10:27:34
问题 I'm using ffmpeg in node js. Both the standard terminal output and the error seems to be sent to stdout, so I don't know how to differentiate between error and success... Here's my code: var convertToMp3 = function(filePath) { var ffmpeg = child_process.spawn('ffmpeg',['-i', filePath, '-y', 'output.mp3']); var err = ''; ffmpeg.stderr .on('data', function(c) { err += c; }) .on('end', function() { console.log('stderr:', err); }); var d = ''; ffmpeg.stdout .on('data', function(c){d +=c;}) .on(

Receiving contiinuous output from python spawn child process not working

北城以北 提交于 2020-02-06 07:29:46
问题 I am attempting to stream output from a weighing scale that is written in python. This program (scale.py) runs continuously and prints the raw value every half second. import RPi.GPIO as GPIO import time import sys from hx711 import HX711 def cleanAndExit(): print "Cleaning..." GPIO.cleanup() print "Bye!" sys.exit() hx = HX711(5, 6) hx.set_reading_format("LSB", "MSB") hx.reset() hx.tare() while True: try: val = hx.get_weight(5) print val hx.power_down() hx.power_up() time.sleep(0.5) except

Using fileinput (Python) for a search-and-replace while also sending messages to console

人盡茶涼 提交于 2020-02-01 05:58:28
问题 I have lines for line in fileinput.input(file_full_path, inplace=True): newline, count = re.subn(search_str, replace_str, line.rstrip()) # ... display some messages to console ... print newline # this is sent to the file_full_path which are supposed to replace all occurrences of search_str in the file file_full_path and replace them with replace_str . The fileinput maps stdout to the given file. So, print newline and things sent to sys.stdout are sent to the file and not to the console. I

Using fileinput (Python) for a search-and-replace while also sending messages to console

允我心安 提交于 2020-02-01 05:55:15
问题 I have lines for line in fileinput.input(file_full_path, inplace=True): newline, count = re.subn(search_str, replace_str, line.rstrip()) # ... display some messages to console ... print newline # this is sent to the file_full_path which are supposed to replace all occurrences of search_str in the file file_full_path and replace them with replace_str . The fileinput maps stdout to the given file. So, print newline and things sent to sys.stdout are sent to the file and not to the console. I

qt printing to terminal

时光怂恿深爱的人放手 提交于 2020-01-30 12:01:41
问题 In my QT application, I want to have it so some real-time information prints in the terminal if I run the application from the terminal. When I use printf("print this") (either in main or during the paint event), it doesn't print until I close the gui. Why is this, and how can I have it print information in real-time? (I'm using linux) Thanks! 回答1: To write to stdout, you should add this CONFIG += console to your project file config and use cout of printf for your liking. qDebug prints by

qt printing to terminal

别等时光非礼了梦想. 提交于 2020-01-30 12:00:14
问题 In my QT application, I want to have it so some real-time information prints in the terminal if I run the application from the terminal. When I use printf("print this") (either in main or during the paint event), it doesn't print until I close the gui. Why is this, and how can I have it print information in real-time? (I'm using linux) Thanks! 回答1: To write to stdout, you should add this CONFIG += console to your project file config and use cout of printf for your liking. qDebug prints by

PyQt5 - TypeError: signal has 0 argument(s) but 1 provided

寵の児 提交于 2020-01-30 03:28:27
问题 I am trying to redirect "sys.stdout" to QTextEdit , here is my code: class Communicate(QObject): printText = pyqtSignal() def write(self, text): self.printText.emit(str(text)) class UI(QWidget): def __init__(self, parent = None): QWidget.__init__(self) ... self.textedit = QTextEdit(self) self.textedit.setGeometry(400,20,220,300) self.c = Communicate() self.c.printText.connect(self.textedit.insertPlainText) sys.stdout = self.c if __name__ == "__main__": ... When I ran the code, I got TypeError

PyQt5 - TypeError: signal has 0 argument(s) but 1 provided

独自空忆成欢 提交于 2020-01-30 03:28:09
问题 I am trying to redirect "sys.stdout" to QTextEdit , here is my code: class Communicate(QObject): printText = pyqtSignal() def write(self, text): self.printText.emit(str(text)) class UI(QWidget): def __init__(self, parent = None): QWidget.__init__(self) ... self.textedit = QTextEdit(self) self.textedit.setGeometry(400,20,220,300) self.c = Communicate() self.c.printText.connect(self.textedit.insertPlainText) sys.stdout = self.c if __name__ == "__main__": ... When I ran the code, I got TypeError

In Go, how do I capture stdout of a function into a string?

…衆ロ難τιáo~ 提交于 2020-01-26 12:53:06
问题 In Python, for example, I can do the following: realout = sys.stdout sys.stdout = StringIO.StringIO() some_function() # prints to stdout get captured in the StringIO object result = sys.stdout.getvalue() sys.stdout = realout Can you do this in Go? 回答1: I agree you should use the fmt.Fprint functions if you can manage it. However, if you don't control the code whose output you're capturing, you may not have that option. Mostafa's answer works, but if you want to do it without a temporary file

In Go, how do I capture stdout of a function into a string?

和自甴很熟 提交于 2020-01-26 12:48:52
问题 In Python, for example, I can do the following: realout = sys.stdout sys.stdout = StringIO.StringIO() some_function() # prints to stdout get captured in the StringIO object result = sys.stdout.getvalue() sys.stdout = realout Can you do this in Go? 回答1: I agree you should use the fmt.Fprint functions if you can manage it. However, if you don't control the code whose output you're capturing, you may not have that option. Mostafa's answer works, but if you want to do it without a temporary file