stdout

Capturing output into a python script from another python script with subprocess

ぐ巨炮叔叔 提交于 2020-01-07 02:57:20
问题 This is running on Windows Vista Home 32b with Service Pack 2 I am actively testing it on Mac, and Linux I have one python script [A] that uses subprocess to run another python script [B] process = subprocess.Popen(action, stdin=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=-1) out = process.stdout.readline() print out I use [A] to run [B] [B] comes from the command line, so can be any script what so ever when [B] is a the following python script #file = 'bufftest.py" msg = "X" x = 1024 y

Accessing stdout when using “time” in python subproces

大城市里の小女人 提交于 2020-01-06 18:05:32
问题 I have been doing some manual benchmark tests in my shell using the time command. I would like to scale my benchmarks by writing a python script that both automates the tests and affords me access to the time data so that I can record it in the format of my choosing (likely a csv). I see there is the timeit module, but that seems like it is more for benchmarking python code, where what I am trying to benchmark here are programs run in the command line. This is what I have been doing manually:

fprintf both to file and to stdout [duplicate]

大憨熊 提交于 2020-01-06 14:40:57
问题 This question already has answers here : How to print both to stdout and file in C (4 answers) Closed 5 years ago . My C program is expected to produce a lot of output. Some of these output lines are special and I would like to write a copy to a special file. I end up doing FILE * outf = fopen("special_file", "a"); fprintf(stdout, "normal line 1\n"); fprintf(stdout, "special line!\n"); fprintf(outf, "special line!\n");/*inelegant & dangerous code duplication*/ fprintf(stdout, "normal line 2\n

Can I Have xlwings Display Console Output?

痴心易碎 提交于 2020-01-06 09:01:46
问题 Is it possible for xlwings to pop up a console while running a script from VBA and show stdout? I know xlwings writes the stdout to a logfile which is useful, but I'd like to give users some updates while they are waiting for their calculation to finish. The debugger kind of does this but seems like overkill. 回答1: If you are using UDFs, then there is a simple possibility: By default xlwings uses the pythonw interpreter. Just change it to python and the console window will pop up. For

Stdout race condition between script and subscript

☆樱花仙子☆ 提交于 2020-01-06 08:49:17
问题 I'm trying to call a script deepScript and process its output within another script shallowScript ; it looks schematically like the following pieces of code: shallowScript.sh #!/bin/zsh exec 1> >( tr "[a-z]" "[A-Z]" ) print "Hello - this is shallowScript" . ./deepScript.sh deepScript.sh #!/bin/zsh print "Hello - this is deepScript" Now, when I run ./shallowScript.sh , the outcome is erratic : either it works as expected (very rarely), or it prints an empty line followed by the two expected

Printing to main stdout in IPython Notebook from other parallel engines

萝らか妹 提交于 2020-01-05 10:27:18
问题 I am currently working in an IPython Notebook. I am running a function across different engines and would like to see what it prints. Example: def simple(a): print a+40; return a+20 A = range(20); dview.map_sync(simple, A); I would like this functionality because I'm running a function that runs for a long time and I am using print statements to keep track of its progress. 来源: https://stackoverflow.com/questions/16430827/printing-to-main-stdout-in-ipython-notebook-from-other-parallel-engines

Is contextlib.redirect_stdout always a good idea?

烂漫一生 提交于 2020-01-04 05:43:27
问题 Since I've learned of the pattern, I've been using with open('myfile.txt','w') as myfile: with contextlib.redirect_stdout(myfile): # stuff print(...) # gets redirected to file This lets me use the print syntax (which I prefer) to write to files and I can easily comment it out to print to screen for debug. However, by doing this, I am removing my ability to both write to file and to the screen, and possibly writing less clear code. Are there any other disadvantages I should know about, and is

Pipe a stream to Debug.Write()

二次信任 提交于 2020-01-04 04:31:05
问题 I am running a command line utility using Process.Start . For debugging purposes I would like to have its output stream to Visual Studio's Debug Output panel ( Debug.Write ). I'd like to do this in real time rather than waiting for the process to complete and then writting it all at once. I know this is possible in theory but I'm not experienced enough with the Stream object to know how to do this. 回答1: This may not be exactly what you want, but it puts you on the right track, I think. p

Is there an stdbuf equivalent for Windows 7 command prompt?

一世执手 提交于 2020-01-04 03:25:14
问题 So gnu has stdbuf which allows you to modify buffering of a command's I/O stream. I need the same functionality for command prompt but I can't seem to find anything about it. I'm simply trying to output both stdout and stderr of a program, to a logfile, without buffering (or rather, just so that they are in sync and in the same order they would be displayed as in the console). Did I just miss some obvious command or syntax, or am I just out of luck in windows? 回答1: Take a look at this. I don

Unix/C++: Open new terminal and redirect output to it

纵然是瞬间 提交于 2020-01-03 17:39:37
问题 My program (C++ on Solaris 10) writes output via wcout to its terminal when it is started from a shell. But when I execute it from within Sun Studio or the file manager is does not have a terminal and the ouput appears in the Sun Studio output window or nowhere at all. I would like it to open its own terminal window in any of the three cases and attach wcout to this terminal window. I want this to be done be the program itself with C++ system calls not by the way how the program is executed