I am attempting to open an image and a text file that my Python (3.3.2) program is creating (the files are created without issue). The last two lines of the program are:subprocess.call(['leafpad', filename + '.tsv'])subprocess.call(['gpicview',filename + '_fig.png'])The text file is successfully opened, with the following warnings returned to the terminal:(leafpad:3676): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-menu-bar-popup-delay after class was initialised(leafpad:3676): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-label-select-on-focus after class was initialised(leafpad:3676): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-can-change-accels after class was initialised(leafpad:3676): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-menu-popup-delay after class was initialised(leafpad:3676): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-menu-popdown-delay after class was initialised(leafpad:3676): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-menu-images after class was initialised(leafpad:3676): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-scrolled-window-placement after class was initialisedThe image file does not open until I close the text file window, and then returns the following similar warnings to the terminal:(gpicview:3682): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-scrolled-window-placement after class was initialised(gpicview:3682): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-button-images after class was initialised(gpicview:3682): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-label-select-on-focus after class was initialisedThrough reading other threads online, I've figured out that the warnings aren't an issue for me (just something that most likely exists as a result of the latest dist, warnings don't really bother me). My problem is primarily that the warnings (it would appear) are preventing the script from continuing along and opening the image viewer as well, and secondarily cluttering up the terminal in a way that looks rather unprofessional. Thanks for any help you could offer in suppressing these warnings and getting both the text editor window and the image viewer window to open simultaneously and without a mess of warnings on my terminal.
Warnings when opening programs via Python subprocess calls
python
Your current method means two things are happening:You are seeing the output of subproccessprocesses can have a few outputs, here are two that can occur:STDOUT - information from the program being runSTDERR - information on warnings errors the program has encountered. This is probably the one that is annoying you.Using options on the subprocess should mean you can pipe the outputs to /dev/null (i.e. the won't appear in the output):DEVNULL = open(os.devnull, 'wb')subprocess.call(['leafpad', filename + '.tsv'], stdout=DEVNULL, stderr=DEVNULL)This is the version for python 2.4+, the bit defining DEVNULL may not be needed in 3.3+Note that even if you remove hide all the output it will still wait for the process, so....and it waits for the processes to finish before continuingIf you want to get the process to continue in the background, you can use this:subprocess.Popen(['leafpad', filename + '.tsv'])Popen does not wait for the process to exit, so it will continue in the background (unlike call) - for more info see here.Putting these 'fixes' together should give you:DEVNULL = open(os.devnull, 'wb')subprocess.Popen(['leafpad', filename + '.tsv'], stdout=DEVNULL, stderr=DEVNULL)For python 2.4+ againYou can get more information from the documentation here.I am a amateur at python whose version of leafpad gives no errors, so if anything does not work please say :)