I’m writing a small Python script under Linux that pops up a number of libnotify pop-ups, currently by using the following syntax:
import os
os.execv('/usr/bin/notify-send', ['App Title', 'Message'])
Unfortunately, and for some strange reason, it kills the interpreter right out to the command-prompt.
It doesn’t do this with any other command the script executes, just notify-send.
There’s no error given, no known exception thrown, no indication of anything wrong, it just dies out to the command prompt.
Does anyone have suggestions or alternatives that equally easy to do?
You should use
subprocess.callwhich starts the program named by its arguments in a new process and waits for the child process to exit rather thanos.execvwhich replaces what is running in the current process with the program specified by its arguments.The usage is
subprocess.call(['/usr/bin/notify-send', 'App Title', 'Message'])