stdout

How to redirecting “stdout” to a Label widget?

只愿长相守 提交于 2019-12-22 06:32:53
问题 I am trying to redirect stdout to a Label widget. The goal is to "print" into the Label all the Python prints that are in my script. But when I click on BUTTON1 nothing happens... Here is my code: from Tkinter import * import sys import tkMessageBox class App: def __init__(self, master): self.frame = Frame(master, borderwidth=5, relief=RIDGE) self.frame.grid() class IORedirector(object): def __init__(self,TEXT_INFO): self.TEXT_INFO = TEXT_INFO class StdoutRedirector(IORedirector): def write

Python standard idiom to set sys.stdout buffer to zero doesn't work with Unicode

為{幸葍}努か 提交于 2019-12-22 05:39:07
问题 When I'm writing sysadmin scripts in Python, the buffer on sys.stdout that effects every call to print() is annoying, because I don't want to wait for a buffer to be flushed and then get a big chunk of lines at once on the screen, instead I want to get individually lines of output as soon as new output is generated by the script. I don't even want to wait for newlines so see the output. An often used idiom to do this in python is import os import sys sys.stdout = os.fdopen(sys.stdout.fileno()

windows console program stdout is buffered when using pipe redirection

女生的网名这么多〃 提交于 2019-12-22 05:10:56
问题 i have a long run server program(say, program A) which is written in QT/c++. the program is not so stable so i decide to write a python script to restart it if it crashes. the problem is that the program may started fail(if i gave it an in-use port), print the error and then just hang there without quitting, so i must monitor the stdout of the program and kill it on failed startup. this is a piece of my final code (well, in fact this is ok, you can just ignore it): self.subp = subprocess

C# console application stdin/stdout redirection

一曲冷凌霜 提交于 2019-12-22 05:09:15
问题 I have an interesting (read: frustrating) problem kicking off a console application from a C# WPF app and redirecting its stdin and stdout. It is mostly up and working but I seem to end up not getting some data from stdout as soon as I start redirecting stdin. I'll clarify with an example. If I don't set hStdInput in the STARTUPINFO structure, when I start the child process I receive the following: MongoDB shell version: 2.2.0 connecting to: test local:PRIMARY> Once I set hStdInput however, I

Can an Adobe AIR Application run via the command line output to console?

老子叫甜甜 提交于 2019-12-22 05:01:13
问题 I have an AIR application that takes command-line arguments via onInvoke. All is good, but I cannot figure out how to print some status messages back to the user (to stdout / console, so to speak). Is it possible? Even a default log file for traces would be fine, but I can't find any info about it anywhere. Do I need to create my own log file? Now that'd be silly. 回答1: Take a look at CommandProxy. It is a low level wrapper around your AIR application that lets you send command from AS3 back

python - how can I redirect the output of unittest? Obvious solution doesn't work

♀尐吖头ヾ 提交于 2019-12-22 04:59:10
问题 Here is my code: import unittest import sys import os class DemoTest(unittest.TestCase): def test_one(self): print "test one" self.assertTrue(True) def test_two(self): print "test two" self.assertTrue(False) if __name__ == '__main__': dirpath = os.path.dirname(os.path.abspath(__file__)) sys.stdout = open(dirpath+'/test_logs/demo_test.stdout.log', 'w') sys.stderr = open(dirpath+'/test_logs/demo_test.stderr.log', 'w') test_program = unittest.main(verbosity=0, exit=False) When I run this, the

Stdout of Node.js child_process exec is cut short

和自甴很熟 提交于 2019-12-22 03:30:28
问题 In Node.js I'm using the exec command of the child_process module to call an algorithm in Java that returns a large amount of text to standard out which I then parse and use. I'm able to capture it mostly, but when it exceeds a certain number of lines, the content is cutoff. exec("sh target/bin/solver "+fields.dimx+" "+fields.dimy, function(error, stdout, stderr){ //do stuff with stdout } I've tried using setTimeouts and callbacks but haven't succeeded but I do feel this is occurring because

Capturing stdout from unmanaged DLL in C# caller

二次信任 提交于 2019-12-21 21:46:31
问题 I have a C# application calling a native C++ DLL via some C++/CLI marshalling code: C# --> C++/CLI --> C++ (no CLR) I want the DLL to post string updates back to the calling application while it is running. Currently the unmanaged DLL writes output to stdout. Essentially I need to capture this output in the UI. In other cases where I am shelling an unmanaged exe this can be achieved by simply redirecting stdout from the callee to a string buffer in the UI data bound to a text panel. I do not

Sending strings between to Python Scripts using subprocess PIPEs

岁酱吖の 提交于 2019-12-21 20:16:10
问题 I want to open a Python script using subprocess in my main python program. I want these two programs to be able to chat with one another as they are both running so I can monitor the activity in the slave script, i.e. I need them to send strings between each other. The main program will have a function similar to this that will communicate with and monitor the slave script: Script 1 import subprocess import pickle import sys import time import os def communicate(clock_speed, channel_number,

Read another process' stdout in C++

拟墨画扇 提交于 2019-12-21 09:37:11
问题 In Windows, is there a way to launch a process in C++ and then read what it spat out into stdout when it's done? The process must be run using elevated privileges (on Vista or later) if necessary. I'm currently using ShellExecuteEx() to launch the process and running a while-loop until GetExitCodeProcess() no longer returns STILL_ACTIVE via the lpExitCode parameter (with a WaitForSingleObject() call doing a 100 msec wait during each iteration). 回答1: There's no easy way to do this. Calling