Mercurial > ~darius > hgwebdir.cgi > py-iview
diff iviewget.py @ 2:6edc508e0775
Try and run flvstreamer on init and exit if it fails.
It's very annoying if we go and select a bunch of stuff and the user hasn't remember to edit the path for it..
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Thu, 20 Aug 2009 17:34:50 +0930 |
parents | fa7ca67af8c9 |
children | 34471d354603 |
line wrap: on
line diff
--- a/iviewget.py Thu Aug 20 17:33:35 2009 +0930 +++ b/iviewget.py Thu Aug 20 17:34:50 2009 +0930 @@ -1,6 +1,8 @@ #!/usr/bin/env python import iview +import os.path +import re import subprocess import sys import time @@ -8,6 +10,7 @@ outpath = '.' outext = 'flv16x9' flvstreamerpath = '/home/darius/projects/flvstreamer/flvstreamer_x86' +flvpattern = re.compile("FLVStreamer v") def listChannels(iview): i = 1 @@ -48,8 +51,27 @@ time.sleep(0.1) else: return res - + +def checkFLVStreamer(): + try: + s = subprocess.Popen(flvstreamerpath, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + except OSError: + print "Couldn't execute FLVstreamer" + return False + while s.poll() != 1: + time.sleep(0.1) + + out, err = s.communicate() + if flvpattern.match(err) == None: + print "Unrecognised output from FLVstreamer" + return False + + return True + if __name__ == "__main__": + if not checkFLVStreamer(): + sys.exit(1) + iview = iview.IView() if iview.metered: print "WARNING: iview is metered"