Mercurial > ~darius > hgwebdir.cgi > py-iview
comparison 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 |
comparison
equal
deleted
inserted
replaced
1:f914f08d69f5 | 2:6edc508e0775 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 import iview | 3 import iview |
4 import os.path | |
5 import re | |
4 import subprocess | 6 import subprocess |
5 import sys | 7 import sys |
6 import time | 8 import time |
7 | 9 |
8 outpath = '.' | 10 outpath = '.' |
9 outext = 'flv16x9' | 11 outext = 'flv16x9' |
10 flvstreamerpath = '/home/darius/projects/flvstreamer/flvstreamer_x86' | 12 flvstreamerpath = '/home/darius/projects/flvstreamer/flvstreamer_x86' |
13 flvpattern = re.compile("FLVStreamer v") | |
11 | 14 |
12 def listChannels(iview): | 15 def listChannels(iview): |
13 i = 1 | 16 i = 1 |
14 print "Id %-30s %-35s" % ('Name', 'Description') | 17 print "Id %-30s %-35s" % ('Name', 'Description') |
15 for c in iview.channels: | 18 for c in iview.channels: |
46 res = p.poll() | 49 res = p.poll() |
47 if res == None: | 50 if res == None: |
48 time.sleep(0.1) | 51 time.sleep(0.1) |
49 else: | 52 else: |
50 return res | 53 return res |
51 | 54 |
55 def checkFLVStreamer(): | |
56 try: | |
57 s = subprocess.Popen(flvstreamerpath, stdout = subprocess.PIPE, stderr = subprocess.PIPE) | |
58 except OSError: | |
59 print "Couldn't execute FLVstreamer" | |
60 return False | |
61 while s.poll() != 1: | |
62 time.sleep(0.1) | |
63 | |
64 out, err = s.communicate() | |
65 if flvpattern.match(err) == None: | |
66 print "Unrecognised output from FLVstreamer" | |
67 return False | |
68 | |
69 return True | |
70 | |
52 if __name__ == "__main__": | 71 if __name__ == "__main__": |
72 if not checkFLVStreamer(): | |
73 sys.exit(1) | |
74 | |
53 iview = iview.IView() | 75 iview = iview.IView() |
54 if iview.metered: | 76 if iview.metered: |
55 print "WARNING: iview is metered" | 77 print "WARNING: iview is metered" |
56 print | 78 print |
57 | 79 |