Redirecting stdout/stderr to a file?

24 views
Skip to first unread message

Demetrios Tsillas

unread,
Aug 1, 2019, 11:50:51 AM8/1/19
to PyInstaller
I have some warning which pop up on the console when I run my app and would like to redirect these to either /dev/null or to a log file under /tmp.

I've tried:

    if sys.platform == "linux2":
        sys.stdout = open('/tmp/InstrumentationBrowser.log', 'w')
        sys.stderr = sys.stdout

Unfortunately I still see the warnings:

$ InstrumentationBrowser ~/BB.dat &
[2] 35873
[1]   Done                    InstrumentationBrowser ~/BB.dat
 $ 
(InstrumentationBrowser:35875): Gtk-WARNING **: 11:43:08.556: Could not load a pixbuf from icon theme.
This may indicate that pixbuf loaders or the mime database could not be found.

 $ 

Is there anything in pyinstaller which may help me?

thanks!!!
-Jim.

Hartmut Goebel

unread,
Aug 1, 2019, 12:11:13 PM8/1/19
to pyins...@googlegroups.com
Hi,

$ InstrumentationBrowser ~/BB.dat &
[2] 35873
[1]   Done                    InstrumentationBrowser ~/BB.dat
 $ 
(InstrumentationBrowser:35875): Gtk-WARNING **: 11:43:08.556: Could not load a pixbuf from icon theme.
This may indicate that pixbuf loaders or the mime database could not be found.

Obviously this warning stems from a C library, which writes to the processes stderr I assume.

sys.stderr is nit the processes stderr, as you can verify with the example below. Thus you need to find a way to change the processes stderr. This is not related to PyInstaller. Anyway if you solve the puzzle blow, please post a solution.

import sys
import subprocess
with open("/tmp/x.log", "w") as sys.stderr:
    subprocess.call("echo foo >&2", shell=True)


--
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software Development

Goebel Consult, Landshut
http://www.goebel-consult.de

Blog: https://www.goe-con.de/blog/e-mails-weiterhin-verschlusseln
Kolumne: https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2012-02-bring-your-own-life-glosse

0x7B752811BF773B65.asc
Reply all
Reply to author
Forward
0 new messages