Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

suppress/redirect stderr when calling python webrowser

I have a python program that opens several urls in seperate tabs in a new browser window, however when I run the program from the command line and open the browser using

webbrowser.open_new(url)

The stderr from firefox prints to bash. Looking at the docs I can't seem to find a way to redirect or suppress them

I have resorted to using

browserInstance = subprocess.Popen(['firefox'], stdout=log, stderr=log)

Where log is a tempfile & then opening the other tabs with webbrowser.open_new.

Is there a way to do this within the webbrowser module?

like image 963
David Miller Avatar asked Aug 29 '09 21:08

David Miller


1 Answers

What is webbrowser.get() giving you?

If you do

 webbrowser.get('firefox').open(url)

then you shouldn't see any output. The webbrowser module choses to leave stderr for some browsers - in particular the text browsers, and then ones where it isn't certain. For all UnixBrowsers that have set background to True, no output should be visible.

like image 139
Martin v. Löwis Avatar answered Oct 05 '22 11:10

Martin v. Löwis