Beispiel #1
0
def getServices(sRef, showAll=True, showHidden=False):
    services = []

    if sRef == "":
        sRef = '%s FROM BOUQUET "bouquets.tv" ORDER BY bouquet' % (
            service_types_tv)

    servicelist = ServiceList(eServiceReference(sRef))
    slist = servicelist.getServicesAsList()

    for sitem in slist:
        st = int(sitem[0].split(":")[1])
        if not st & 512 or showHidden:
            if showAll or st == 0:
                service = {}
                service['servicereference'] = unicode(sitem[0],
                                                      'utf_8',
                                                      errors='ignore').encode(
                                                          'utf_8', 'ignore')
                service['servicename'] = unicode(sitem[1],
                                                 'utf_8',
                                                 errors='ignore').encode(
                                                     'utf_8', 'ignore')
                services.append(service)

    return {"services": services}
Beispiel #2
0
	def buildList(self, ref, epg):
		self.servicelist = ServiceList(ref, command_func = self.getServiceList, validate_commands=False)
		list = self.servicelist.getServicesAsList()
		E2List = [] 
		for index in range(len(list)): 
			item = list[index]
			servicereference = item[0]
			servicename = item[1]
			eventstart = 0
			eventduration = 0
			eventtitle = ""
			eventid = 0
			eventdescription = ""
			eventdescriptionextended = ""
			if epg:
				epgref = item[0]
				events = self.epgcache.lookupEvent(['IBDTSERNX', (epgref, 0, -1)])
				if events:
					if events[0][0] is not None:
						eventid =  events[0][0]
					if events[0][1] is not None:
						eventstart =  events[0][1]
					if events[0][2] is not None:
						eventduration =  events[0][2]
					if events[0][3] is not None:
						eventtitle = events[0][3]
					if events[0][4] is not None:
						eventdescription= events[0][4]
					if events[0][5] is not None:
						eventdescriptionextended= events[0][5]
				E2List.append(E2EPGListAllData(servicereference = servicereference, servicename = servicename, eventstart = eventstart, eventduration = eventduration, eventtitle = eventtitle, eventid = eventid, eventdescription= eventdescription, eventdescriptionextended = eventdescriptionextended))
			else:
					E2List.append(E2ServiceList(servicereference = item[0], servicename = item[1]))
		return E2List
Beispiel #3
0
    def render(self, req):
        try:
            w1 = req.uri.split("?")[1]
            w2 = w1.split("&")
            parts = {}
            for i in w2:
                w3 = i.split("=")
                parts[w3[0]] = w3[1]
        except:
            req.setResponseCode(200)
            return "no ref given with ref=???"

        if parts.has_key("ref"):
            s = "<br/>"

            ref = parts["ref"].replace("%20", " ").replace("%3A", ":").replace("%22", '"')
            print ref
            fav = eServiceReference(ref)
            services = ServiceList(fav, command_func=None, validate_commands=False)
            sub = services.getServicesAsList()

            if len(sub) > 0:
                for (ref, name) in sub:
                    s = s + "<p>"
                    s = s + '<a href="http://%s:8001/%s" vod>%s</a>' % (req.host.host, ref, name)
                req.setResponseCode(200)
                req.setHeader("Content-type", "text/html")
                return s
        else:
            req.setResponseCode(200)
            return "no ref"
Beispiel #4
0
	def serviceList(self, param):
		print "serviceList: ", param
		sRef = str(param["sRef"])
		bouquet = str(param["bouquet"])
		self.sRefFound = 0

		if bouquet == '':
			returnList = []
			bouquet = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
			ref = eServiceReference(bouquet)
			self.servicelist = ServiceList(ref, command_func=self.getServiceList, validate_commands=False)
			self.servicelist.setRoot(ref)
			for (ref2, name) in self.servicelist.getServicesAsList():
				part = self.serviceListOne(ref2, sRef)
				if part:
					returnList = returnList + [["-- " + name + " --", "<" + name + ">", ""]] + part
			bouquet = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
			ref = eServiceReference(bouquet)
			self.servicelist = ServiceList(ref, command_func=self.getServiceList, validate_commands=False)
			self.servicelist.setRoot(ref)
			for (ref2, name) in self.servicelist.getServicesAsList():
				part = self.serviceListOne(ref2, sRef)
				if part:
					returnList = returnList + [["-- " + name + " --", "<" + name + ">", ""]] + part
		else:
			returnList = self.serviceListOne(bouquet, sRef)

		if self.sRefFound == 0 and sRef != '':
			returnListPart = ["Inserted", sRef, "selected"]
			returnList = [returnListPart] + returnList
		#print returnList
		return returnList
	def render(self, req):
		try:
			w1 = req.uri.split("?")[1]
			w2 = w1.split("&")
			parts = {}
			for i in w2:
					w3 = i.split("=")
					parts[w3[0]] = w3[1]
		except:
			req.setResponseCode(200);
			return "no ref given with ref=???"

		if parts.has_key("ref"):
			s = '<br/>'
			ref = parts['ref'].replace('%20', ' ').replace('%3A', ':').replace('%22', '"')
			print ref
			fav = eServiceReference(ref)
			services = ServiceList(fav, command_func = None, validate_commands = False)
			sub = services.getServicesAsList()
			if len(sub) > 0:
				for (ref, name) in sub:
					s = s + '<p>'
					s = s + '<a href="http://%s:8001/%s" vod>%s</a>'%(req.host.host,ref,name)
				req.setResponseCode(200);
				req.setHeader('Content-type', 'text/html');
				return s;
		else:
			req.setResponseCode(200);
			return "no ref";
Beispiel #6
0
	def serviceList(self, param):
		print "serviceList: ", param
		sRef = str(param["sRef"])
		bouquet = str(param["bouquet"])
		self.sRefFound = 0

		if bouquet == '':
			returnList = []
			bouquet = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
			ref = eServiceReference(bouquet)
			self.servicelist = ServiceList(ref, command_func=self.getServiceList, validate_commands=False)
			self.servicelist.setRoot(ref)
			for (ref2, name) in self.servicelist.getServicesAsList():
				part = self.serviceListOne(ref2, sRef)
				if part:
					returnList = returnList + [["-- " + name + " --", "<" + name + ">", ""]] + part
			bouquet = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
			ref = eServiceReference(bouquet)
			self.servicelist = ServiceList(ref, command_func=self.getServiceList, validate_commands=False)
			self.servicelist.setRoot(ref)
			for (ref2, name) in self.servicelist.getServicesAsList():
				part = self.serviceListOne(ref2, sRef)
				if part:
					returnList = returnList + [["-- " + name + " --", "<" + name + ">", ""]] + part
		else:
			returnList = self.serviceListOne(bouquet, sRef)

		if self.sRefFound == 0 and sRef != '':
			returnListPart = ["Inserted", sRef, "selected"]
			returnList = [returnListPart] + returnList
		#print returnList
		return returnList
def getServices(sRef, showAll=True, showHidden=False, pos=0):
    services = []

    if sRef == "":
        sRef = '%s FROM BOUQUET "bouquets.tv" ORDER BY bouquet' % (
            service_types_tv)

    servicelist = ServiceList(eServiceReference(sRef))
    slist = servicelist.getServicesAsList()

    for sitem in slist:
        st = int(sitem[0].split(":")[1])
        if (sitem[0][:7] == '1:832:D') or (not (st & 512) and not (st & 64)):
            pos = pos + 1
        if not st & 512 or showHidden:
            if showAll or st == 0:
                service = {}
                service['pos'] = 0 if (st & 64) else pos
                service['servicereference'] = unicode(sitem[0],
                                                      'utf_8',
                                                      errors='ignore').encode(
                                                          'utf_8', 'ignore')
                service['program'] = int(
                    service['servicereference'].split(':')[3], 16)
                service['servicename'] = unicode(sitem[1],
                                                 'utf_8',
                                                 errors='ignore').encode(
                                                     'utf_8', 'ignore')
                services.append(service)

    return {"services": services, "pos": pos}
	def getPicons(self):
		from Components.Sources.ServiceList import ServiceList
		from enigma import eServiceReference, eServiceCenter, iServiceInformation
		import shutil

		currentServiceRef = self.session.nav.getCurrentlyPlayingServiceReference()
		servicelist = ServiceList("")
		servicelist.setRoot(currentServiceRef)
		canais = servicelist.getServicesAsList()

		servicehandler = eServiceCenter.getInstance()

		try:
			os.makedirs("/tmp/piconsTmp")
		except OSError as exception:
			pass

		piconsDir=config.plugins.geradorpicon.pasta.value

		for item in canais:
		    canal = eServiceReference(item[0])
		    if canal:
			    nome = servicehandler.info(canal).getName(canal)
			    picon=canal.toString()[:-1].replace(":","_")+".png"
			    try:
			        shutil.copy(piconsDir+"/"+picon,"/tmp/piconsTmp/"+nome+".png")
			    except:
			        pass
Beispiel #9
0
	def getChannelList(self):
		if not self._channelList:
			from Components.Sources.ServiceList import ServiceList
			bouquet = eServiceReference('1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet')
			slist = ServiceList(bouquet, validate_commands=False)
			services = slist.getServicesAsList(format="S")
			self._channelList = services[:]
		return self._channelList
	def escreveRefresh(self):
		from enigma import eServiceReference, eServiceCenter, iServiceInformation
		from Components.Sources.ServiceList import ServiceList
		import re


		currentServiceRef = self.session.nav.getCurrentlyPlayingServiceReference()

		servicelist = ServiceList("")
		servicelist.setRoot(currentServiceRef)

		canais = servicelist.getServicesAsList()

		servicehandler = eServiceCenter.getInstance()
		tmpCanais={}
		for item in canais:
			canal = eServiceReference(item[0])
			if canal:
			    nome = servicehandler.info(canal).getName(canal)
			    tipo=item[0].split(":")[2]
			    if tipo=="2": continue

			    transponder_info = servicehandler.info(canal).getInfoObject(canal, iServiceInformation.sTransponderData)
			    id=str(transponder_info["frequency"])

			    if transponder_info["tuner_type"]!="DVB-C":
				    id=id+str(transponder_info["polarization"])
				    position=transponder_info["orbital_position"]
			    else:
				    position="DVB-C"
				    id=id+str(transponder_info["symbol_rate"])


			    if(position==config.plugins.Easy.pref.value):
				    if not tmpCanais.has_key(id):
						tmpCanais[id]="#SERVICE %s:%s"%(item[0],nome)

		arq_name="%s/bouquets.tv"%(utils.outdir)
		arq = open(arq_name, "r+")
		check=False
		for linha in arq.readlines():
			if "userbouquet.refresh.tv" in linha:
				check=True
		if not check:
			arq.write("#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET \"userbouquet.refresh.tv\" ORDER BY bouquet\n")
		arq.close()

		arq_name="%s/userbouquet.refresh.tv"%(utils.outdir)
		arq = open(arq_name, "w")
		arq.write("#NAME epgrefresh\n")

		for canal in tmpCanais:
			arq.write(tmpCanais[canal]+"\n")

		arq.close()
Beispiel #11
0
	def LSTC(self, args):
		if args:
			payload = "%d parameter not implemented" % (CODE_IMP_PARAM,)
			return self.sendLine(payload)
		from Components.Sources.ServiceList import ServiceList
		bouquet = eServiceReference('1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet')
		slist = ServiceList(bouquet, validate_commands=False)
		services = slist.getServicesAsList(format="SNn")
		if services:
			def getServiceInfoValue(info, sref, what):
				if info is None: return ""
				v = info.getInfo(sref.ref, what)
				if v == -2: return info.getInfoString(sref.ref, what)
				elif v == -1: return "N/A"
				return v
			def sendServiceLine(service, counter, last=False):
				if service[0][:5] == '1:64:':
					# format for markers:  ":Name"
					line = "%d%s:%s" % (CODE_OK, '-' if not last else ' ', service[1])
				else:
					# <id> <full name>,<short name>;<provider>:<freq>:<parameters>:<source>:<srate>:<vpid>:<apid>:<tpid>:<conditional access>:<:sid>:<nid>:<tid>:<:rid>
					# e.g. 5  RTL Television,RTL:12188:h:S19.2E:27500:163:104:105:0:12003:1:1089:0
					sref = ServiceReference(service[0])
					info = sref.info()
					# XXX: how to get this?! o0
					feinfo = None #sref.ref.frontendInfo()
					fedata = feinfo.getAll(True) if feinfo else {}
					prov = getServiceInfoValue(info, sref, iServiceInformation.sProvider)
					frequency = fedata.get("frequency", 0)/1000
					param = -1
					source = '-1'
					srate = -1
					vpid = '-1'
					apid = '-1'
					tpid = -1
					ca = '-1'
					sid = -1
					nid = -1
					tid = -1
					rid = -1
					# TODO: support full format, these are only the important fields ;)
					line = "%d%s%d %s,%s;%s:%d:%s:%s:%d:%s:%s:%d:%s:%d:%d:%d:%d" % (CODE_OK, '-' if not last else ' ', counter, service[1], service[2], prov, frequency, param, source, srate, vpid, apid, tpid, ca, sid, nid, tid, rid)
				self.sendLine(line)

			self.channelList = [x[0] for x in services] # always refresh cache b/c this is what the user works with from now on
			lastItem = services.pop()
			idx = 1
			for service in services:
				sendServiceLine(service, idx)
				idx += 1
			sendServiceLine(lastItem, idx, last=True)
		else:
			payload = "%d no services found" % (CODE_ERR_LOCAL,)
			self.sendLine(payload)
def getServices(sRef):
    services = []

    if sRef == "":
        sRef = '%s FROM BOUQUET "bouquets.tv" ORDER BY bouquet' % (service_types_tv)

    servicelist = ServiceList(eServiceReference(sRef))
    slist = servicelist.getServicesAsList()
    for sitem in slist:
        service = {}
        service["servicereference"] = sitem[0]
        service["servicename"] = sitem[1]
        services.append(service)

    return {"services": services}
Beispiel #13
0
    def updateEventCache(self):
        try:
            from Screens.ChannelSelection import service_types_tv
            from Components.Sources.ServiceList import ServiceList
            bouquetlist = ServiceList(
                eServiceReference(
                    service_types_tv +
                    ' FROM BOUQUET "bouquets.tv" ORDER BY bouquet'),
                validate_commands=False).getServicesAsList()
            for bouquetitem in bouquetlist:
                serviceHandler = eServiceCenter.getInstance()
                list = serviceHandler.list(
                    eServiceReference(str(bouquetitem[0])))
                services = list and list.getContent('S')
                search = ['IBDCTSERNX']

                if services:  # It's a Bouquet
                    search.extend([(service, 0, -1) for service in services])

                events = self.epgcache.lookupEvent(search)

                for eventinfo in events:
                    #0 eventID | 4 eventname | 5 short descr | 6 long descr | 7 serviceref | 8 channelname
                    self.eventcache.append((eventinfo[0], eventinfo[7],
                                            eventinfo[8], eventinfo[4]))

        except Exception:
            print "[TVCharts Plugin] Error creating eventcache!"
Beispiel #14
0
def getServices(sRef):
    services = []

    if sRef == "":
        sRef = '%s FROM BOUQUET "bouquets.tv" ORDER BY bouquet' % (
            service_types_tv)

    servicelist = ServiceList(eServiceReference(sRef))
    slist = servicelist.getServicesAsList()
    for sitem in slist:
        service = {}
        service['servicereference'] = sitem[0]
        service['servicename'] = sitem[1]
        services.append(service)

    return {"services": services}
Beispiel #15
0
	def buildList(self, ref):
		self.servicelist = ServiceList(ref, command_func=self.getServiceList, validate_commands=False)
		list = self.servicelist.getServicesAsList()
		for item in list:
			self.servicelist.setRoot(eServiceReference(item[0]))
			sub = self.servicelist.getServicesAsList()

			if sub:
				self.xml += "\t<e2bouquet>\n"
				bouquet = True

				subxml = ""
				for (ref, name) in sub:
					subxml += "\t\t\t<e2service>\n"
					subxml += "\t\t\t\t<e2servicereference>%s</e2servicereference>\n\t\t\t\t<e2servicename>%s</e2servicename>\n" % (self.filterXML(ref), self.filterXML(name))
					subxml += "\t\t\t</e2service>\n"

			else:
				self.xml += "\t\t<e2service>\n"
				bouquet = False

			self.xml += "\t\t<e2servicereference>%s</e2servicereference>\n\t\t<e2servicename>%s</e2servicename>\n" % (self.filterXML(item[0]), self.filterXML(item[1]))

			if bouquet:
				self.xml += "\t\t<e2servicelist>\n"
				self.xml += subxml
				self.xml += "\t\t</e2servicelist>\n"
				self.xml += "\t</e2bouquet>\n"
			else:
				self.xml += "\t</e2service>\n"

		return self.xml
def getServices(sRef, showAll=True, showHidden=False, pos=0, provider=False, picon=False):
	services = []
	allproviders = {}

	if sRef == "":
		sRef = '%s FROM BOUQUET "bouquets.tv" ORDER BY bouquet' % (service_types_tv)

	if provider:
		s_type = service_types_tv
		if "radio" in sRef:
			s_type = service_types_radio
		pserviceHandler = eServiceCenter.getInstance()
		pservices = pserviceHandler.list(eServiceReference('%s FROM PROVIDERS ORDER BY name' % (s_type)))
		providers = pservices and pservices.getContent("SN", True)

		if provider:
			for provider in providers:
				servicelist = ServiceList(eServiceReference(provider[0]))
				slist = servicelist.getServicesAsList()
				for sitem in slist:
					allproviders[sitem[0]] = provider[1]

	servicelist = ServiceList(eServiceReference(sRef))
	slist = servicelist.getServicesAsList()

	for sitem in slist:
		st = int(sitem[0].split(":")[1])
		if (sitem[0][:7] == '1:832:D') or (not (st & 512) and not (st & 64)):
			pos = pos + 1
		if not st & 512 or showHidden:
			if showAll or st == 0:
				service = {}
				service['pos'] = 0 if (st & 64) else pos
				sr = unicode(sitem[0], 'utf_8', errors='ignore').encode('utf_8', 'ignore')
				if picon:
					service['picon'] = getPicon(sr)
				service['servicereference'] = sr
				service['program'] = int(service['servicereference'].split(':')[3], 16)
				service['servicename'] = unicode(sitem[1], 'utf_8', errors='ignore').encode('utf_8', 'ignore')
				if provider:
					if sitem[0] in allproviders:
						service['provider'] = allproviders[sitem[0]]
					else:
						service['provider'] = ""
				services.append(service)

	return {"services": services, "pos": pos}
Beispiel #17
0
    def __init__(self, session, request):
        WebScreen.__init__(self, session, request)
        from WebComponents.Sources.ServiceListRecursive import ServiceListRecursive
        from Components.Sources.ServiceList import ServiceList
        from Screens.ChannelSelection import service_types_tv

        fav = eServiceReference(service_types_tv +
                                ' FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
        self["SwitchService"] = ServiceList(fav,
                                            command_func=self.zapTo,
                                            validate_commands=False)
        self["ServiceList"] = ServiceList(fav,
                                          command_func=self.getServiceList,
                                          validate_commands=False)
        self["ServiceListRecursive"] = ServiceListRecursive(
            session, func=ServiceListRecursive.FETCH)
        self["localip"] = RequestData(request, what=RequestData.HOST)
Beispiel #18
0
 def serviceListOne(self, bouquet, selref):
     ref = eServiceReference(bouquet)
     self.servicelist = ServiceList(ref,
                                    command_func=self.getServiceList,
                                    validate_commands=False)
     self.servicelist.setRoot(ref)
     returnList = []
     for (ref2, name) in self.servicelist.getServicesAsList():
         print "ref2: (", ref2, ") name: (", name, ")"
         returnListPart = [name, ref2]
         if ref2 == str(selref):
             returnListPart.append("selected")
             self.sRefFound = 1
         else:
             returnListPart.append("")
         returnList.append(returnListPart)
     return returnList
Beispiel #19
0
	def __init__(self, session, request):
		WebScreen.__init__(self, session, request)

		from Components.Sources.ServiceList import ServiceList
		from Screens.ChannelSelection import service_types_tv

		fav = eServiceReference(service_types_tv + ' FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
		self["ServiceList"] = ServiceList(fav, command_func=self.getServiceList, validate_commands=False)
Beispiel #20
0
def getServices(sRef):
	services = []

	if sRef == "":
		sRef = '%s FROM BOUQUET "bouquets.tv" ORDER BY bouquet' % (service_types_tv)

	servicelist = ServiceList(eServiceReference(sRef))
	slist = servicelist.getServicesAsList()

	for sitem in slist:
		if not int(sitem[0].split(":")[1]) & 512:	# 512 is hidden service on sifteam image. Doesn't affect other images
			service = {}
			service['servicereference'] = sitem[0]
			service['servicename'] = sitem[1]
			services.append(service)

	return { "services": services }
def getServices(sRef, showAll = True, showHidden = False):
	services = []

	if sRef == "":
		sRef = '%s FROM BOUQUET "bouquets.tv" ORDER BY bouquet' % (service_types_tv)

	servicelist = ServiceList(eServiceReference(sRef))
	slist = servicelist.getServicesAsList()

	for sitem in slist:
		st = int(sitem[0].split(":")[1])
		if not st & 512 or showHidden:
			if showAll or st == 0: 
				service = {}
				service['servicereference'] = sitem[0].encode("utf8")
				service['servicename'] = sitem[1].encode("utf8")
				services.append(service)

	return { "services": services }
	def render(self, req):
		s = '<br/>'
		if config.usage.multibouquet.value:
			bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
		else:
			from Screens.ChannelSelection import service_types_tv
			bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'%(service_types_tv)
		fav = eServiceReference(bouquet_rootstr)
		services = ServiceList(fav, command_func = None, validate_commands = False)
		sub = services.getServicesAsList()
		if len(sub) > 0:
			self.putChild('channel', ChannelList())
			for (ref, name) in sub:
				s = s + '<p>'
				ref = ref.replace(' ', '%20').replace(':', '%3A').replace('"', '%22')
				s = s + '<a href="/channel?ref=' + ref + '">' + name + '</a>'
			req.setResponseCode(200)
			req.setHeader('Content-type', 'text/html');
			return s;
Beispiel #23
0
	def _init_services(self, ref):
		self.info(ref)
		servicelist = None
		def get_servicelist(ref):
			servicelist.root = ref
		if ref:
			ref = eServiceReference(ref)
			if not ref.valid():
				self.warning("Invalid ref %s" % ref)
				return []
		else:
			self.warning("Missing ref!")

		servicelist = ServiceList(ref, command_func=get_servicelist, validate_commands=False)
		services = servicelist.getServicesAsList()
		for ref, name in services:
			if ref.startswith("1:64"): #skip markers
				continue
			child = self._gen_child(ref, name)
			self.add_child(child)
def getServices(sRef, showAll = True, showHidden = False):
	services = []

	if sRef == "":
		sRef = '%s FROM BOUQUET "bouquets.tv" ORDER BY bouquet' % (service_types_tv)

	servicelist = ServiceList(eServiceReference(sRef))
	slist = servicelist.getServicesAsList()

	for sitem in slist:
		st = int(sitem[0].split(":")[1])
		if not st & 512 or showHidden:
			if showAll or st == 0:
				service = {}
				service['servicereference'] = unicode(sitem[0], 'utf_8', errors='ignore').encode('utf_8', 'ignore')
				service['program'] = int(service['servicereference'].split(':')[3], 16)
				service['servicename'] = unicode(sitem[1], 'utf_8', errors='ignore').encode('utf_8', 'ignore')
				services.append(service)

	return { "services": services }
Beispiel #25
0
    def render(self, req):
        s = "<br/>"

        if config.usage.multibouquet.value:
            bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
        else:
            bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet' % (self.service_types)

        fav = eServiceReference(bouquet_rootstr)
        services = ServiceList(fav, command_func=None, validate_commands=False)
        sub = services.getServicesAsList()

        if len(sub) > 0:
            self.putChild("channel", ChannelList())
            for (ref, name) in sub:
                s = s + "<p>"
                ref = ref.replace(" ", "%20").replace(":", "%3A").replace('"', "%22")
                s = s + '<a href="/channel?ref=' + ref + '">' + name + "</a>"
            req.setResponseCode(200)
            req.setHeader("Content-type", "text/html")
            return s
Beispiel #26
0
	def __init__(self, session, request):
		ServiceListWebScreen.__init__(self, session, request)
		LocationsAndTagsWebScreen.__init__(self, session, request)

		from Components.Sources.ServiceList import ServiceList
		from Screens.ChannelSelection import service_types_tv
		fav = eServiceReference(service_types_tv + ' FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
		self["BouquetList"] = ServiceList(fav, command_func=self.getBouquetList, validate_commands=False)
		#get the first bouquet and set it
		favlist = self["BouquetList"].getServicesAsList(format = "S")
		if len(favlist) > 0:
			self["ServiceList"].root = eServiceReference(favlist[0])
	def escreveCanais(self):
		from enigma import eServiceReference, eServiceCenter, iServiceInformation
		from Components.Sources.ServiceList import ServiceList
		import re


		t=open("/tmp/canais.csv","w")

		currentServiceRef = self.session.nav.getCurrentlyPlayingServiceReference()

		servicelist = ServiceList("")
		servicelist.setRoot(currentServiceRef)

		canais = servicelist.getServicesAsList()

		servicehandler = eServiceCenter.getInstance()
		from sets import Set
		ctmp=Set()
		for item in canais:
		    canal = eServiceReference(item[0])
		    if canal:
			    nome = servicehandler.info(canal).getName(canal)

			    if nome=="(...)" or re.match("\d+",nome): continue
			    tipo=item[0].split(":")[2]
			    if tipo=="2": continue

			    transponder_info = servicehandler.info(canal).getInfoObject(canal, iServiceInformation.sTransponderData)

			    if transponder_info["tuner_type"]=="DVB-C":
				    continue

			    position = int(transponder_info["orbital_position"])

			    if(position==config.plugins.Easy.pref.value):
				    ctmp.add("%s,%s\n"%(nome.strip(),"True" if tipo in ["19","25"] else "False"))


		for c in ctmp:
			t.write(c)
def getServices(sRef,
                showAll=True,
                showHidden=False,
                pos=0,
                provider=False,
                picon=False):
    services = []
    allproviders = {}

    if sRef == "":
        sRef = '%s FROM BOUQUET "bouquets.tv" ORDER BY bouquet' % (
            service_types_tv)

    if provider:
        s_type = service_types_tv
        if "radio" in sRef:
            s_type = service_types_radio
        pserviceHandler = eServiceCenter.getInstance()
        pservices = pserviceHandler.list(
            eServiceReference('%s FROM PROVIDERS ORDER BY name' % (s_type)))
        providers = pservices and pservices.getContent("SN", True)

        if provider:
            for provider in providers:
                servicelist = ServiceList(eServiceReference(provider[0]))
                slist = servicelist.getServicesAsList()
                for sitem in slist:
                    allproviders[sitem[0]] = provider[1]

    servicelist = ServiceList(eServiceReference(sRef))
    slist = servicelist.getServicesAsList()

    for sitem in slist:
        st = int(sitem[0].split(":")[1])
        if (sitem[0][:7] == '1:832:D') or (not (st & 512) and not (st & 64)):
            pos = pos + 1
        if not st & 512 or showHidden:
            if showAll or st == 0:
                service = {}
                service['pos'] = 0 if (st & 64) else pos
                sr = unicode(sitem[0], 'utf_8',
                             errors='ignore').encode('utf_8', 'ignore')
                if picon:
                    service['picon'] = getPicon(sr)
                service['servicereference'] = sr
                service['program'] = int(
                    service['servicereference'].split(':')[3], 16)
                service['servicename'] = unicode(sitem[1],
                                                 'utf_8',
                                                 errors='ignore').encode(
                                                     'utf_8', 'ignore')
                if provider:
                    if sitem[0] in allproviders:
                        service['provider'] = allproviders[sitem[0]]
                    else:
                        service['provider'] = ""
                services.append(service)

    return {"services": services, "pos": pos}
Beispiel #29
0
    def buildList(self, ref):
        self.servicelist = ServiceList(ref,
                                       command_func=self.getServiceList,
                                       validate_commands=False)
        list = self.servicelist.getServicesAsList()
        for item in list:
            self.servicelist.setRoot(eServiceReference(item[0]))
            sub = self.servicelist.getServicesAsList()

            if sub:
                self.xml += "\t<e2bouquet>\n"
                bouquet = True

                subxml = ""
                for (ref, name) in sub:
                    name = name.replace('\xc2\x86', '').replace('\xc2\x87', '')
                    subxml += "\t\t\t<e2service>\n"
                    subxml += "\t\t\t\t<e2servicereference>%s</e2servicereference>\n\t\t\t\t<e2servicename>%s</e2servicename>\n" % (
                        self.filterXML(ref), self.filterXML(name))
                    subxml += "\t\t\t</e2service>\n"

            else:
                self.xml += "\t\t<e2service>\n"
                bouquet = False

            self.xml += "\t\t<e2servicereference>%s</e2servicereference>\n\t\t<e2servicename>%s</e2servicename>\n" % (
                self.filterXML(item[0]), self.filterXML(item[1]))

            if bouquet:
                self.xml += "\t\t<e2servicelist>\n"
                self.xml += subxml
                self.xml += "\t\t</e2servicelist>\n"
                self.xml += "\t</e2bouquet>\n"
            else:
                self.xml += "\t</e2service>\n"

        return self.xml
		def do_populate(parent=None):
			if parent.external_id == None:
				self.warning("Invalid ref %s" %parent.external_id)
				return

			servicelist = None
			def get_servicelist(ref):
				servicelist.root = ref
			ref = eServiceReference(parent.external_id)
			if not ref.valid():
				self.warning("Invalid ref %s" %parent.external_id)
				return

			servicelist = ServiceList(ref, command_func=get_servicelist, validate_commands=False)
			services = servicelist.getServicesAsList()

			snum = 1
			isChannelList = False
			for sref, name in services:
				name = unicode(name.replace('\xc2\x86', '').replace('\xc2\x87', ''), errors='ignore')
				item = None
				if sref.startswith("1:7:"): #Bouquet
					item = LazyContainer(parent, name, childrenRetriever=retriever)
				else:
					isChannelList = True
					if not sref.startswith("1:64:"): # skip markers
						url = 'http://' + self.streaminghost + ':8001/' + sref
						item = DreamboxService(name, url, snum, parent)
						snum += 1

				if item is not None:
					parent.add_child(item, external_id=sref)

			if isChannelList:
				def sort(x, y):
					return cmp(x.get_service_number(), y.get_service_number())
				parent.sorting_method = sort
Beispiel #31
0
    def _init_services(self, ref):
        self.info(ref)
        servicelist = None

        def get_servicelist(ref):
            servicelist.root = ref

        if ref:
            ref = eServiceReference(ref)
            if not ref.valid():
                self.warning("Invalid ref %s" % ref)
                return []
        else:
            self.warning("Missing ref!")

        servicelist = ServiceList(ref,
                                  command_func=get_servicelist,
                                  validate_commands=False)
        services = servicelist.getServicesAsList()
        for ref, name in services:
            if ref.startswith("1:64"):  #skip markers
                continue
            child = self._gen_child(ref, name)
            self.add_child(child)
Beispiel #32
0
	def serviceListOne(self, bouquet, selref):
		ref = eServiceReference(bouquet)
		self.servicelist = ServiceList(ref, command_func=self.getServiceList, validate_commands=False)
		self.servicelist.setRoot(ref)
		returnList = []
		for (ref2, name) in self.servicelist.getServicesAsList():
			print "ref2: (", ref2, ") name: (", name, ")"
			returnListPart = [
				name,
				ref2
			]
			if ref2 == str(selref):
				returnListPart.append("selected")
				self.sRefFound = 1
			else:
				returnListPart.append("")
			returnList.append(returnListPart)
		return returnList
	def setValue(self, oid, value):
		#the first time we are called, we have to fill the bisect oid store, values are just values, no objects (we cannot call value.get)
		try:
			value.get()
		except:
			return bisectoidstore.BisectOIDStore.setValue(self, oid, value)

		oidstring = bisectoidstore.sortableToOID(oid)
		if oidstring == self.MANAGERIP_OID:
			if config.plugins.SnmpAgent.managerip.value <> value.get():
				config.plugins.SnmpAgent.managerip.value = value.get()
				config.plugins.SnmpAgent.managerip.save()
		elif oidstring == self.ENABLE_BITRATE_OID:
			if config.plugins.SnmpAgent.measurebitrate.value and not value.get():
				config.plugins.SnmpAgent.measurebitrate.value = False
				config.plugins.SnmpAgent.measurebitrate.save()
				if self.bitrate:
					self.bitrate.stop()
					self.bitrate = None
			elif not config.plugins.SnmpAgent.measurebitrate.value and value.get():
				config.plugins.SnmpAgent.measurebitrate.value = True
				config.plugins.SnmpAgent.measurebitrate.save()
				self.bitrate = Bitrate(self.session)
				self.bitrate.start()
		elif oidstring == self.SYSTEMNAME_OID:
			if config.plugins.SnmpAgent.systemname.value <> value.get():
				config.plugins.SnmpAgent.systemname.value = value.get()
				config.plugins.SnmpAgent.systemname.save()
		elif oidstring == self.SUPPORTADDRESS_OID:
			if config.plugins.SnmpAgent.supportaddress.value <> value.get():
				config.plugins.SnmpAgent.supportaddress.value = value.get()
				config.plugins.SnmpAgent.supportaddress.save()
		elif oidstring == self.SYSTEMDESCRIPTION_OID:
			if config.plugins.SnmpAgent.systemdescription.value <> value.get():
				config.plugins.SnmpAgent.systemdescription.value = value.get()
				config.plugins.SnmpAgent.systemdescription.save()
		elif oidstring == self.LOCATION_OID:
			if config.plugins.SnmpAgent.location.value <> value.get():
				config.plugins.SnmpAgent.location.value = value.get()
				config.plugins.SnmpAgent.location.save()
		elif oidstring == self.CHANNELNAME_OID:
			if self.getChannelName() <> value.get():
				root = config.tv.lastroot.value.split(';')
				fav = eServiceReference(root[-2])
				services = ServiceList(fav, command_func=self.zapTo, validate_commands=False)
				sub = services.getServicesAsList()

				if len(sub) > 0:
					for (ref, name) in sub:
						if name == value.get():
							self.zapTo(eServiceReference(ref))
							break
		elif oidstring == self.SERVICESTRING_OID:
			if self.getServiceString() <> value.get():
				self.zapTo(eServiceReference(value.get()))
		elif oidstring == self.FASTSCANSTRING_OID:
			refstring = ''
			fields = value.get().split(',')
			if len(fields) >= 15:
				onid, tsid, freq, id1, id2, sid, orbital_pos, f1, f2, f3, symbolrate, f4, name, provider, servicetype = fields[0:15]
				refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % (1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0)
			if refstring is not '':
				self.zapTo(eServiceReference(refstring))
		elif oidstring == self.SERVICEPARAMS_OID:
			refstring = ''
			fields = value.get().split(',')
			if len(fields) >= 5:
				orbital_pos, tsid, onid, sid, servicetype = fields[0:5]
				refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % (1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0)
			if refstring is not '':
				self.zapTo(eServiceReference(refstring))
		elif oidstring == self.IP_OID:
			ipstring = value.get().split('.')
			ipval = []
			for x in ipstring:
				ipval.append(int(x))
			if iNetwork.getAdapterAttribute(self.iface, "ip") <> ipval:
				iNetwork.setAdapterAttribute(self.iface, "dhcp", 0)
				iNetwork.setAdapterAttribute(self.iface, "ip", ipval)
				iNetwork.deactivateNetworkConfig()
				iNetwork.writeNetworkConfig()
				iNetwork.activateNetworkConfig()
		elif oidstring == self.IP_OID:
			ipstring = value.get().split('.')
			ipval = []
			for x in ipstring:
				ipval.append(int(x))
			if iNetwork.getAdapterAttribute(self.iface, "netmask") <> ipval:
				iNetwork.setAdapterAttribute(self.iface, "dhcp", 0)
				iNetwork.setAdapterAttribute(self.iface, "netmask", ipval)
				iNetwork.deactivateNetworkConfig()
				iNetwork.writeNetworkConfig()
				iNetwork.activateNetworkConfig()
		elif oidstring == self.GATEWAY_OID:
			ipstring = value.get().split('.')
			ipval = []
			for x in ipstring:
				ipval.append(int(x))
			if iNetwork.getAdapterAttribute(self.iface, "gateway") <> ipval:
				iNetwork.setAdapterAttribute(self.iface, "dhcp", 0)
				iNetwork.setAdapterAttribute(self.iface, "gateway", ipval)
				iNetwork.deactivateNetworkConfig()
				iNetwork.writeNetworkConfig()
				iNetwork.activateNetworkConfig()
		elif oidstring == self.ENABLE_EMM_OID:
			if config.plugins.SnmpAgent.checkemm.value and not value.get():
				config.plugins.SnmpAgent.checkemm.value = False
				config.plugins.SnmpAgent.checkemm.save()
				if self.emm:
					self.emm.stop()
					self.emm = None
			elif not config.plugins.SnmpAgent.checkemm.value and value.get():
				config.plugins.SnmpAgent.checkemm.value = True
				config.plugins.SnmpAgent.checkemm.save()
				self.emm = Emm(self.session)
				self.emm.start()
		else:
			print "oid not found!?"

		return None
Beispiel #34
0
class WAPfunctions(Source):
	LISTTIME = 0
	REPEATED = 1
	SERVICELIST = 2
	OPTIONLIST = 3
	FILLVALUE = 4
	LOCATIONLIST = 5
	TAGLIST = 6
	DELETEOLD = 7

	lut = {	"Name":0,
			"Value":1,
			"Selected":2
	}

	def __init__(self, session, func=LISTTIME):
		self.func = func
		Source.__init__(self)
		self.session = session
		self.result = ( "unknown command (%s)" % (self.func), )

	def handleCommand(self, cmd):
		print "WAPfunctions: handleCommand", cmd
		if self.func is self.LISTTIME:
			self.result = self.fillListTime(cmd)
		elif self.func is self.REPEATED:
			self.result = self.fillRepeated(cmd)
		elif self.func is self.SERVICELIST:
			self.result = self.serviceList(cmd)
		elif self.func is self.OPTIONLIST:
			self.result = self.fillOptionList(cmd)
		elif self.func is self.FILLVALUE:
			self.result = self.fillValue(cmd)
		elif self.func is self.LOCATIONLIST:
			self.result = self.locationList(cmd)
		elif self.func is self.TAGLIST:
			self.result = self.tagList(cmd)
		elif self.func is self.DELETEOLD:
			self.result = self.deleteOldSaved(cmd)
		else:
			self.result = ( "unknown command cmd(%s) self.func(%s)" % (cmd, self.func), )

	def fillListTime(self, param):
		print "fillListTime", param

		input = 0
		start = 1
		end = 1

		timeNow = time()
		timePlusTwo = timeNow + 7200

		if 'begin' in param:
			begin = param['begin'] or 0
			begin = int(begin)
			del param['begin']
			if begin > 0:
				timeNow = begin
		if 'end' in param:
			end = param['end'] or 0
			end = int(end)
			del param['end']
			if end > 0:
				timePlusTwo = end

		t = {}
		t["sday"] = t["day"] = strftime("%d", localtime(timeNow))
		t["smonth"] = t["month"] = strftime("%m", localtime(timeNow))
		t["syear"] = t["year"] = strftime("%Y", localtime(timeNow))
		t["smin"] = strftime("%M", localtime(timeNow))
		t["shour"] = strftime("%H", localtime(timeNow))
		t["emin"] = strftime("%M", localtime(timePlusTwo))
		t["ehour"] = strftime("%H", localtime(timePlusTwo))

		key = ""
		for i in param:
			p = str(i)
			if p != "sRef" and param[p] != None:
				key = p

		if key == "smin" or key == "emin" :
			start = 0
			end = 59
		elif key == "shour" or key == "ehour":
			start = 0
			end = 23
		elif key == "day" or key == "sday":
			start = 1
			end = 31
		elif key == "month" or key == "smonth":
			start = 1
			end = 12
		else:
			start = int(t[key])
			end = int(t[key]) + 2

		if param[key] == "now" or param[key] == "end" or param[key] == "begin":
			input = int(t[key])
		else:
			input = param[key] or 0
			input = int(input)

		self.result = self.fillOptionListAny(input, start, end)
		return self.result

	def fillOptionListAny(self, input, start, end):
		returnList = []
		for i in range(start, end + 1, 1):
			returnList1 = []
			j = str(i)
			if len(j) == 1:
				j = "0%s" % j
			returnList1.extend((j, i))
			if i == input:
				returnList1.append("selected")
			else:
				returnList1.append("")
			returnList.append(returnList1)
		return returnList

	def fillRepeated(self, param):
		print "fillRepeated", param
		repeated = param or 0
		repeated = int(repeated)

		self.lut = {"Name":0
			, "Value":1
			, "Description":2
			, "Selected":3
		}

		mo = ["mo", 	1, "Mo "]#"Monday"]
		tu = ["tu", 	2, "Tu "]#"Tuesday"]
		we = ["we", 	4, "We "]#"Wednesday"]
		th = ["th", 	8, "Th "]#"Thursday"]
		fr = ["fr", 16, "Fr "]#"Friday"]
		sa = ["sa", 32, "Sa "]#"Saturday"]
		su = ["su", 64, "Su "]#"Sunday"]
		mf = ["mf", 31, "Mo-Fr"]
		ms = ["ms", 127, "Mo-Su"]

		if repeated == 127:
			repeated = repeated - 127
			ms.append("checked")
		else:
			ms.append("")

		if repeated >= 64:
			repeated = repeated - 64
			su.append("checked")
		else:
			su.append("")

		if repeated >= 32:
			repeated = repeated - 32
			sa.append("checked")
		else:
			sa.append("")

		if repeated == 31:
			repeated = repeated - 31
			mf.append("checked")
		else:
			mf.append("")

		if repeated >= 16:
			repeated = repeated - 16
			fr.append("checked")
		else:
			fr.append("")

		if repeated >= 8:
			repeated = repeated - 8
			th.append("checked")
		else:
			th.append("")

		if repeated >= 4:
			repeated = repeated - 4
			we.append("checked")
		else:
			we.append("")

		if repeated >= 2:
			repeated = repeated - 2
			tu.append("checked")
		else:
			tu.append("")

		if repeated == 1:
			repeated = repeated - 1
			mo.append("checked")
		else:
			mo.append("")

		return [
			mo,
			tu,
			we,
			th,
			fr,
			sa,
			su,
			mf,
			ms,
		]

	def serviceListOne(self, bouquet, selref):
		ref = eServiceReference(bouquet)
		self.servicelist = ServiceList(ref, command_func=self.getServiceList, validate_commands=False)
		self.servicelist.setRoot(ref)
		returnList = []
		for (ref2, name) in self.servicelist.getServicesAsList():
			print "ref2: (", ref2, ") name: (", name, ")"
			returnListPart = [
				name,
				ref2
			]
			if ref2 == str(selref):
				returnListPart.append("selected")
				self.sRefFound = 1
			else:
				returnListPart.append("")
			returnList.append(returnListPart)
		return returnList

	def serviceList(self, param):
		print "serviceList: ", param
		sRef = str(param["sRef"])
		bouquet = str(param["bouquet"])
		self.sRefFound = 0

		if bouquet == '':
			returnList = []
			bouquet = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
			ref = eServiceReference(bouquet)
			self.servicelist = ServiceList(ref, command_func=self.getServiceList, validate_commands=False)
			self.servicelist.setRoot(ref)
			for (ref2, name) in self.servicelist.getServicesAsList():
				part = self.serviceListOne(ref2, sRef)
				if part:
					returnList = returnList + [["-- " + name + " --", "<" + name + ">", ""]] + part
			bouquet = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
			ref = eServiceReference(bouquet)
			self.servicelist = ServiceList(ref, command_func=self.getServiceList, validate_commands=False)
			self.servicelist.setRoot(ref)
			for (ref2, name) in self.servicelist.getServicesAsList():
				part = self.serviceListOne(ref2, sRef)
				if part:
					returnList = returnList + [["-- " + name + " --", "<" + name + ">", ""]] + part
		else:
			returnList = self.serviceListOne(bouquet, sRef)

		if self.sRefFound == 0 and sRef != '':
			returnListPart = ["Inserted", sRef, "selected"]
			returnList = [returnListPart] + returnList
		#print returnList
		return returnList

	def getServiceList(self, ref):
		self.servicelist.root = ref

	def locationList(self, param):
		print "locationList", param
		dirname = param
		lst = config.movielist.videodirs.value
		if not dirname:
			dirname = "/hdd/movie/"
		if not dirname in lst:
			lst = [dirname] + lst
		returnList = [[lst[i], i, dirname == lst[i] and "selected" or ""] for i in range(len(lst))]
		return returnList

	def tagList(self, param):
		print "tagList", param
		tag = param
		try:
			file = open("/etc/enigma2/movietags")
			taglist = [x.rstrip() for x in file]
			while "" in taglist:
				taglist.remove("")
			file.close()
		except IOError, ioe:
			taglist = []
		if not tag in taglist:
			taglist = [tag] + taglist
		if not "" in taglist:
			taglist.append("")
		returnList = [[taglist[i], i, tag == taglist[i] and "selected" or ""] for i in range(len(taglist))]
		return returnList
Beispiel #35
0
class WAPfunctions(Source):
	LISTTIME = 0
	REPEATED = 1
	SERVICELIST = 2
	OPTIONLIST = 3
	FILLVALUE = 4
	LOCATIONLIST = 5
	TAGLIST = 6
	DELETEOLD = 7

	lut = {	"Name": 0,
			"Value": 1,
			"Selected": 2
	}

	def __init__(self, session, func=LISTTIME):
		self.func = func
		Source.__init__(self)
		self.session = session
		self.result = ("unknown command (%s)" % (self.func), )

	def handleCommand(self, cmd):
		print "WAPfunctions: handleCommand", cmd
		if self.func is self.LISTTIME:
			self.result = self.fillListTime(cmd)
		elif self.func is self.REPEATED:
			self.result = self.fillRepeated(cmd)
		elif self.func is self.SERVICELIST:
			self.result = self.serviceList(cmd)
		elif self.func is self.OPTIONLIST:
			self.result = self.fillOptionList(cmd)
		elif self.func is self.FILLVALUE:
			self.result = self.fillValue(cmd)
		elif self.func is self.LOCATIONLIST:
			self.result = self.locationList(cmd)
		elif self.func is self.TAGLIST:
			self.result = self.tagList(cmd)
		elif self.func is self.DELETEOLD:
			self.result = self.deleteOldSaved(cmd)
		else:
			self.result = ("unknown command cmd(%s) self.func(%s)" % (cmd, self.func), )

	def fillListTime(self, param):
		print "fillListTime", param

		input = 0
		start = 1
		end = 1

		timeNow = time()
		timePlusTwo = timeNow + 7200

		if 'begin' in param:
			begin = param['begin'] or 0
			begin = int(begin)
			del param['begin']
			if begin > 0:
				timeNow = begin
		if 'end' in param:
			end = param['end'] or 0
			end = int(end)
			del param['end']
			if end > 0:
				timePlusTwo = end

		t = {}
		t["sday"] = t["day"] = strftime("%d", localtime(timeNow))
		t["smonth"] = t["month"] = strftime("%m", localtime(timeNow))
		t["syear"] = t["year"] = strftime("%Y", localtime(timeNow))
		t["smin"] = strftime("%M", localtime(timeNow))
		t["shour"] = strftime("%H", localtime(timeNow))
		t["emin"] = strftime("%M", localtime(timePlusTwo))
		t["ehour"] = strftime("%H", localtime(timePlusTwo))

		key = ""
		for i in param:
			p = str(i)
			if p != "sRef" and param[p] != None:
				key = p

		if key == "smin" or key == "emin":
			start = 0
			end = 59
		elif key == "shour" or key == "ehour":
			start = 0
			end = 23
		elif key == "day" or key == "sday":
			start = 1
			end = 31
		elif key == "month" or key == "smonth":
			start = 1
			end = 12
		else:
			start = int(t[key])
			end = int(t[key]) + 2

		if param[key] == "now" or param[key] == "end" or param[key] == "begin":
			input = int(t[key])
		else:
			input = param[key] or 0
			input = int(input)

		self.result = self.fillOptionListAny(input, start, end)
		return self.result

	def fillOptionListAny(self, input, start, end):
		returnList = []
		for i in range(start, end + 1, 1):
			returnList1 = []
			j = str(i)
			if len(j) == 1:
				j = "0%s" % j
			returnList1.extend((j, i))
			if i == input:
				returnList1.append("selected")
			else:
				returnList1.append("")
			returnList.append(returnList1)
		return returnList

	def fillRepeated(self, param):
		print "fillRepeated", param
		repeated = param or 0
		repeated = int(repeated)

		self.lut = {"Name": 0			, "Value": 1			, "Description": 2			, "Selected": 3
		}

		mo = ["mo", 1, "Mo "]#"Monday"]
		tu = ["tu", 2, "Tu "]#"Tuesday"]
		we = ["we", 4, "We "]#"Wednesday"]
		th = ["th", 8, "Th "]#"Thursday"]
		fr = ["fr", 16, "Fr "]#"Friday"]
		sa = ["sa", 32, "Sa "]#"Saturday"]
		su = ["su", 64, "Su "]#"Sunday"]
		mf = ["mf", 31, "Mo-Fr"]
		ms = ["ms", 127, "Mo-Su"]

		if repeated == 127:
			repeated = repeated - 127
			ms.append("checked")
		else:
			ms.append("")

		if repeated >= 64:
			repeated = repeated - 64
			su.append("checked")
		else:
			su.append("")

		if repeated >= 32:
			repeated = repeated - 32
			sa.append("checked")
		else:
			sa.append("")

		if repeated == 31:
			repeated = repeated - 31
			mf.append("checked")
		else:
			mf.append("")

		if repeated >= 16:
			repeated = repeated - 16
			fr.append("checked")
		else:
			fr.append("")

		if repeated >= 8:
			repeated = repeated - 8
			th.append("checked")
		else:
			th.append("")

		if repeated >= 4:
			repeated = repeated - 4
			we.append("checked")
		else:
			we.append("")

		if repeated >= 2:
			repeated = repeated - 2
			tu.append("checked")
		else:
			tu.append("")

		if repeated == 1:
			repeated = repeated - 1
			mo.append("checked")
		else:
			mo.append("")

		return [
			mo,
			tu,
			we,
			th,
			fr,
			sa,
			su,
			mf,
			ms,
		]

	def serviceListOne(self, bouquet, selref):
		ref = eServiceReference(bouquet)
		self.servicelist = ServiceList(ref, command_func=self.getServiceList, validate_commands=False)
		self.servicelist.setRoot(ref)
		returnList = []
		for (ref2, name) in self.servicelist.getServicesAsList():
			print "ref2: (", ref2, ") name: (", name, ")"
			returnListPart = [
				name,
				ref2
			]
			if ref2 == str(selref):
				returnListPart.append("selected")
				self.sRefFound = 1
			else:
				returnListPart.append("")
			returnList.append(returnListPart)
		return returnList

	def serviceList(self, param):
		print "serviceList: ", param
		sRef = str(param["sRef"])
		bouquet = str(param["bouquet"])
		self.sRefFound = 0

		if bouquet == '':
			returnList = []
			bouquet = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
			ref = eServiceReference(bouquet)
			self.servicelist = ServiceList(ref, command_func=self.getServiceList, validate_commands=False)
			self.servicelist.setRoot(ref)
			for (ref2, name) in self.servicelist.getServicesAsList():
				part = self.serviceListOne(ref2, sRef)
				if part:
					returnList = returnList + [["-- " + name + " --", "<" + name + ">", ""]] + part
			bouquet = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
			ref = eServiceReference(bouquet)
			self.servicelist = ServiceList(ref, command_func=self.getServiceList, validate_commands=False)
			self.servicelist.setRoot(ref)
			for (ref2, name) in self.servicelist.getServicesAsList():
				part = self.serviceListOne(ref2, sRef)
				if part:
					returnList = returnList + [["-- " + name + " --", "<" + name + ">", ""]] + part
		else:
			returnList = self.serviceListOne(bouquet, sRef)

		if self.sRefFound == 0 and sRef != '':
			returnListPart = ["Inserted", sRef, "selected"]
			returnList = [returnListPart] + returnList
		#print returnList
		return returnList

	def getServiceList(self, ref):
		self.servicelist.root = ref

	def locationList(self, param):
		print "locationList", param
		dirname = param
		lst = config.movielist.videodirs.value
		if not dirname:
			dirname = resolveFilename(SCOPE_HDD)
		if not dirname in lst:
			lst = [dirname] + lst
		returnList = [[lst[i], i, dirname == lst[i] and "selected" or ""] for i in range(len(lst))]
		return returnList

	def tagList(self, param):
		print "tagList", param
		tag = param
		try:
			file = open(resolveFilename(SCOPE_CONFIG, "movietags"))
			taglist = [x.rstrip() for x in file]
			while "" in taglist:
				taglist.remove("")
			file.close()
		except IOError, ioe:
			taglist = []
		if not tag in taglist:
			taglist = [tag] + taglist
		if not "" in taglist:
			taglist.append("")
		returnList = [[taglist[i], i, tag == taglist[i] and "selected" or ""] for i in range(len(taglist))]
		return returnList
Beispiel #36
0
    def gerarBouquets(self):
            self.mudaSituacao(1, _("Creating favorites"))

            from enigma import eServiceReference, eServiceCenter, iServiceInformation
            from Components.Sources.ServiceList import ServiceList

            if self.parserules():

                self.satPref=config.plugins.Easy.pref.value if config.plugins.Easy.pref.value=="DVB-C" else utils.positionToSat(config.plugins.Easy.pref.value)

                currentServiceRef = self.session.nav.getCurrentlyPlayingServiceReference()
                servicelist = ServiceList("")
                servicelist.setRoot(currentServiceRef)
                try:
                    canais = servicelist.getServicesAsList()
                except:
	                self.session.open(MessageBox, text = _("Please, put in valid service first."), type = MessageBox.TYPE_WARNING,close_on_any_key=True, timeout=5)
	                return
#                tmp=open("/tmp/teste","w")
                servicehandler = eServiceCenter.getInstance()
                for item in canais:
                    canal = eServiceReference(item[0])
                    if canal:

                        nome = servicehandler.info(canal).getName(canal)

                        if nome=="(...)" or re.match("\d+",nome): continue
                        # tipo=str(canal.type)

                        tipo=item[0].split(":")[2]

                        transponder_info = servicehandler.info(canal).getInfoObject(canal, iServiceInformation.sTransponderData)

                        cabo = True if transponder_info["tuner_type"]=="DVB-C" else False

                        if cabo and nome.strip().lower().endswith("hd"):
                            tipo="25"

                        if str(tipo) in ["1","19","25"]:
                            if transponder_info["tuner_type"]=="DVB-C":
                                satName="DVB-C"
                                sat=satName
                                position=satName
                            else:
                                position = int(transponder_info["orbital_position"])

                                if position>1800:
                                    sat= str(int(((float(position)/10)-360)*10))
                                    satName= "%sW" % str(int(((float(position)/10)-360)*-1))
                                else:
                                    sat= str(int(((float(position)/10)+180)*10))
                                    satName= "%sE" % str(int(((float(position)/10)-180)*-1))


                            frequencia=str(int(transponder_info["frequency"])/1000)

                            sid = canal.toString().split(":")[3]
                            sid=str(int(sid,16))
                            #                                tmp.write("%s:%s\n"%(nome,sid))
                            bouqs=self.whichBouquets(nome,sat,frequencia,sid,tipo)
                            for bq in bouqs:
                                if config.plugins.Easy.addSat.value:
                                    self.bouquets[bq].append("%s:%s (%s)"%(item[0],nome,satName))
                                else:
                                    self.bouquets[bq].append("%s:%s"%(item[0],nome))

                            if not self.fazParte(nome, self.rulesdict["exclude"], sat, frequencia,sid,tipo):
                                tmpCanal=self.fazParteFavorito(nome, sat, frequencia,sid,tipo)
                                if tmpCanal:
                                    if config.plugins.Easy.addSat.value:
                                        self.favouritesTv.append("%s:%s (%s)"%(item[0],nome,satName))
                                    else:
                                        self.favouritesTv.append("%s:%s"%(item[0],nome))

                        elif tipo=="2":
                            if(position==config.plugins.Easy.pref.value):
                                self.favouritesRadio.append("%s:%s"%(item[0],nome))

                    if config.plugins.Easy.operadora.value and position==config.plugins.Easy.pref.value:
                        self.favoritoOperadora.append("%s:%s"%(item[0],nome))

                self.mudaSituacao(40, _("Deleting all favorites"))

                self.t=eTimer()
                self.t.callback.append(utils.removeoldfiles)
                self.t.callback.append(self.escreveBouquets)
                if config.plugins.Easy.operadora.value:
                    self.t.callback.append(self.escreveOperadoraFavoritos)

                self.t.start(1,True)

                return True
            else:
                self.iniciar.stop()
                self.close()
                return False
Beispiel #37
0
class Services( Source ):
	def __init__(self, session):
		Source.__init__(self)
		self.session = session
		self.servicelist = {}
		self.epgcache = eEPGCache.getInstance()
	
	def buildList(self, ref, epg):
		self.servicelist = ServiceList(ref, command_func = self.getServiceList, validate_commands=False)
		list = self.servicelist.getServicesAsList()
		E2List = [] 
		for index in range(len(list)): 
			item = list[index]
			servicereference = item[0]
			servicename = item[1]
			eventstart = 0
			eventduration = 0
			eventtitle = ""
			eventid = 0
			eventdescription = ""
			eventdescriptionextended = ""
			if epg:
				epgref = item[0]
				events = self.epgcache.lookupEvent(['IBDTSERNX', (epgref, 0, -1)])
				if events:
					if events[0][0] is not None:
						eventid =  events[0][0]
					if events[0][1] is not None:
						eventstart =  events[0][1]
					if events[0][2] is not None:
						eventduration =  events[0][2]
					if events[0][3] is not None:
						eventtitle = events[0][3]
					if events[0][4] is not None:
						eventdescription= events[0][4]
					if events[0][5] is not None:
						eventdescriptionextended= events[0][5]
				E2List.append(E2EPGListAllData(servicereference = servicereference, servicename = servicename, eventstart = eventstart, eventduration = eventduration, eventtitle = eventtitle, eventid = eventid, eventdescription= eventdescription, eventdescriptionextended = eventdescriptionextended))
			else:
					E2List.append(E2ServiceList(servicereference = item[0], servicename = item[1]))
		return E2List

	def buildEPGList(self, ref):
		E2List = [] 
		events = self.epgcache.lookupEvent(['IBDTSERN',(ref,0,-1,-1)]);
		if events:
			for item in events:
				servicereference = ""
				servicename = ""
				eventstart = 0
				eventduration = 0
				eventtitle = ""
				eventid = 0
				eventdescription = ""
				eventdescriptionextended = ""
				if item[6] is not None:
					servicereference = item[6]
				if item[7] is not None:
					servicename = item[7]
				if item[1] is not None:
					eventstart = item[1]
				if item[2] is not None:
					eventduration = item[2]
				if item[3] is not None:
					eventtitle = item[3]
				if item[0] is not None:
					eventid = item[0]
				if item[4] is not None:
					eventdescription = item[4]
				if item[5] is not None:
					eventdescriptionextended = item[5]
				if eventstart != 0:
					E2List.append(E2EPGListAllData(servicereference = servicereference, servicename = servicename, eventstart = eventstart, eventduration = eventduration, eventtitle = eventtitle, eventid = eventid, eventdescription= eventdescription, eventdescriptionextended = eventdescriptionextended))
		return E2List
	
	def getServiceList(self, ref):
		self.servicelist.root = ref
Beispiel #38
0
class ServiceListRecursive(Source):
	FETCH = 0

	def __init__(self, session, func=FETCH):
		Source.__init__(self)

		self.session = session
		self.func = func
		self.servicelist = {}
		self.xml = ""
		self.command = eServiceReference(service_types_tv + ' FROM BOUQUET "bouquets.tv" ORDER BY bouquet')

	def handleCommand(self, cmd):
		self.command = eServiceReference(cmd)

	def do_func(self):
		if self.func == self.FETCH:
			func = self.buildList
		else:
			func = self.buildList

		return func(self.command)

	def buildList(self, ref):
		self.servicelist = ServiceList(ref, command_func=self.getServiceList, validate_commands=False)
		list = self.servicelist.getServicesAsList()
		for item in list:
			self.servicelist.setRoot(eServiceReference(item[0]))
			sub = self.servicelist.getServicesAsList()

			if sub:
				self.xml += "\t<e2bouquet>\n"
				bouquet = True

				subxml = ""
				for (ref, name) in sub:
					subxml += "\t\t\t<e2service>\n"
					subxml += "\t\t\t\t<e2servicereference>%s</e2servicereference>\n\t\t\t\t<e2servicename>%s</e2servicename>\n" % (self.filterXML(ref), self.filterXML(name))
					subxml += "\t\t\t</e2service>\n"

			else:
				self.xml += "\t\t<e2service>\n"
				bouquet = False

			self.xml += "\t\t<e2servicereference>%s</e2servicereference>\n\t\t<e2servicename>%s</e2servicename>\n" % (self.filterXML(item[0]), self.filterXML(item[1]))

			if bouquet:
				self.xml += "\t\t<e2servicelist>\n"
				self.xml += subxml
				self.xml += "\t\t</e2servicelist>\n"
				self.xml += "\t</e2bouquet>\n"
			else:
				self.xml += "\t</e2service>\n"

		return self.xml

	def filterXML(self, item):
		item = item.replace("&", "&amp;").replace("<", "&lt;").replace('"', '&quot;').replace(">", "&gt;")
		return item

	def getServiceList(self, ref):
		self.servicelist.root = ref

	text = property(do_func)
class ServiceListRecursive(Source):
    FETCH = 0

    def __init__(self, session, func=FETCH):
        Source.__init__(self)

        self.session = session
        self.func = func
        self.servicelist = {}
        self.xml = ""
        self.command = eServiceReference(
            service_types_tv + ' FROM BOUQUET "bouquets.tv" ORDER BY bouquet')

    def handleCommand(self, cmd):
        self.command = eServiceReference(cmd)

    def do_func(self):
        if self.func == self.FETCH:
            func = self.buildList
        else:
            func = self.buildList

        return func(self.command)

    def buildList(self, ref):
        self.servicelist = ServiceList(ref,
                                       command_func=self.getServiceList,
                                       validate_commands=False)
        list = self.servicelist.getServicesAsList()
        for item in list:
            self.servicelist.setRoot(eServiceReference(item[0]))
            sub = self.servicelist.getServicesAsList()

            if sub:
                self.xml += "\t<e2bouquet>\n"
                bouquet = True

                subxml = ""
                for (ref, name) in sub:
                    subxml += "\t\t\t<e2service>\n"
                    subxml += "\t\t\t\t<e2servicereference>%s</e2servicereference>\n\t\t\t\t<e2servicename>%s</e2servicename>\n" % (
                        self.filterXML(ref), self.filterXML(name))
                    subxml += "\t\t\t</e2service>\n"

            else:
                self.xml += "\t\t<e2service>\n"
                bouquet = False

            self.xml += "\t\t<e2servicereference>%s</e2servicereference>\n\t\t<e2servicename>%s</e2servicename>\n" % (
                self.filterXML(item[0]), self.filterXML(item[1]))

            if bouquet:
                self.xml += "\t\t<e2servicelist>\n"
                self.xml += subxml
                self.xml += "\t\t</e2servicelist>\n"
                self.xml += "\t</e2bouquet>\n"
            else:
                self.xml += "\t</e2service>\n"

        return self.xml

    def filterXML(self, item):
        item = item.replace("&", "&amp;").replace("<", "&lt;").replace(
            '"', '&quot;').replace(">", "&gt;")
        return item

    def getServiceList(self, ref):
        self.servicelist.root = ref

    text = property(do_func)
Beispiel #40
0
def getServices(sRef,
                showAll=True,
                showHidden=False,
                pos=0,
                provider=False,
                picon=False):
    services = []
    allproviders = {}

    CalcPos = False

    if sRef == "":
        sRef = '%s FROM BOUQUET "bouquets.tv" ORDER BY bouquet' % (
            service_types_tv)
        CalcPos = True
    elif ' "bouquets.radio" ' in sRef:
        CalcPos = True
    elif ' "bouquets.tv" ' in sRef:
        CalcPos = True

    if provider:
        s_type = service_types_tv
        if "radio" in sRef:
            s_type = service_types_radio
        pserviceHandler = eServiceCenter.getInstance()
        pservices = pserviceHandler.list(
            eServiceReference('%s FROM PROVIDERS ORDER BY name' % (s_type)))
        providers = pservices and pservices.getContent("SN", True)

        if provider:
            for provider in providers:
                servicelist = ServiceList(eServiceReference(provider[0]))
                slist = servicelist.getServicesAsList()
                for sitem in slist:
                    allproviders[sitem[0]] = provider[1]

    servicelist = ServiceList(eServiceReference(sRef))
    slist = servicelist.getServicesAsList()
    serviceHandler = eServiceCenter.getInstance()

    oPos = 0
    for sitem in slist:

        oldoPos = oPos
        sref = sitem[0]
        if CalcPos and 'userbouquet' in sref:
            serviceslist = serviceHandler.list(eServiceReference(sref))
            sfulllist = serviceslist and serviceslist.getContent("RN", True)
            for citem in sfulllist:
                sref = citem[0].toString()
                hs = (int(sref.split(":")[1]) & 512)
                sp = (sref[:7] == '1:832:D') or (sref[:7]
                                                 == '1:832:1') or (sref[:6]
                                                                   == '1:320:')
                if not hs or sp:  # 512 is hidden service on sifteam image. Doesn't affect other images
                    oPos = oPos + 1
                    if not sp and citem[0].flags & eServiceReference.isMarker:
                        oPos = oPos - 1

        st = int(sitem[0].split(":")[1])
        sp = (sitem[0][:7] == '1:832:D') or (sitem[0][:7]
                                             == '1:832:1') or (sitem[0][:6]
                                                               == '1:320:')
        if sp or (not (st & 512) and not (st & 64)):
            pos = pos + 1
        if not st & 512 or showHidden:
            if showAll or st == 0:
                service = {}
                service['pos'] = 0 if (st & 64) else pos
                sr = unicode(sitem[0], 'utf_8',
                             errors='ignore').encode('utf_8', 'ignore')
                if CalcPos:
                    service['startpos'] = oldoPos
                if picon:
                    service['picon'] = getPicon(sr)
                service['servicereference'] = sr
                service['program'] = int(
                    service['servicereference'].split(':')[3], 16)
                service['servicename'] = unicode(sitem[1],
                                                 'utf_8',
                                                 errors='ignore').encode(
                                                     'utf_8', 'ignore')
                if provider:
                    if sitem[0] in allproviders:
                        service['provider'] = allproviders[sitem[0]]
                    else:
                        service['provider'] = ""
                services.append(service)

    return {"services": services, "pos": pos}
Beispiel #41
0
    def setValue(self, oid, value):
        #the first time we are called, we have to fill the bisect oid store, values are just values, no objects (we cannot call value.get)
        try:
            value.get()
        except:
            return bisectoidstore.BisectOIDStore.setValue(self, oid, value)

        oidstring = bisectoidstore.sortableToOID(oid)
        if oidstring == self.MANAGERIP_OID:
            if config.plugins.SnmpAgent.managerip.value <> value.get():
                config.plugins.SnmpAgent.managerip.value = value.get()
                config.plugins.SnmpAgent.managerip.save()
        elif oidstring == self.ENABLE_BITRATE_OID:
            if config.plugins.SnmpAgent.measurebitrate.value and not value.get(
            ):
                config.plugins.SnmpAgent.measurebitrate.value = False
                config.plugins.SnmpAgent.measurebitrate.save()
                if self.bitrate:
                    self.bitrate.stop()
                    self.bitrate = None
            elif not config.plugins.SnmpAgent.measurebitrate.value and value.get(
            ):
                config.plugins.SnmpAgent.measurebitrate.value = True
                config.plugins.SnmpAgent.measurebitrate.save()
                self.bitrate = Bitrate(self.session)
                self.bitrate.start()
        elif oidstring == self.SYSTEMNAME_OID:
            if config.plugins.SnmpAgent.systemname.value <> value.get():
                config.plugins.SnmpAgent.systemname.value = value.get()
                config.plugins.SnmpAgent.systemname.save()
        elif oidstring == self.SUPPORTADDRESS_OID:
            if config.plugins.SnmpAgent.supportaddress.value <> value.get():
                config.plugins.SnmpAgent.supportaddress.value = value.get()
                config.plugins.SnmpAgent.supportaddress.save()
        elif oidstring == self.SYSTEMDESCRIPTION_OID:
            if config.plugins.SnmpAgent.systemdescription.value <> value.get():
                config.plugins.SnmpAgent.systemdescription.value = value.get()
                config.plugins.SnmpAgent.systemdescription.save()
        elif oidstring == self.LOCATION_OID:
            if config.plugins.SnmpAgent.location.value <> value.get():
                config.plugins.SnmpAgent.location.value = value.get()
                config.plugins.SnmpAgent.location.save()
        elif oidstring == self.CHANNELNAME_OID:
            if self.getChannelName() <> value.get():
                root = config.tv.lastroot.value.split(';')
                fav = eServiceReference(root[-2])
                services = ServiceList(fav,
                                       command_func=self.zapTo,
                                       validate_commands=False)
                sub = services.getServicesAsList()

                if len(sub) > 0:
                    for (ref, name) in sub:
                        if name == value.get():
                            self.zapTo(eServiceReference(ref))
                            break
        elif oidstring == self.SERVICESTRING_OID:
            if self.getServiceString() <> value.get():
                self.zapTo(eServiceReference(value.get()))
        elif oidstring == self.FASTSCANSTRING_OID:
            refstring = ''
            fields = value.get().split(',')
            if len(fields) >= 15:
                onid, tsid, freq, id1, id2, sid, orbital_pos, f1, f2, f3, symbolrate, f4, name, provider, servicetype = fields[
                    0:15]
                refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % (
                    1, 0, int(servicetype), int(sid), int(tsid), int(onid),
                    int(orbital_pos) * 65536, 0, 0, 0)
            if refstring is not '':
                self.zapTo(eServiceReference(refstring))
        elif oidstring == self.SERVICEPARAMS_OID:
            refstring = ''
            fields = value.get().split(',')
            if len(fields) >= 5:
                orbital_pos, tsid, onid, sid, servicetype = fields[0:5]
                refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % (
                    1, 0, int(servicetype), int(sid), int(tsid), int(onid),
                    int(orbital_pos) * 65536, 0, 0, 0)
            if refstring is not '':
                self.zapTo(eServiceReference(refstring))
        elif oidstring == self.IP_OID:
            ipstring = value.get().split('.')
            ipval = []
            for x in ipstring:
                ipval.append(int(x))
            if iNetwork.getAdapterAttribute(self.iface, "ip") <> ipval:
                iNetwork.setAdapterAttribute(self.iface, "dhcp", 0)
                iNetwork.setAdapterAttribute(self.iface, "ip", ipval)
                iNetwork.deactivateNetworkConfig()
                iNetwork.writeNetworkConfig()
                iNetwork.activateNetworkConfig()
        elif oidstring == self.IP_OID:
            ipstring = value.get().split('.')
            ipval = []
            for x in ipstring:
                ipval.append(int(x))
            if iNetwork.getAdapterAttribute(self.iface, "netmask") <> ipval:
                iNetwork.setAdapterAttribute(self.iface, "dhcp", 0)
                iNetwork.setAdapterAttribute(self.iface, "netmask", ipval)
                iNetwork.deactivateNetworkConfig()
                iNetwork.writeNetworkConfig()
                iNetwork.activateNetworkConfig()
        elif oidstring == self.GATEWAY_OID:
            ipstring = value.get().split('.')
            ipval = []
            for x in ipstring:
                ipval.append(int(x))
            if iNetwork.getAdapterAttribute(self.iface, "gateway") <> ipval:
                iNetwork.setAdapterAttribute(self.iface, "dhcp", 0)
                iNetwork.setAdapterAttribute(self.iface, "gateway", ipval)
                iNetwork.deactivateNetworkConfig()
                iNetwork.writeNetworkConfig()
                iNetwork.activateNetworkConfig()
        elif oidstring == self.ENABLE_EMM_OID:
            if config.plugins.SnmpAgent.checkemm.value and not value.get():
                config.plugins.SnmpAgent.checkemm.value = False
                config.plugins.SnmpAgent.checkemm.save()
                if self.emm:
                    self.emm.stop()
                    self.emm = None
            elif not config.plugins.SnmpAgent.checkemm.value and value.get():
                config.plugins.SnmpAgent.checkemm.value = True
                config.plugins.SnmpAgent.checkemm.save()
                self.emm = Emm(self.session)
                self.emm.start()
        else:
            print "oid not found!?"

        return None
def getServices(sRef, showAll=True, showHidden=False, pos=0, provider=False, picon=False):
	services = []
	allproviders = {}

	CalcPos = False

	if sRef == "":
		sRef = '%s FROM BOUQUET "bouquets.tv" ORDER BY bouquet' % (service_types_tv)
		CalcPos = True
	elif ' "bouquets.radio" ' in sRef:
		CalcPos = True
	elif ' "bouquets.tv" ' in sRef:
		CalcPos = True

	if provider:
		s_type = service_types_tv
		if "radio" in sRef:
			s_type = service_types_radio
		pserviceHandler = eServiceCenter.getInstance()
		pservices = pserviceHandler.list(eServiceReference('%s FROM PROVIDERS ORDER BY name' % (s_type)))
		providers = pservices and pservices.getContent("SN", True)

		if provider:
			for provider in providers:
				servicelist = ServiceList(eServiceReference(provider[0]))
				slist = servicelist.getServicesAsList()
				for sitem in slist:
					allproviders[sitem[0]] = provider[1]

	servicelist = ServiceList(eServiceReference(sRef))
	slist = servicelist.getServicesAsList()
	serviceHandler = eServiceCenter.getInstance()

	oPos = 0
	for sitem in slist:
		
		oldoPos = oPos
		if CalcPos:
			sref = sitem[0]
			serviceslist = serviceHandler.list(eServiceReference(sref))
			sfulllist = serviceslist and serviceslist.getContent("RN", True)
			for citem in sfulllist:
				sref = citem[0].toString()
				hs = (int(sref.split(":")[1]) & 512)
				sp = (sref[:7] == '1:832:D')
				if not hs or sp:  # 512 is hidden service on sifteam image. Doesn't affect other images
					oPos = oPos + 1
					if not sp and citem[0].flags & eServiceReference.isMarker:
						oPos = oPos - 1

		st = int(sitem[0].split(":")[1])
		if (sitem[0][:7] == '1:832:D') or (not (st & 512) and not (st & 64)):
			pos = pos + 1
		if not st & 512 or showHidden:
			if showAll or st == 0:
				service = {}
				service['pos'] = 0 if (st & 64) else pos
				sr = unicode(sitem[0], 'utf_8', errors='ignore').encode('utf_8', 'ignore')
				if CalcPos:
					service['startpos'] = oldoPos
				if picon:
					service['picon'] = getPicon(sr)
				service['servicereference'] = sr
				service['program'] = int(service['servicereference'].split(':')[3], 16)
				service['servicename'] = unicode(sitem[1], 'utf_8', errors='ignore').encode('utf_8', 'ignore')
				if provider:
					if sitem[0] in allproviders:
						service['provider'] = allproviders[sitem[0]]
					else:
						service['provider'] = ""
				services.append(service)

	return {"services": services, "pos": pos}