stdout

Stdout stops showing in QTextEdit once another window has opened

*爱你&永不变心* 提交于 2019-12-14 03:04:15
问题 I am trying to get stdout and error messages to show on my main window. The window is by pyqt and made via designer. I have a QTextEdit on it. This is where the output should show itself. Also I have a dialog box (again made via designer) where i set some settings for my program before running it. The dialog box is opened like this: def open_settings(self): dialog = SettingsDialog() dialog.open_settings_tab() # its on a tab widget I already read and used the info on these links to achieve my

Reading stdout from one program in another program

谁都会走 提交于 2019-12-14 02:17:06
问题 I have a problem concerning the reading of the stdout in python. I have to explain a bit what I am trying to do. I have a Python program ( foo ); this calls a second python program ( bar ). bar will give back to stdout status details and other information to be logged. The foo now has to read this. In principle it works. I can grab the output of bar and send it to a log file without any problems. The problems start when I try to look for certain phrases in the output from bar (the status

Smart way to format tables on stdout in C

China☆狼群 提交于 2019-12-14 00:25:47
问题 I am trying to write table to stdout with numerical data. I would like to format so that numbers are aligned like: 1234 23 312 2314 12 123 I know that max length of the number is 6 chars, is there a smart way to know how many spaces needs to be output before number so it looks exactly like this? 回答1: printf may be the quickest solution: #include <cstdio> int a[] = { 22, 52352, 532 }; for (unsigned int i = 0; i != 3; ++i) { std::printf("%6i %6i\n", a[i], a[i]); } Prints: 22 22 52352 52352 532

Ignoring the first line of stderr and keeping stdout intact

会有一股神秘感。 提交于 2019-12-13 21:03:02
问题 mongodump prints a single debug message to stderr every time it is run, which is causing some unintended side effects. How do I ignore only the first line of stderr and keep everything else intact? I'm piping stdout to a file, so I can't combine stderr and stdout. 回答1: Using a process substitution, and piping stdout into rev to see that stderr is unaffected { echo stderr1 >&2; echo stdout1; echo stderr2 >&2; } 2> >(sed 1d >&2) | rev 1tuodts stderr2 来源: https://stackoverflow.com/questions

How to respond to a command line promt with node.js

喜你入骨 提交于 2019-12-13 19:16:32
问题 How would I respond to a command line prompt programmatically with node.js? For example, if I do process.stdin.write('sudo ls'); The command line will prompt for a password. Is there an event for 'prompt?' Also, how do I know when something like process.stdin.write('npm install') is complete? I'd like to use this to make file edits (needed to stage my app), deploy to my server, and reverse those file edits (needed for eventually deploying to production). Any help would rock! 回答1: You'll want

Truncated output log files when logging stdout and stderr separately

巧了我就是萌 提交于 2019-12-13 16:19:54
问题 I have set up a subprocess command within a context manager that pipes the stdout and stderr to separate files via my own logger. This is a variation on the answer given here: https://stackoverflow.com/a/4838875/4844311 My code is as follows: import logging import subprocess with StreamLogger(logging.DEBUG, my_out_logger) as out: with StreamLogger(logging.ERROR, my_err_logger) as err: p = subprocess.Popen(cmd, shell=False, stdout=out, stderr=err) p.communicate() p.wait() where my_out_logger

Notice: Use of undefined constant STDOUT - assumed 'STDOUT'

我只是一个虾纸丫 提交于 2019-12-13 12:23:43
问题 I am trying to set up Amazon Aws Php SDK in Xampp. After installing the SDK, I am trying to download a bucket from Amazon S3, using the following code. <?php error_reporting(-1); ini_set('display_errors', 'on'); include_once ('aws/aws-autoloader.php'); use Aws\S3\S3Client; $client = S3Client::factory(array( 'key' => '__my__key__', 'secret' => '__secret__key__' )); $destination = 'downloaded_bucket'; $source_bucket = '__my__bucket__name'; $key_prefix = ''; $options = array('debug'=>true);

Printing to STDOUT and log file while removing ANSI color codes

£可爱£侵袭症+ 提交于 2019-12-13 12:05:09
问题 I have the following functions for colorizing my screen messages: def error(string): return '\033[31;1m' + string + '\033[0m' def standout(string): return '\033[34;1m' + string + '\033[0m' I use them as follows: print error('There was a problem with the program') print "This is normal " + standout("and this stands out") I want to log the output to a file (in addition to STDOUT) WITHOUT the ANSI color codes, hopefully without having to add a second "logging" line to each print statement. The

How to pipe tar.extractall from python

风流意气都作罢 提交于 2019-12-13 07:13:56
问题 I'm extracting a tarball using the tarfile module of python. I don't want the extracted files to be written on the disk, but rather get piped directly to another program, specifically bgzip. I'm also trying to use StringIO for that matter, but I get stuck even on that stage - the tarball gets extracted on the disk. #!/usr/bin/env python import tarfile, StringIO tar = tarfile.open("6genomes.tgz", "r:gz") def enafun(members): for tarkati in tar: if tarkati.isreg(): yield tarkati reles =

Output from python console

家住魔仙堡 提交于 2019-12-13 05:36:50
问题 I have the following problem, I have separate python functions in different files. That I call when I need them. Currently, I am trying to create gui with tkinter and I need to display output from functions that I call. Since I suppose to read what python console generates I tried to use subprocess but it didn't work out, I suppose I have to read stdout and then pass it to tkinter listbox, but methods that I tried didn't work. from Tkinter import * import ConfigParser, sys import subprocess