#!/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 "" for statictuner in tuner_list: if statictuner[1].find("notfound") > -1 : print "Couldn't open tuner map" print "" else: print "