1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
#!/usr/bin/python2
import subprocess
import socket,sys
import urllib2
from MythTV import MythBE,MythDB,MythLog
def find_slave_hosts():
slave_hosts=[]
try:
be=MythBE()
db = MythDB()
cursor = db.cursor()
except:
return slave_hosts
try:
cmd="select hostname from settings where data='Slave_backend';"
cursor.execute(cmd)
results=cursor.fetchall()
for i in results:
slave_hosts.append(i[0])
except:
return slave_hosts
return slave_hosts
def read_local_tuner():
tuner_list = []
exportfile = '/etc/udev/mv-persistent-video.description'
try:
f = open(exportfile,"r")
for line in f.readlines():
if line.startswith("#"):
continue
item = line.split(":")
if len(item) <= 1 :
continue
tuner_list.append(item)
except :
tuner_list.append(["notfound","notfound","notfound"])
return tuner_list
def parse_remote_tuners(the_page):
tuner_list=[]
the_page = the_page.split("\n")
try:
for line in the_page:
if line.startswith("#"):
continue
item = line.split(":")
if len(item) <= 1 :
continue
tuner_list.append(item)
except :
tuner_list.append(["notfound","notfound","notfound"])
return tuner_list
def remote_tuners(slave_host):
default_timeout = 3
socket.setdefaulttimeout(default_timeout)
slaveurl="http://%s:1337/cardlist.cgi" %slave_host
req = urllib2.Request(slaveurl)
response = urllib2.urlopen(req)
the_page = response.read()
#the_page="abc\nadef\na"
if the_page :
tuner_list = parse_remote_tuners(the_page)
print "</br>"
for statictuner in tuner_list:
if statictuner[1].find("notfound") > -1 :
print "Couldn't open tuner map"
print "</br>"
else:
print "<li> %s  %s" %(statictuner[1] ,statictuner[0])
print "</br>"
print " static device node: %s" %statictuner[2]
print "</br>"
print "</br>"
else:
print "<li> no tuners found  "
return
mbelist = read_local_tuner()
slave_hosts = find_slave_hosts()
#--------------MBE-------------
hostname = socket.gethostname()
print "</br>"
print "<h2>"
print "__________ %s __________" %(hostname)
print "</h2>"
print "</br>"
print '''
<div id="navcontainer">
<ul id="navlist">
'''
for statictuner in mbelist:
hdhr_url = None
if statictuner[1].find("notfound") > -1 :
print "Couldn't open tuner map"
print "</br>"
else:
ceton_url = None
hdhr_url = None
if statictuner[0] == "hdhr":
hdhr_url = statictuner[1].split("-")[-1]
elif statictuner[0] == "infinitv":
ceton_port = statictuner[3].strip()
#Services/1/Status.html
#print statictuner
ceton_tuner=statictuner[2].strip()[-1]
ceton_tuner = int(ceton_tuner) + 1
ceton_url = "http://%s:%s/Services/%s/Status.html" %(hostname,
ceton_port,
ceton_tuner)
#print "<li> %s  %s" %(statictuner[1] ,statictuner[0])
print "<li> %s  " %(statictuner[1])
print "</br>"
print " static device node: %s" %statictuner[2]
if hdhr_url:
print "</br>"
print ' device webpage: <a href="http://%s">http://%s</a> ' %(hdhr_url.strip(),hdhr_url.strip())
if ceton_url:
print "</br>"
print ' device webpage: <a href="%s">%s</a> ' %(ceton_url.strip(),ceton_url.strip())
print "</br>"
print "</br>"
print '''</ul> </div>'''
#---------Slave tuners
for i in slave_hosts:
print "<h2>"
print "__________ %s __________" %(i)
print "</h2>"
print "</br>"
print '''
<div id="navcontainer">
<ul id="navlist" '''
#remote_tuners(i)
try:
remote_tuners(i)
pass
except:
print "</br>"
print "<li> Problem reading list from %s" %i
pass
print ''' </ul> </div>'''
|