summaryrefslogtreecommitdiffstats
path: root/abs/core/supplemental-web/contents/list_cardmap.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2013-01-05 02:40:34 (GMT)
committerJames Meyer <james.meyer@operamail.com>2013-01-05 02:40:34 (GMT)
commit8535c8a04075454c676a548dbec40673b0ad62e0 (patch)
treeae7a7d6294cc96e1fd9e45556a51fec5a0fa14a3 /abs/core/supplemental-web/contents/list_cardmap.py
parent6623efa259ecac69b28c204f6100700a774adb2d (diff)
downloadlinhes_pkgbuild-8535c8a04075454c676a548dbec40673b0ad62e0.zip
linhes_pkgbuild-8535c8a04075454c676a548dbec40673b0ad62e0.tar.gz
linhes_pkgbuild-8535c8a04075454c676a548dbec40673b0ad62e0.tar.bz2
supplemental-web: Two major additions here.
1) introduce the static dev node mapping as produced by autocard. Currently located under system->List static dev nodes for tuners. This link will pull in mappings from the MBE and all SLAVE boxes. The query will pull the data from the host each time it's requested, so the slave machines must be on to see the mapping. The data is pulled over http from the slave box by calling cardlist.cgi, which will read in /etc/udev/mv-persisten-video.description. 2) Add the ability to upload and download system backup files from the MBE. Also reworked the css to make it a tad prettier. refs #893 refs #892
Diffstat (limited to 'abs/core/supplemental-web/contents/list_cardmap.py')
-rwxr-xr-xabs/core/supplemental-web/contents/list_cardmap.py132
1 files changed, 132 insertions, 0 deletions
diff --git a/abs/core/supplemental-web/contents/list_cardmap.py b/abs/core/supplemental-web/contents/list_cardmap.py
new file mode 100755
index 0000000..0c28e0e
--- /dev/null
+++ b/abs/core/supplemental-web/contents/list_cardmap.py
@@ -0,0 +1,132 @@
+#!/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&nbsp;&nbsp;&nbsp%s" %(statictuner[1] ,statictuner[0])
+ print "</br>"
+ print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static device node: %s" %statictuner[2]
+ print "</br>"
+ print "</br>"
+ else:
+ print "<li> no tuners found &nbsp;&nbsp;&nbsp"
+
+ return
+
+
+
+mbelist = read_local_tuner()
+slave_hosts = find_slave_hosts()
+
+#--------------MBE-------------
+hostname = socket.gethostname()
+print "<h2>"
+print "__________ %s __________" %(hostname)
+print "</h2>"
+print "</br>"
+print '''
+<div id="navcontainer">
+<ul id="navlist">
+'''
+
+for statictuner in mbelist:
+ if statictuner[1].find("notfound") > -1 :
+ print "Couldn't open tuner map"
+ print "</br>"
+ else:
+ print "<li> %s&nbsp;&nbsp;&nbsp%s" %(statictuner[1] ,statictuner[0])
+ print "</br>"
+ print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static device node: %s" %statictuner[2]
+ 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>'''
+
+