I have a python cgi/html that takes url and launches on epiphany-browser. However, after the media/video is over, I need the browser to terminate. On other posts, it seems there are ways to do this with vlc-media and other players. But I haven't found one with a browser.
Basic framework around the command looks like:
msg = form.getvalue("msg", "(no msg)")
.......
## in-progress of msg = "sudo -u vnc " + msg + " "
.......
from subprocess import *
print Popen(msg, shell=True, stdin=PIPE, stdout=PIPE).communicate()[0]
How do I implement such that the command (url) that gets executed shuts down after the streaming(youtube,cnn, etc) has been finished?
Thanks.
The simplest way to do this would be to use
pkill
. As you're looking to kill an instance ofepiphany
, a browser in the Unix family of operating systems, you'd use something like:If you executable is named something other than
epiphany-browser
change the second part of thepkill
command to match.Also bear in mind this will kill all processes with that name. To only kill the newest you can do something like:
If you want to be really clever, you can try to graph the actual process number after you launch it:
Also you should probably use the
webbrowser
object rather than opening withPopen
. It lacks aclose
as far as I understand from the documentation, but for opening sessions it's the preferred solution.Epiphany
is supported via theGaleon
object:20.1. webbrowser — Convenient Web-browser controller