コード例 #1
0
 def moveService(self, param):
     print "[WebComponents.BouquetEditor] moveService with param = ", param
     sBouquetRef = param["sBouquetRef"]
     if sBouquetRef is None:
         return (False, _("No bouquet given!"))
     sRef = None
     if "sRef" in param:
         if param["sRef"] is not None:
             sRef = param["sRef"]
     if sRef is None:
         return (False, _("No service given!"))
     position = None
     if "position" in param:
         if param["position"] is not None:
             position = int(param["position"])
     if position is None:
         return (False, _("No position given!"))
     mutableBouquetList = self.getMutableList(
         eServiceReference(sBouquetRef))
     if mutableBouquetList is not None:
         ref = eServiceReference(sRef)
         mutableBouquetList.moveService(ref, position)
         mutableBouquetList.flushChanges()
         self.setRoot(sBouquetRef)
         return (True, _("Service %s moved.") % self.getName(ref))
     return (False, _("Service can not be moved."))
コード例 #2
0
	def addMarkerToBouquet(self, param):
		print "[WebComponents.BouquetEditor] addMarkerToBouquet with param = ", param
		sBouquetRef = param["sBouquetRef"]
		if sBouquetRef is None:
			return (False, _("No bouquet given!"))
		name = None
		if "Name" in param:
			if param["Name"] is not None:
				name =param["Name"]
		if name is None:
			if not "SP" in param:
				return (False, _("No marker-name given!"))
		sRefBefore = eServiceReference()
		if "sRefBefore" in param:
			if param["sRefBefore"] is not None:
				sRefBefore = eServiceReference(param["sRefBefore"])
		bouquet_ref = eServiceReference(sBouquetRef) 
		mutableBouquetList = self.getMutableList(bouquet_ref)
		cnt = 0
		while mutableBouquetList:
			if name is None:
				service_str = '1:832:D:%d:0:0:0:0:0:0:'% cnt
			else:
				service_str = '1:64:%d:0:0:0:0:0:0:0::%s'%(cnt, name)
			ref = eServiceReference(service_str)
			if not mutableBouquetList.addService(ref, sRefBefore):
				mutableBouquetList.flushChanges()
				self.setRoot(sBouquetRef)
				return (True, _("Marker added."))
			cnt+=1
		return (False, _("Internal error!"))
コード例 #3
0
def setSleepTimer(session, time, action, enabled):
    if action not in ["shutdown", "standby"]:
        action = "standby"

    if hasattr(session.nav, "SleepTimer"):
        try:
            ret = getSleepTimer(session)
            from Screens.Standby import inStandby
            if inStandby is not None:
                ret["message"] = _(
                    "ERROR: Cannot set SleepTimer while device is in Standby-Mode"
                )
                return ret
            if enabled == False:
                session.nav.SleepTimer.clear()
                ret = getSleepTimer(session)
                ret["message"] = _("Sleeptimer has been disabled")
                return ret
            config.SleepTimer.action.value = action
            config.SleepTimer.action.save()
            session.nav.SleepTimer.setSleepTime(time)
            ret = getSleepTimer(session)
            ret["message"] = _("Sleeptimer set to %d minutes") % time
            return ret
        except Exception, e:
            return {"result": False, "message": _("SleepTimer Error")}
コード例 #4
0
 def addMarkerToBouquet(self, param):
     print "[WebComponents.BouquetEditor] addMarkerToBouquet with param = ", param
     sBouquetRef = param["sBouquetRef"]
     if sBouquetRef is None:
         return (False, _("No bouquet given!"))
     name = None
     if "Name" in param:
         if param["Name"] is not None:
             name = param["Name"]
     if name is None:
         if not "SP" in param:
             return (False, _("No marker-name given!"))
     sRefBefore = eServiceReference()
     if "sRefBefore" in param:
         if param["sRefBefore"] is not None:
             sRefBefore = eServiceReference(param["sRefBefore"])
     bouquet_ref = eServiceReference(sBouquetRef)
     mutableBouquetList = self.getMutableList(bouquet_ref)
     cnt = 0
     while mutableBouquetList:
         if name is None:
             service_str = '1:832:D:%d:0:0:0:0:0:0:' % cnt
         else:
             service_str = '1:64:%d:0:0:0:0:0:0:0::%s' % (cnt, name)
         ref = eServiceReference(service_str)
         if not mutableBouquetList.addService(ref, sRefBefore):
             mutableBouquetList.flushChanges()
             self.setRoot(sBouquetRef)
             return (True, _("Marker added."))
         cnt += 1
     return (False, _("Internal error!"))
コード例 #5
0
 def removeService(self, param):
     print "[WebComponents.BouquetEditor] removeService with param = ", param
     sBouquetRef = param["sBouquetRef"]
     if sBouquetRef is None:
         return (False, _("No bouquet given!"))
     sRef = None
     if "sRef" in param:
         if param["sRef"] is not None:
             sRef = param["sRef"]
     if sRef is None:
         return (False, _("No service given!"))
     ref = eServiceReference(sRef)
     if ref.flags & eServiceReference.isGroup:  # check if  service is an alternative, if so delete it with removeBouquet
         new_param = {}
         new_param["sBouquetRef"] = sRef
         new_param[
             "mode"] = None  # of no interest when passing BouquetRefRoot
         new_param["BouquetRefRoot"] = sBouquetRef
         returnValue = self.removeBouquet(new_param)
         if returnValue[0]:
             return (True, _("Service %s removed.") % self.getName(ref))
     else:
         bouquetRef = eServiceReference(sBouquetRef)
         mutableBouquetList = self.getMutableList(bouquetRef)
         if mutableBouquetList is not None:
             if not mutableBouquetList.removeService(ref):
                 mutableBouquetList.flushChanges()
                 self.setRoot(sBouquetRef)
                 return (True, _("Service %s removed from bouquet %s.") %
                         (self.getName(ref), self.getName(bouquetRef)))
     return (False, _("Service %s can not be removed.") % self.getName(ref))
コード例 #6
0
ファイル: ipkg.py プロジェクト: lprot/e2openplugin-OpenWebif
 def render_POST(self, request):
     request.setResponseCode(http.OK)
     request.setHeader('content-type', 'text/plain')
     request.setHeader('charset', 'UTF-8')
     content = request.args['rfile'][0]
     filename = self.mbasename(request.args['filename'][0])
     if not content or not config.OpenWebif.allow_upload_ipk.value:
         result = [False, _('Error upload File')]
     else:
         if not filename.endswith(".ipk"):
             result = [False, _('wrong filetype')]
         else:
             FN = "/tmp/" + filename  # nosec
             fileh = os.open(FN, os.O_WRONLY | os.O_CREAT)
             bytes = 0
             if fileh:
                 bytes = os.write(fileh, content)
                 os.close(fileh)
             if bytes <= 0:
                 try:
                     os.remove(FN)
                 except OSError, oe:
                     pass
                 result = [False, _('Error writing File')]
             else:
                 result = [True, FN]
コード例 #7
0
def getJsonFromConfig(cnf):
    if cnf.__class__.__name__ == "ConfigSelection" or cnf.__class__.__name__ == "ConfigSelectionNumber":
        if type(cnf.choices.choices) == dict:
            choices = []
            for choice in cnf.choices.choices:
                choices.append((choice, _(cnf.choices.choices[choice])))
        elif type(cnf.choices.choices[0]) == tuple:
            choices = []
            for choice_tuple in cnf.choices.choices:
                choices.append((choice_tuple[0], _(choice_tuple[1])))
        else:
            choices = []
            for choice in cnf.choices.choices:
                choices.append((choice, _(choice)))

        return {"result": True, "type": "select", "choices": choices, "current": cnf.value}
    elif (
        cnf.__class__.__name__ == "ConfigBoolean"
        or cnf.__class__.__name__ == "ConfigEnableDisable"
        or cnf.__class__.__name__ == "ConfigYesNo"
    ):
        return {"result": True, "type": "checkbox", "current": cnf.value}
    elif cnf.__class__.__name__ == "ConfigSet":
        return {"result": True, "type": "multicheckbox", "choices": cnf.choices.choices, "current": cnf.value}

    elif cnf.__class__.__name__ == "ConfigNumber":
        return {"result": True, "type": "number", "current": cnf.value}
    elif cnf.__class__.__name__ == "ConfigInteger":
        return {"result": True, "type": "number", "current": cnf.value, "limits": (cnf.limits[0][0], cnf.limits[0][1])}

    elif cnf.__class__.__name__ == "ConfigText":
        return {"result": True, "type": "text", "current": cnf.value}

    print "[OpenWebif] Unknown class ", cnf.__class__.__name__
    return {"result": False, "type": "unknown"}
コード例 #8
0
 def moveBouquet(self, param):
     print "[WebComponents.BouquetEditor] moveBouquet with param = ", param
     sBouquetRef = param["sBouquetRef"]
     if sBouquetRef is None:
         return (False, _("No bouquet name given!"))
     mode = MODE_TV  # init
     if "mode" in param:
         if param["mode"] is not None:
             mode = int(param["mode"])
     position = None
     if "position" in param:
         if param["position"] is not None:
             position = int(param["position"])
     if position is None:
         return (False, _("No position given!"))
     mutableBouquetList = self.getMutableBouquetList(mode)
     if mutableBouquetList is not None:
         ref = eServiceReference(sBouquetRef)
         mutableBouquetList.moveService(ref, position)
         mutableBouquetList.flushChanges()
         self.setRoot(self.bouquet_rootstr)
         return (True, _("Bouquet %s moved.") % self.getName(ref))
     else:
         return (False,
                 _("Bouquet %s can not be moved.") % self.getName(ref))
コード例 #9
0
ファイル: timers.py プロジェクト: HDMU/e2openplugin-OpenWebif
def setSleepTimer(session, time, action, enabled):
	if action not in ["shutdown", "standby"]:
		action = "standby"

	if hasattr(session.nav, "SleepTimer"):
		try:
			ret = getSleepTimer(session)
			from Screens.Standby import inStandby
			if inStandby is not None:
				ret["message"] = _("ERROR: Cannot set SleepTimer while device is in Standby-Mode")
				return ret
			if enabled == False:
				session.nav.SleepTimer.clear()
				ret = getSleepTimer(session)
				ret["message"] = _("Sleeptimer has been disabled")
				return ret
			config.SleepTimer.action.value = action
			config.SleepTimer.action.save()
			session.nav.SleepTimer.setSleepTime(time)
			ret = getSleepTimer(session)
			ret["message"] = _("Sleeptimer set to %d minutes") % time
			return ret
		except Exception, e:
			return {
				"result": False,
				"message": _("SleepTimer Error")
			}
コード例 #10
0
	def addBouquet(self, bName, mode, services):
		if config.usage.multibouquet.value:
			mutableBouquetList = self.getMutableBouquetList(mode)
			if mutableBouquetList:
				if mode == MODE_TV:
					bName += " (TV)"
					sref = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET \"userbouquet.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(bName, "userbouquet.", mode))
				else:
					bName += " (Radio)"
					sref = '1:7:2:0:0:0:0:0:0:0:FROM BOUQUET \"userbouquet.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(bName, "userbouquet.", mode))
				new_bouquet_ref = eServiceReference(sref)
				if not mutableBouquetList.addService(new_bouquet_ref):
					mutableBouquetList.flushChanges()
					eDVBDB.getInstance().reloadBouquets()
					mutableBouquet = self.getMutableList(new_bouquet_ref)
					if mutableBouquet:
						mutableBouquet.setListName(bName)
						if services is not None:
							for service in services:
								if mutableBouquet.addService(service):
									print "add", service.toString(), "to new bouquet failed"
						mutableBouquet.flushChanges()
						self.setRoot(self.bouquet_rootstr)
						return (True, _("Bouquet %s created.") % bName)
					else:
						return (False, _("Get mutable list for new created bouquet failed!"))

				else:
					return (False, _("Bouquet %s already exists.") % bName)
			else:
				return (False, _("Bouquetlist is not editable!"))
		else:
			return (False, _("Multi-Bouquet is not enabled!"))
コード例 #11
0
def getAdapterIPv6(ifname):
	addr = _("IPv4-only kernel")
	
	if fileExists('/proc/net/if_inet6'):
		addr = _("IPv4-only Python/Twisted")

		if has_ipv6 and version.major >= 12:
			proc = '/proc/net/if_inet6'
			tempaddrs = []
			for line in file(proc).readlines():
				if line.startswith('fe80'):
					continue

				tmpaddr = ""
				tmp = line.split()
				if ifname == tmp[5]:
					tmpaddr = ":".join([ tmp[0][i:i+4] for i in range(0,len(tmp[0]),4) ])

					if tmp[2].lower() != "ff":
						tmpaddr = "%s/%s" % (tmpaddr, int(tmp[2].lower(), 16))

					tempaddrs.append(normalize_ipv6(tmpaddr))

			if len(tempaddrs) > 1:
				tempaddrs.sort()
				addr = ', '.join(tempaddrs)
			elif len(tempaddrs) == 1:
				addr = tempaddrs[0]
			elif len(tempaddrs) == 0:
				addr = _("none/IPv4-only network")

	return (addr)
コード例 #12
0
 def addServiceToBouquet(self, param):
     print "[WebComponents.BouquetEditor] addService with param = ", param
     sBouquetRef = param["sBouquetRef"]
     if sBouquetRef is None:
         return (False, _("No bouquet given!"))
     sRef = None
     if "sRef" in param:
         if param["sRef"] is not None:
             sRef = param["sRef"]
     if sRef is None:
         return (False, _("No service given!"))
     sName = None
     if "Name" in param:
         if param["Name"] is not None:
             sName = param["Name"]
     sRefBefore = eServiceReference()
     if "sRefBefore" in param:
         if param["sRefBefore"] is not None:
             sRefBefore = eServiceReference(param["sRefBefore"])
     bouquetRef = eServiceReference(sBouquetRef)
     mutableBouquetList = self.getMutableList(bouquetRef)
     if mutableBouquetList is not None:
         ref = eServiceReference(sRef)
         if sName:
             ref.setName(sName)
         if not mutableBouquetList.addService(ref, sRefBefore):
             mutableBouquetList.flushChanges()
             self.setRoot(sBouquetRef)
             return (True, _("Service %s added.") % self.getName(ref))
         else:
             bouquetName = self.getName(bouquetRef)
             return (False, _("Service %s already exists in bouquet %s.") %
                     (self.getName(ref), bouquetName))
     return (False, _("This service can not be added."))
コード例 #13
0
	def addBouquet(self, bName, mode, services):
		if config.usage.multibouquet.value:
			mutableBouquetList = self.getMutableBouquetList(mode)
			if mutableBouquetList:
				if mode == MODE_TV:
					bName += " (TV)"
					sref = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET \"userbouquet.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(bName, "userbouquet.", mode))
				else:
					bName += " (Radio)"
					sref = '1:7:2:0:0:0:0:0:0:0:FROM BOUQUET \"userbouquet.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(bName, "userbouquet.", mode))
				new_bouquet_ref = eServiceReference(sref)
				if not mutableBouquetList.addService(new_bouquet_ref):
					mutableBouquetList.flushChanges()
					eDVBDB.getInstance().reloadBouquets()
					mutableBouquet = self.getMutableList(new_bouquet_ref)
					if mutableBouquet:
						mutableBouquet.setListName(bName)
						if services is not None:
							for service in services:
								if mutableBouquet.addService(service):
									print "add", service.toString(), "to new bouquet failed"
						mutableBouquet.flushChanges()
						self.setRoot(self.bouquet_rootstr)
						return (True, _("Bouquet %s created.") % bName)
					else:
						return (False, _("Get mutable list for new created bouquet failed!"))

				else:
					return (False, _("Bouquet %s already exists.") % bName)
			else:
				return (False, _("Bouquetlist is not editable!"))
		else:
			return (False, _("Multi-Bouquet is not enabled!"))
コード例 #14
0
ファイル: base.py プロジェクト: rdamas/e2openplugin-OpenWebif
    def prepareMainTemplate(self):
        # here will be generated the dictionary for the main template
        ret = getCollapsedMenus()
        ret["remotegrabscreenshot"] = getRemoteGrabScreenshot()["remotegrabscreenshot"]
        ret["configsections"] = getConfigsSections()["sections"]
        ret["zapstream"] = getZapStream()["zapstream"]
        ret["showname"] = getShowName()["showname"]
        ret["customname"] = getCustomName()["customname"]
        ret["boxname"] = getBoxName()["boxname"]
        if not ret["boxname"] or not ret["customname"]:
            ret["boxname"] = getInfo()["brand"] + " " + getInfo()["model"]
        ret["box"] = getBoxType()
        ret["remote"] = remote
        from Components.config import config

        if hasattr(eEPGCache, "FULL_DESCRIPTION_SEARCH"):
            ret["epgsearchcaps"] = True
        else:
            ret["epgsearchcaps"] = False
            if config.OpenWebif.webcache.epg_desc_search.value:
                config.OpenWebif.webcache.epg_desc_search.value = False
                config.OpenWebif.webcache.epg_desc_search.save()
        ret["epgsearchtype"] = getEPGSearchType()["epgsearchtype"]
        extras = []
        extras.append({"key": "ajax/settings", "description": _("Settings")})
        if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/LCD4linux/WebSite.pyo")):
            lcd4linux_key = "lcd4linux/config"
            if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/WebInterface/plugin.pyo")):
                from Components.Network import iNetwork

                ifaces = iNetwork.getConfiguredAdapters()
                if len(ifaces):
                    ip_list = iNetwork.getAdapterAttribute(ifaces[0], "ip")  # use only the first configured interface
                    ip = "%d.%d.%d.%d" % (ip_list[0], ip_list[1], ip_list[2], ip_list[3])
                try:
                    lcd4linux_port = "http://" + ip + ":" + str(config.plugins.Webinterface.http.port.value) + "/"
                    lcd4linux_key = lcd4linux_port + "lcd4linux/config"
                except KeyError:
                    lcd4linux_key = None
            if lcd4linux_key:
                extras.append({"key": lcd4linux_key, "description": _("LCD4Linux Setup")})

        try:
            from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer

            extras.append({"key": "ajax/at", "description": _("AutoTimer")})
        except ImportError:
            pass
        if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/bqe.tmpl")):
            extras.append({"key": "ajax/bqe", "description": _("BouquetEditor")})

        try:
            from Plugins.Extensions.EPGRefresh.EPGRefresh import epgrefresh

            extras.append({"key": "ajax/epgr", "description": _("EPGRefresh")})
        except ImportError:
            pass
        ret["extras"] = extras

        return ret
コード例 #15
0
	def removeService(self, param):
		print "[WebComponents.BouquetEditor] removeService with param = ", param
		sBouquetRef = param["sBouquetRef"]
		if sBouquetRef is None:
			return (False, _("No bouquet given!"))
		sRef = None
		if "sRef" in param:
			if param["sRef"] is not None:
				sRef =param["sRef"]
		if sRef is None:
			return (False, _("No service given!"))
		ref = eServiceReference(sRef)
		if ref.flags & eServiceReference.isGroup: # check if  service is an alternative, if so delete it with removeBouquet
			new_param = {}
			new_param["sBouquetRef"] = sRef
			new_param["mode"] = None # of no interest when passing BouquetRefRoot
			new_param["BouquetRefRoot"] = sBouquetRef
			returnValue = self.removeBouquet(new_param)
			if returnValue[0]:
				return (True, _("Service %s removed.") % self.getName(ref))
		else:
			bouquetRef = eServiceReference(sBouquetRef)
			mutableBouquetList = self.getMutableList(bouquetRef)
			if mutableBouquetList is not None:
				if not mutableBouquetList.removeService(ref):
					mutableBouquetList.flushChanges()
					self.setRoot(sBouquetRef)
					return (True, _("Service %s removed from bouquet %s.") % (self.getName(ref), self.getName(bouquetRef)))
		return (False, _("Service %s can not be removed.") % self.getName(ref))
コード例 #16
0
	def moveService(self, param):
		print "[WebComponents.BouquetEditor] moveService with param = ", param
		sBouquetRef = param["sBouquetRef"]
		if sBouquetRef is None:
			return (False,_( "No bouquet given!"))
		sRef = None
		if "sRef" in param:
			if param["sRef"] is not None:
				sRef =param["sRef"]
		if sRef is None:
			return (False, _("No service given!"))
		position = None
		if "position" in param:
			if param["position"] is not None:
				position = int(param["position"])
		if position is None:
			return (False, _("No position given!"))
		mutableBouquetList = self.getMutableList(eServiceReference(sBouquetRef))
		if mutableBouquetList is not None:
			ref = eServiceReference(sRef)
			mutableBouquetList.moveService(ref, position)
			mutableBouquetList.flushChanges()
			self.setRoot(sBouquetRef)
			return (True, _("Service %s moved.") % self.getName(ref))
		return (False, _("Service can not be moved."))
コード例 #17
0
	def addServiceToBouquet(self, param):
		print "[WebComponents.BouquetEditor] addService with param = ", param
		sBouquetRef = param["sBouquetRef"]
		if sBouquetRef is None:
			return (False, _("No bouquet given!"))
		sRef = None
		if "sRef" in param:
			if param["sRef"] is not None:
				sRef =param["sRef"]
		if sRef is None:
			return (False, _("No service given!"))
		sName = None
		if "Name" in param:
			if param["Name"] is not None:
				sName =param["Name"]
		sRefBefore = eServiceReference()
		if "sRefBefore" in param:
			if param["sRefBefore"] is not None:
				sRefBefore = eServiceReference(param["sRefBefore"])
		bouquetRef = eServiceReference(sBouquetRef)
		mutableBouquetList = self.getMutableList(bouquetRef)
		if mutableBouquetList is not None:
			ref = eServiceReference(sRef)
			if sName:
				ref.setName(sName)
			if not mutableBouquetList.addService(ref, sRefBefore):
				mutableBouquetList.flushChanges()
				self.setRoot(sBouquetRef)
				return (True, _("Service %s added.") % self.getName(ref))
			else:
				bouquetName = self.getName(bouquetRef)
				return (False, _("Service %s already exists in bouquet %s.") % (self.getName(ref), bouquetName))
		return (False, _("This service can not be added."))
コード例 #18
0
def editTimer(session, serviceref, begin, end, name, description, disabled, justplay, afterEvent, dirname, tags, repeated, channelOld, beginOld, endOld, vpsinfo, always_zap):
	# TODO: exception handling
	serviceref = unquote(serviceref)
	channelOld_str =  ':'.join(str(channelOld).split(':')[:11])
	rt = session.nav.RecordTimer
	for timer in rt.timer_list + rt.processed_timers:
		needed_ref = ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == channelOld_str
		if needed_ref and int(timer.begin) == beginOld and int(timer.end) == endOld:
			timer.service_ref = ServiceReference(serviceref)
			# TODO: start end time check
			timer.begin = int(float(begin))
			timer.end = int(float(end))
			timer.name = name
			timer.description = description
			# TODO : EIT
			#timer.eit = eit
			timer.disabled = disabled
			timer.justplay = justplay
			timer.afterEvent = afterEvent
			timer.dirname = dirname
			timer.tags = tags
			timer.repeated = repeated
			timer.processRepeated()
			if vpsinfo is not None:
				timer.vpsplugin_enabled = vpsinfo["vpsplugin_enabled"]
				timer.vpsplugin_overwrite = vpsinfo["vpsplugin_overwrite"]
				timer.vpsplugin_time = vpsinfo["vpsplugin_time"]

			if always_zap <> -1:
				if hasattr(timer,"always_zap"):
					timer.always_zap = always_zap == 1

			# TODO: multi tuner test
			sanity = TimerSanityCheck(rt.timer_list, timer)
			conflicts = None
			if not sanity.check():
				conflicts = sanity.getSimulTimerList()
				if conflicts is not None:
					for conflict in conflicts:
						if conflict.setAutoincreaseEnd(entry):
							rt.timeChanged(conflict)
							if not sanity.check():
								conflicts = sanity.getSimulTimerList()
			if conflicts is None:
				rt.timeChanged(timer)
				return {
					"result": True,
					"message": _("Timer '%s' changed") % name
				}
			else:
				return {
					"result": False,
					"message": _("Timer '%s' not saved while Conflict") % name
				}

	return {
		"result": False,
		"message": _("Could not find timer '%s' with given start and end time!") % name
	}
コード例 #19
0
ファイル: web.py プロジェクト: OpenLD/e2openplugin-OpenWebif
    def testMandatoryArguments(self, request, keys):
        for key in keys:
            if key not in request.args.keys():
                return {"result": False, "message": _("Missing mandatory parameter '%s'") % key}

            if len(request.args[key][0]) == 0:
                return {"result": False, "message": _("The parameter '%s' can't be empty") % key}

        return None
コード例 #20
0
def addTimer(session, serviceref, begin, end, name, description, disabled, justplay, afterevent, dirname, tags, repeated, vpsinfo=None, logentries=None, eit=0, always_zap=-1):
	serviceref = unquote(serviceref)
	rt = session.nav.RecordTimer

	print "mao1", dirname

	if not dirname:
		dirname = preferredTimerPath()

	print "mao2", dirname

	try:
		timer = RecordTimerEntry(
			ServiceReference(serviceref),
			begin,
			end,
			name,
			description,
			eit,
			disabled,
			justplay,
			afterevent,
			dirname=dirname,
			tags=tags)

		timer.repeated = repeated

		if logentries:
			timer.log_entries = logentries

		conflicts = rt.record(timer)
		if conflicts:
			errors = []
			for conflict in conflicts:
				errors.append(conflict.name)

			return {
				"result": False,
				"message": _("Conflicting Timer(s) detected! %s") % " / ".join(errors)
			}
		#VPS
		if vpsinfo is not None:
			timer.vpsplugin_enabled = vpsinfo["vpsplugin_enabled"]
			timer.vpsplugin_overwrite = vpsinfo["vpsplugin_overwrite"]
			timer.vpsplugin_time = vpsinfo["vpsplugin_time"]

		if always_zap <> -1:
			if hasattr(timer,"always_zap"):
				timer.always_zap = always_zap == 1

	except Exception, e:
		print e
		return {
			"result": False,
			"message": _("Could not add timer '%s'!") % name
		}
コード例 #21
0
 def toggleLock(self, param):
     if not config.ParentalControl.configured.value:
         return (False, _("Parent Control is not activated."))
     sRef = None
     if "sRef" in param:
         if param["sRef"] is not None:
             sRef = param["sRef"]
     if sRef is None:
         return (False, _("No service given!"))
     if "setuppinactive" in config.ParentalControl.dict().keys(
     ) and config.ParentalControl.setuppinactive.value:
         password = None
         if "password" in param:
             if param["password"] is not None:
                 password = param["password"]
         if password is None:
             return (False, _("No Parent Control Setup Pin given!"))
         else:
             if password.isdigit():
                 if int(password) != config.ParentalControl.setuppin.value:
                     return (False, _("Parent Control Setup Pin is wrong!"))
             else:
                 return (False, _("Parent Control Setup Pin is wrong!"))
     cur_ref = eServiceReference(sRef)
     protection = parentalControl.getProtectionLevel(
         cur_ref.toCompareString())
     if protection:
         parentalControl.unProtectService(cur_ref.toCompareString())
     else:
         parentalControl.protectService(cur_ref.toCompareString())
     if cur_ref.flags & eServiceReference.mustDescent:
         serviceType = "Bouquet"
     else:
         serviceType = "Service"
     if protection:
         if config.ParentalControl.type.value == "blacklist":
             if parentalControl.blacklist.has_key(sref):
                 if "SERVICE" in parentalControl.blacklist.has_key(sref):
                     protectionText = _(
                         "Service %s is locked.") % self.getName(cur_ref)
                 elif "BOUQUET" in parentalControl.blacklist.has_key(sref):
                     protectionText = _(
                         "Bouquet %s is locked.") % self.getName(cur_ref)
                 else:
                     protectionText = _("%s %s is locked.") % (
                         serviceType, self.getName(cur_ref))
         else:
             if hasattr(ParentalControl, "whitelist"
                        ) and parentalControl.whitelist.has_key(sref):
                 if "SERVICE" in parentalControl.whitelist.has_key(sref):
                     protectionText = _(
                         "Service %s is unlocked.") % self.getName(cur_ref)
                 elif "BOUQUET" in parentalControl.whitelist.has_key(sref):
                     protectionText = _(
                         "Bouquet %s is unlocked.") % self.getName(cur_ref)
     return (True, protectionText)
コード例 #22
0
ファイル: base.py プロジェクト: herpoi/e2openplugin-OpenWebif
	def prepareMainTemplate(self):
		# here will be generated the dictionary for the main template
		ret = getCollapsedMenus()
		ret['remotegrabscreenshot'] = getRemoteGrabScreenshot()['remotegrabscreenshot']
		ret['configsections'] = getConfigsSections()['sections']
		ret['zapstream'] = getZapStream()['zapstream']
		ret['box'] = "dmm"
		if fileExists("/proc/stb/info/model"):
			ret['box'] = open("/proc/stb/info/model").read().strip().lower()
		elif fileExists("/proc/stb/info/model"):
			ret['box'] = open("/proc/stb/info/model").read().strip().lower()
			
		if ret["box"] in ("nbox", "esi88", "adb2850", "adb2849", "dsi87"):
			ret["remote"] = "nbox"
		else:
			ret["remote"] = "dmm"
		extras = []
		extras.append({ 'key': 'ajax/settings','description': _("Settings")})
		if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/LCD4linux/WebSite.pyo")):
			lcd4linux_key = "lcd4linux/config"
			if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/WebInterface/plugin.pyo")):
				from Components.config import config
				from Components.Network import iNetwork
				ifaces = iNetwork.getConfiguredAdapters()
				if len(ifaces):
					ip_list = iNetwork.getAdapterAttribute(ifaces[0], "ip") # use only the first configured interface
					ip = "%d.%d.%d.%d" % (ip_list[0], ip_list[1], ip_list[2], ip_list[3])
				try:
					lcd4linux_port = "http://" + ip + ":" + str(config.plugins.Webinterface.http.port.value) + "/"
					lcd4linux_key = lcd4linux_port + 'lcd4linux/config'
				except KeyError:
					lcd4linux_key = None
			if lcd4linux_key:
				extras.append({ 'key': lcd4linux_key, 'description': _("LCD4Linux Setup")})

# TODO AutoTimer,Epgrefresh,BouquetEditor as Webinterface
		
#		try:
#			from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer
#			extras.append({ 'key': 'ajax/xxx','description': 'AutoTimer'})
#		except ImportError:
		
#		try:
#			from Plugins.Extensions.WebBouquetEditor.WebComponents.Sources.BouquetEditor import BouquetEditor
#			extras.append({ 'key': 'ajax/xxx','description': 'BouquetEditor'})
#		except ImportError:
		
#		try:
#			from Plugins.Extensions.EPGRefresh.EPGRefresh import epgrefresh
#			extras.append({ 'key': 'ajax/xxx','description': 'EPGRefresh'})
#		except ImportError:

		ret['extras'] = extras

		return ret
コード例 #23
0
	def renameService(self, param):
		sRef = None
		if "sRef" in param:
			if param["sRef"] is not None:
				sRef =param["sRef"]
		if sRef is None:
			return (False, _("No service given!"))
		sName = None
		if "newName" in param:
			if param["newName"] is not None:
				sName =param["newName"]
		if sName is None:
			return (False, _("No new servicename given!"))
		sBouquetRef = None
		if "sBouquetRef" in param:
			if param["sBouquetRef"] is not None:
				sBouquetRef =param["sBouquetRef"]
		cur_ref = eServiceReference(sRef) 
		if cur_ref.flags & eServiceReference.mustDescent:
			# bouquets or alternatives can be renamed with setListName directly
			mutableBouquetList = self.getMutableList(cur_ref)
			if mutableBouquetList:
					mutableBouquetList.setListName(sName)
					mutableBouquetList.flushChanges()
					if sBouquetRef: # BouquetRef is given when renaming alternatives
						self.setRoot(sBouquetRef)
					else:
						mode = MODE_TV # mode is given when renaming bouquet
						if "mode" in param:
							if param["mode"] is not None:
								mode = int(param["mode"])
						if mode == MODE_TV:
							bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
						else:
							bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
						self.setRoot(bouquet_rootstr)
					return (True, _("Bouquet renamed successfully."))
		else: # service
			# services can not be renamed directly, so delete the current and add it again with new servicename
			sRefBefore = None
			if "sRefBefore" in param:
				if param["sRefBefore"] is not None:
					sRefBefore =param["sRefBefore"]
			new_param = {}
			new_param["sBouquetRef"] = sBouquetRef
			new_param["sRef"] = sRef
			new_param["Name"] = sName
			new_param["sRefBefore"] = sRefBefore
			returnValue = self.removeService(new_param)
			if returnValue[0]:
				returnValue = self.addServiceToBouquet(new_param)
				if returnValue[0]:
					return (True, _("Service renamed successfully."))
		return (False, _("Service can not be renamed."))
コード例 #24
0
 def backupFiles(self, param):
     filename = param
     if not filename:
         filename = self.BACKUP_FILENAME
     invalidCharacters = re_compile(r'[^A-Za-z0-9_. ]+|^\.|\.$|^ | $|^$')
     tarFilename = "%s.tar" % invalidCharacters.sub('_', filename)
     backupFilename = path.join(self.BACKUP_PATH, tarFilename)
     if path.exists(backupFilename):
         remove(backupFilename)
     checkfile = path.join(self.BACKUP_PATH, '.webouquetedit')
     f = open(checkfile, 'w')
     if f:
         files = []
         f.write('created with WebBouquetEditor')
         f.close()
         files.append(checkfile)
         files.append("/etc/enigma2/bouquets.tv")
         files.append("/etc/enigma2/bouquets.radio")
         #files.append("/etc/enigma2/userbouquet.favourites.tv")
         #files.append("/etc/enigma2/userbouquet.favourites.radio")
         files.append("/etc/enigma2/lamedb")
         for xml in ("/etc/tuxbox/cables.xml",
                     "/etc/tuxbox/terrestrial.xml",
                     "/etc/tuxbox/satellites.xml", "/etc/tuxbox/atsc.xml",
                     "/etc/enigma2/lamedb5"):
             if path.exists(xml):
                 files.append(xml)
         if config.ParentalControl.configured.value:
             if config.ParentalControl.type.value == "blacklist":
                 files.append("/etc/enigma2/blacklist")
             else:
                 files.append("/etc/enigma2/whitelist")
         files += self.getPhysicalFilenamesFromServicereference(
             eServiceReference(
                 '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
             ))
         files += self.getPhysicalFilenamesFromServicereference(
             eServiceReference(
                 '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
             ))
         tarFiles = ""
         for arg in files:
             if not path.exists(arg):
                 return (
                     False,
                     _("Error while preparing backup file, %s does not exists."
                       ) % arg)
             tarFiles += "%s " % arg
         lines = popen("tar cvf %s %s" %
                       (backupFilename, tarFiles)).readlines()
         remove(checkfile)
         return (True, tarFilename)
     else:
         return (False, _("Error while preparing backup file."))
コード例 #25
0
 def renameService(self, param):
     sRef = None
     if "sRef" in param:
         if param["sRef"] is not None:
             sRef = param["sRef"]
     if sRef is None:
         return (False, _("No service given!"))
     sName = None
     if "newName" in param:
         if param["newName"] is not None:
             sName = param["newName"]
     if sName is None:
         return (False, _("No new servicename given!"))
     sBouquetRef = None
     if "sBouquetRef" in param:
         if param["sBouquetRef"] is not None:
             sBouquetRef = param["sBouquetRef"]
     cur_ref = eServiceReference(sRef)
     if cur_ref.flags & eServiceReference.mustDescent:
         # bouquets or alternatives can be renamed with setListName directly
         mutableBouquetList = self.getMutableList(cur_ref)
         if mutableBouquetList:
             mutableBouquetList.setListName(sName)
             mutableBouquetList.flushChanges()
             if sBouquetRef:  # BouquetRef is given when renaming alternatives
                 self.setRoot(sBouquetRef)
             else:
                 mode = MODE_TV  # mode is given when renaming bouquet
                 if "mode" in param:
                     if param["mode"] is not None:
                         mode = int(param["mode"])
                 if mode == MODE_TV:
                     bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
                 else:
                     bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
                 self.setRoot(bouquet_rootstr)
             return (True, _("Bouquet renamed successfully."))
     else:  # service
         # services can not be renamed directly, so delete the current and add it again with new servicename
         sRefBefore = None
         if "sRefBefore" in param:
             if param["sRefBefore"] is not None:
                 sRefBefore = param["sRefBefore"]
         new_param = {}
         new_param["sBouquetRef"] = sBouquetRef
         new_param["sRef"] = sRef
         new_param["Name"] = sName
         new_param["sRefBefore"] = sRefBefore
         returnValue = self.removeService(new_param)
         if returnValue[0]:
             returnValue = self.addServiceToBouquet(new_param)
             if returnValue[0]:
                 return (True, _("Service renamed successfully."))
     return (False, _("Service can not be renamed."))
コード例 #26
0
def getJsonFromConfig(cnf):
	if cnf.__class__.__name__ == "ConfigSelection" or cnf.__class__.__name__ == "ConfigSelectionNumber":
		if type(cnf.choices.choices) == dict:
			choices = []
			for choice in cnf.choices.choices:
				choices.append((choice, _(cnf.choices.choices[choice])))
		elif type(cnf.choices.choices[0]) == tuple:
			choices = []
			for choice_tuple in cnf.choices.choices:
				choices.append((choice_tuple[0], _(choice_tuple[1])))
		else:
			choices = []
			for choice in cnf.choices.choices:
				choices.append((choice, _(choice)))
				
		return {
			"result": True,
			"type": "select",
			"choices": choices,
			"current": cnf.value
		}
	elif cnf.__class__.__name__ == "ConfigBoolean" or cnf.__class__.__name__ == "ConfigEnableDisable" or cnf.__class__.__name__ == "ConfigYesNo":
		return {
			"result": True,
			"type": "checkbox",
			"current": cnf.value
		}
	elif cnf.__class__.__name__ == "ConfigSet":
		return {
			"result": True,
			"type": "multicheckbox",
			"choices": cnf.choices.choices,
			"current": cnf.value
		}

	elif cnf.__class__.__name__ == "ConfigNumber":
		return {
			"result": True,
			"type": "number",
			"current": cnf.value
		}
	elif cnf.__class__.__name__ == "ConfigInteger":
		return {
			"result": True,
			"type": "number",
			"current": cnf.value,
			"limits": (cnf.limits[0][0], cnf.limits[0][1])
		}

	print "[OpenWebif] Unknown class ", cnf.__class__.__name__
	return {
		"result": False,
		"type": "unknown"
	}
コード例 #27
0
ファイル: message.py プロジェクト: AREADELTASAT/OpenWebif
def getMessageAnswer():
    global lastreply
    reply = lastreply

    if reply is None:
        return {"result": False, "message": _('No answer in time')}

    return {
        "result": True,
        "message": _('Answer is YES!') if reply else _('Answer is NO!')
    }
コード例 #28
0
def toggleTimerStatus(session, serviceref, begin, end):
    serviceref = unquote(serviceref)
    serviceref_str = ':'.join(str(serviceref).split(':')[:11])
    rt = session.nav.RecordTimer
    for timer in rt.timer_list + rt.processed_timers:
        needed_ref = ':'.join(
            timer.service_ref.ref.toString().split(':')[:11]) == serviceref_str
        if needed_ref and int(timer.begin) == begin and int(timer.end) == end:
            if timer.disabled:
                timer.enable()
                effect = "enabled"
                sanity = TimerSanityCheck(rt.timer_list, timer)
                if not sanity.check():
                    timer.disable()
                    return {
                        "result":
                        False,
                        "message":
                        _("Timer '%s' not enabled while Conflict") %
                        (timer.name)
                    }
                elif sanity.doubleCheck():
                    timer.disable()
                    return {
                        "result": False,
                        "message":
                        _("Timer '%s' already exists!") % (timer.name)
                    }
            else:
                if timer.isRunning():
                    return {
                        "result":
                        False,
                        "message":
                        _("The timer '%s' now recorded! Not disabled!") %
                        (timer.name)
                    }
                else:
                    timer.disable()
                    effect = "disabled"
            rt.timeChanged(timer)
            return {
                "result":
                True,
                "message":
                _("The timer '%s' has been %s successfully") %
                (timer.name, effect),
                "disabled":
                timer.disabled
            }

    return {"result": False, "message": _("No matching Timer found")}
コード例 #29
0
    def removeBouquet(self, param):
        print "[WebComponents.BouquetEditor] removeBouquet with param = ", param
        refstr = sref = param["sBouquetRef"]
        if refstr is None:
            return (False, _("No bouquet name given!"))
        mode = MODE_TV  # init
        if "mode" in param:
            if param["mode"] is not None:
                mode = int(param["mode"])

        if param.has_key("BouquetRefRoot"):
            bouquet_root = param[
                "BouquetRefRoot"]  # only when removing alternative
        else:
            bouquet_root = None
        pos = refstr.find('FROM BOUQUET "')
        filename = None
        if pos != -1:
            refstr = refstr[pos + 14:]
            pos = refstr.find('"')
            if pos != -1:
                filename = '/etc/enigma2/' + refstr[:
                                                    pos]  # FIXMEEE !!! HARDCODED /etc/enigma2
        ref = eServiceReference(sref)
        bouquetName = self.getName(ref)
        if not bouquetName:
            bouquetName = filename
        if bouquet_root:
            mutableList = self.getMutableList(eServiceReference(bouquet_root))
        else:
            mutableList = self.getMutableBouquetList(mode)

        if ref.valid() and mutableList is not None:
            if not mutableList.removeService(ref):
                mutableList.flushChanges()
                self.setRoot(self.bouquet_rootstr)
            else:
                return (False, _("Bouquet %s removed failed.") % filename)
        else:
            return (
                False,
                _("Bouquet %s removed failed, sevicerefence or mutable list is not valid."
                  ) % filename)
        try:
            if filename is not None:
                if not path.exists(filename + '.del'):
                    remove(filename)
                return (True, _("Bouquet %s deleted.") % bouquetName)
        except OSError:
            return (False, _("Error: Bouquet %s could not deleted, OSError.") %
                    filename)
コード例 #30
0
def getSleepTimer(session):
	if hasattr(session.nav, "SleepTimer"):
		try:
			return {
				"enabled": session.nav.SleepTimer.isActive(),
				"minutes": session.nav.SleepTimer.getCurrentSleepTime(),
				"action": config.SleepTimer.action.value,
				"message": _("Sleeptimer is enabled") if session.nav.SleepTimer.isActive() else _("Sleeptimer is disabled")
			}
		except Exception, e:
			return {
				"result": False,
				"message": _("SleepTimer error")
			}
コード例 #31
0
def getMessageAnswer():
	global lastreply
	reply = lastreply

	if reply is None:
		return {
			"result": False,
			"message": _('No answer in time')
		}

	return {
		"result": True,
		"message": _('Answer is YES!') if reply else _('Answer is NO!')
	}
コード例 #32
0
ファイル: timers.py プロジェクト: HDMU/e2openplugin-OpenWebif
def getSleepTimer(session):
	if hasattr(session.nav, "SleepTimer"):
		try:
			return {
				"enabled": session.nav.SleepTimer.isActive(),
				"minutes": session.nav.SleepTimer.getCurrentSleepTime(),
				"action": config.SleepTimer.action.value,
				"message": _("Sleeptimer is enabled") if session.nav.SleepTimer.isActive() else _("Sleeptimer is disabled")
			}
		except Exception, e:
			return {
				"result": False,
				"message": _("SleepTimer error")
			}
コード例 #33
0
ファイル: base.py プロジェクト: Leatherface75/enigma2pc
	def prepareMainTemplate(self):
		# here will be generated the dictionary for the main template
		ret = getCollapsedMenus()
		ret['remotegrabscreenshot'] = getRemoteGrabScreenshot()['remotegrabscreenshot']
		ret['configsections'] = getConfigsSections()['sections']
		ret['zapstream'] = getZapStream()['zapstream']
		ret['showname'] = getShowName()['showname']
		ret['customname'] = getCustomName()['customname']
		ret['boxname'] = getBoxName()['boxname']
		if not ret['boxname'] or not ret['customname']:
			ret['boxname'] = getInfo()['brand']+" "+getInfo()['model']
		ret['box'] = getBoxType()
		ret["remote"] = remote

		extras = []
		extras.append({ 'key': 'ajax/settings','description': _("Settings")})
		if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/LCD4linux/WebSite.pyo")):
			lcd4linux_key = "lcd4linux/config"
			if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/WebInterface/plugin.pyo")):
				from Components.config import config
				from Components.Network import iNetwork
				ifaces = iNetwork.getConfiguredAdapters()
				if len(ifaces):
					ip_list = iNetwork.getAdapterAttribute(ifaces[0], "ip") # use only the first configured interface
					ip = "%d.%d.%d.%d" % (ip_list[0], ip_list[1], ip_list[2], ip_list[3])
				try:
					lcd4linux_port = "http://" + ip + ":" + str(config.plugins.Webinterface.http.port.value) + "/"
					lcd4linux_key = lcd4linux_port + 'lcd4linux/config'
				except KeyError:
					lcd4linux_key = None
			if lcd4linux_key:
				extras.append({ 'key': lcd4linux_key, 'description': _("LCD4Linux Setup")})
		
		try:
			from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer
			extras.append({ 'key': 'ajax/at','description': _('AutoTimer')})
		except ImportError:
			pass
		if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/bqe.tmpl")):
			extras.append({ 'key': 'ajax/bqe','description': _('BouquetEditor')})
		
		try:
			from Plugins.Extensions.EPGRefresh.EPGRefresh import epgrefresh
			extras.append({ 'key': 'ajax/epgr','description': _('EPGRefresh')})
		except ImportError:
			pass
		ret['extras'] = extras

		return ret
コード例 #34
0
 def restoreFiles(self, param):
     tarFilename = param
     backupFilename = tarFilename  #path.join(self.BACKUP_PATH, tarFilename)
     if path.exists(backupFilename):
         check_tar = False
         lines = popen('tar -tf %s' % backupFilename).readlines()
         for line in lines:
             pos = line.find('tmp/.webouquetedit')
             if pos != -1:
                 check_tar = True
                 break
         if check_tar:
             eDVBDB.getInstance().removeServices()
             files = []
             files += self.getPhysicalFilenamesFromServicereference(
                 eServiceReference(
                     '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
                 ))
             files += self.getPhysicalFilenamesFromServicereference(
                 eServiceReference(
                     '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
                 ))
             for bouquetfiles in files:
                 if path.exists(bouquetfiles):
                     remove(bouquetfiles)
             lines = popen('tar xvf %s -C / --exclude tmp/.webouquetedit' %
                           backupFilename).readlines()
             nimmanager.readTransponders()
             eDVBDB.getInstance().reloadServicelist()
             eDVBDB.getInstance().reloadBouquets()
             infoBarInstance = InfoBar.instance
             if infoBarInstance is not None:
                 servicelist = infoBarInstance.servicelist
                 root = servicelist.getRoot()
                 currentref = servicelist.getCurrentSelection()
                 servicelist.setRoot(root)
                 servicelist.setCurrentSelection(currentref)
             remove(backupFilename)
             return (True, _("Bouquet-settings were restored successfully"))
         else:
             return (
                 False,
                 _("Error, %s was not created with WebBouquetEditor...") %
                 backupFilename)
     else:
         return (
             False,
             _("Error, %s does not exists, restore is not possible...") %
             backupFilename)
コード例 #35
0
	def prepareMainTemplate(self):
		# here will be generated the dictionary for the main template
		ret = getCollapsedMenus()
		ret['remotegrabscreenshot'] = getRemoteGrabScreenshot()['remotegrabscreenshot']
		ret['configsections'] = getConfigsSections()['sections']
		ret['zapstream'] = getZapStream()['zapstream']
		ret['showname'] = getShowName()['showname']
		ret['customname'] = getCustomName()['customname']
		ret['boxname'] = getBoxName()['boxname']
		if not ret['boxname'] or not ret['customname']:
			ret['boxname'] = getInfo()['brand']+" "+getInfo()['model']
		ret['box'] = getBoxType()
		ret["remote"] = rc_model.getRcFolder()+remotesuffix

		extras = []
		extras.append({ 'key': 'ajax/settings','description': _("Settings")})
		if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/LCD4linux/WebSite.pyo")):
			lcd4linux_key = "lcd4linux/config"
			if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/WebInterface/plugin.pyo")):
				from Components.config import config
				from Components.Network import iNetwork
				ifaces = iNetwork.getConfiguredAdapters()
				if len(ifaces):
					ip_list = iNetwork.getAdapterAttribute(ifaces[0], "ip") # use only the first configured interface
					ip = "%d.%d.%d.%d" % (ip_list[0], ip_list[1], ip_list[2], ip_list[3])
				try:
					lcd4linux_port = "http://" + ip + ":" + str(config.plugins.Webinterface.http.port.value) + "/"
					lcd4linux_key = lcd4linux_port + 'lcd4linux/config'
				except KeyError:
					lcd4linux_key = None
			if lcd4linux_key:
				extras.append({ 'key': lcd4linux_key, 'description': _("LCD4Linux Setup")})
		
		try:
			from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer
			extras.append({ 'key': 'ajax/at','description': _('AutoTimer')})
		except ImportError:
			pass
		if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/bqe.tmpl")):
			extras.append({ 'key': 'ajax/bqe','description': _('BouquetEditor')})
		
		try:
			from Plugins.Extensions.EPGRefresh.EPGRefresh import epgrefresh
			extras.append({ 'key': 'ajax/epgr','description': _('EPGRefresh')})
		except ImportError:
			pass
		ret['extras'] = extras

		return ret
コード例 #36
0
ファイル: info.py プロジェクト: GeirJ/e2openplugin-OpenWebif
def getIPv4Method(iface):
	# iNetwork.getAdapterAttribute is crap and not portable
	ipv4method = _("static")
	if fileExists('/etc/network/interfaces'):
		ifaces = '/etc/network/interfaces'
		for line in file(ifaces).readlines():
			if not line.startswith('#'):
				if line.startswith('iface') and "inet " in line and iface in line:
					if "static" in line:
						ipv4method = _("static")
					if "dhcp" in line:
						ipv4method = _("DHCP")
					if "manual" in line:
						ipv4method = _("manual/disabled")
	return ipv4method
コード例 #37
0
ファイル: web.py プロジェクト: oscarfl/e2openplugin-OpenWebif
    def testMandatoryArguments(self, request, keys):
        for key in keys:
            if key not in request.args.keys():
                return {
                    "result": False,
                    "message": _("Missing mandatory parameter '%s'") % key
                }

            if len(request.args[key][0]) == 0:
                return {
                    "result": False,
                    "message": _("The parameter '%s' can't be empty") % key
                }

        return None
コード例 #38
0
	def toggleLock(self, param):
		if not config.ParentalControl.configured.value:
			return (False, _("Parent Control is not activated."))
		sRef = None
		if "sRef" in param:
			if param["sRef"] is not None:
				sRef =param["sRef"]
		if sRef is None:
			return (False, _("No service given!"))
		if "setuppinactive" in config.ParentalControl.dict().keys() and config.ParentalControl.setuppinactive.value:
			password = None
			if "password" in param:
				if param["password"] is not None:
					password =param["password"]
			if password is None:
				return (False, _("No Parent Control Setup Pin given!"))
			else:
				if password.isdigit():
					if int(password) != config.ParentalControl.setuppin.value:
						return (False, _("Parent Control Setup Pin is wrong!"))
				else:
					return (False, _("Parent Control Setup Pin is wrong!"))
		cur_ref = eServiceReference(sRef)
		protection = parentalControl.getProtectionLevel(cur_ref.toCompareString())
		if protection:
			parentalControl.unProtectService(cur_ref.toCompareString())
		else:
			parentalControl.protectService(cur_ref.toCompareString())
		if cur_ref.flags & eServiceReference.mustDescent:
			serviceType = "Bouquet"
		else:
			serviceType = "Service"
		if protection:
			if config.ParentalControl.type.value == "blacklist":
				if parentalControl.blacklist.has_key(sref):
					if "SERVICE" in parentalControl.blacklist.has_key(sref):
						protectionText = _("Service %s is locked.") % self.getName(cur_ref)
					elif "BOUQUET" in parentalControl.blacklist.has_key(sref):
						protectionText = _("Bouquet %s is locked.") % self.getName(cur_ref)
					else:
						protectionText = _("%s %s is locked.") % (serviceType, self.getName(cur_ref))
			else:
				if hasattr(ParentalControl, "whitelist") and parentalControl.whitelist.has_key(sref):
					if "SERVICE" in parentalControl.whitelist.has_key(sref):
						protectionText = _("Service %s is unlocked.") % self.getName(cur_ref)
					elif "BOUQUET" in parentalControl.whitelist.has_key(sref):
						protectionText = _("Bouquet %s is unlocked.") % self.getName(cur_ref)
		return (True, protectionText)
コード例 #39
0
ファイル: timers.py プロジェクト: HDMU/e2openplugin-OpenWebif
def getVPSChannels(session):
	vpsfile="/etc/enigma2/vps.xml"
	from Tools.Directories import fileExists
	if fileExists(vpsfile):
		try:
			import xml.etree.cElementTree
			vpsfile = file(vpsfile, 'r')
			vpsdom = xml.etree.cElementTree.parse(vpsfile)
			vpsfile.close()
			xmldata = vpsdom.getroot()
			channels = []
			for ch in xmldata.findall("channel"):
				channels.append({
					"serviceref": ch.attrib["serviceref"],
					"has_pdc": ch.attrib["has_pdc"],
					"last_check": ch.attrib["last_check"],
					"default_vps": ch.attrib["default_vps"]
				})
			return {
				"result": True,
				"channels": channels
			}
		except Exception, e:
			return {
				"result": False,
				"message": _("Error parsing vps.xml")
			}
コード例 #40
0
def getIPv4Method(iface):
    # iNetwork.getAdapterAttribute is crap and not portable
    ipv4method = _("static")
    if fileExists('/etc/network/interfaces'):
        ifaces = '/etc/network/interfaces'
        for line in file(ifaces).readlines():
            if not line.startswith('#'):
                if line.startswith(
                        'iface') and "inet " in line and iface in line:
                    if "static" in line:
                        ipv4method = _("static")
                    if "dhcp" in line:
                        ipv4method = _("DHCP")
                    if "manual" in line:
                        ipv4method = _("manual/disabled")
    return ipv4method
コード例 #41
0
def removeTimer(session, serviceref, begin, end):
    serviceref_str = ':'.join(str(serviceref).split(':')[:11])
    rt = session.nav.RecordTimer
    for timer in rt.timer_list + rt.processed_timers:
        needed_ref = ':'.join(
            timer.service_ref.ref.toString().split(':')[:11]) == serviceref_str
        if needed_ref and int(timer.begin) == begin and int(timer.end) == end:
            rt.removeEntry(timer)
            return {
                "result":
                True,
                "message":
                _("The timer '%s' has been deleted successfully") % timer.name
            }

    return {"result": False, "message": _("No matching Timer found")}
コード例 #42
0
 def handleCommand(self, cmd):
     print "[WebComponents.BouquetEditor] handleCommand with cmd = ", cmd
     if self.func is self.ADD_BOUQUET:
         self.result = self.addToBouquet(cmd)
     elif self.func is self.MOVE_BOUQUET:
         self.result = self.moveBouquet(cmd)
     elif self.func is self.MOVE_SERVICE:
         self.result = self.moveService(cmd)
     elif self.func is self.REMOVE_BOUQUET:
         self.result = self.removeBouquet(cmd)
     elif self.func is self.REMOVE_SERVICE:
         self.result = self.removeService(cmd)
     elif self.func is self.ADD_SERVICE_TO_BOUQUET:
         self.result = self.addServiceToBouquet(cmd)
     elif self.func is self.ADD_PROVIDER_TO_BOUQUETLIST:
         self.result = self.addProviderToBouquetlist(cmd)
     elif self.func is self.ADD_SERVICE_TO_ALTERNATIVE:
         self.result = self.addServiceToAlternative(cmd)
     elif self.func is self.REMOVE_ALTERNATIVE_SERVICES:
         self.result = self.removeAlternativeServices(cmd)
     elif self.func is self.TOGGLE_LOCK:
         self.result = self.toggleLock(cmd)
     elif self.func is self.BACKUP:
         self.result = self.backupFiles(cmd)
     elif self.func is self.RESTORE:
         self.result = self.restoreFiles(cmd)
     elif self.func is self.RENAME_SERVICE:
         self.result = self.renameService(cmd)
     elif self.func is self.ADD_MARKER_TO_BOUQUET:
         self.result = self.addMarkerToBouquet(cmd)
     else:
         self.result = (False, _("one two three four unknown command"))
コード例 #43
0
def getVPSChannels(session):
	vpsfile="/etc/enigma2/vps.xml"
	from Tools.Directories import fileExists
	if fileExists(vpsfile):
		try:
			import xml.etree.cElementTree
			vpsfile = file(vpsfile, 'r')
			vpsdom = xml.etree.cElementTree.parse(vpsfile)
			vpsfile.close()
			xmldata = vpsdom.getroot()
			channels = []
			for ch in xmldata.findall("channel"):
				channels.append({
					"serviceref": ch.attrib["serviceref"],
					"has_pdc": ch.attrib["has_pdc"],
					"last_check": ch.attrib["last_check"],
					"default_vps": ch.attrib["default_vps"]
				})
			return {
				"result": True,
				"channels": channels
			}
		except Exception, e:
			return {
				"result": False,
				"message": _("Error parsing vps.xml")
			}
コード例 #44
0
def addTimerByEventId(session, eventid, serviceref, justplay, dirname, tags, vpsinfo, always_zap):
	serviceref = unquote(serviceref)
	event = eEPGCache.getInstance().lookupEventId(eServiceReference(serviceref), eventid)
	if event is None:
		return {
			"result": False,
			"message": _("EventId not found")
		}

	(begin, end, name, description, eit) = parseEvent(event)
	return addTimer(
		session,
		serviceref,
		begin,
		end,
		name,
		description,
		False,
		justplay,
		AFTEREVENT.AUTO,
		dirname,
		tags,
		False,
		vpsinfo,
		None,
		eit,
		always_zap
	)
コード例 #45
0
	def handleCommand(self, cmd):
		print "[WebComponents.BouquetEditor] handleCommand with cmd = ", cmd
		if self.func is self.ADD_BOUQUET:
			self.result = self.addToBouquet(cmd)
		elif self.func is self.MOVE_BOUQUET:
			self.result = self.moveBouquet(cmd)
		elif self.func is self.MOVE_SERVICE:
			self.result = self.moveService(cmd)
		elif self.func is self.REMOVE_BOUQUET:
			self.result = self.removeBouquet(cmd)
		elif self.func is self.REMOVE_SERVICE:
			self.result = self.removeService(cmd)
		elif self.func is self.ADD_SERVICE_TO_BOUQUET:
			self.result = self.addServiceToBouquet(cmd)
		elif self.func is self.ADD_PROVIDER_TO_BOUQUETLIST:
			self.result = self.addProviderToBouquetlist(cmd)
		elif self.func is self.ADD_SERVICE_TO_ALTERNATIVE:
			self.result = self.addServiceToAlternative(cmd)
		elif self.func is self.REMOVE_ALTERNATIVE_SERVICES:
			self.result = self.removeAlternativeServices(cmd)
		elif self.func is self.TOGGLE_LOCK:
			self.result = self.toggleLock(cmd)
		elif self.func is self.BACKUP:
			self.result = self.backupFiles(cmd)
		elif self.func is self.RESTORE:
			self.result = self.restoreFiles(cmd)
		elif self.func is self.RENAME_SERVICE:
			self.result = self.renameService(cmd)
		elif self.func is self.ADD_MARKER_TO_BOUQUET:
			self.result = self.addMarkerToBouquet(cmd)
		else:
			self.result = ( False, _("one two three four unknown command") )
コード例 #46
0
ファイル: timers.py プロジェクト: HDMU/e2openplugin-OpenWebif
def addTimerByEventId(session, eventid, serviceref, justplay, dirname, tags, vpsinfo, always_zap):
	event = eEPGCache.getInstance().lookupEventId(eServiceReference(serviceref), eventid)
	if event is None:
		return {
			"result": False,
			"message": _("EventId not found")
		}

	(begin, end, name, description, eit) = parseEvent(event)
	return addTimer(
		session,
		serviceref,
		begin,
		end,
		name,
		description,
		False,
		justplay,
		AFTEREVENT.AUTO,
		dirname,
		tags,
		False,
		vpsinfo,
		None,
		eit,
		always_zap
	)
コード例 #47
0
ファイル: timers.py プロジェクト: HDMU/e2openplugin-OpenWebif
def removeTimer(session, serviceref, begin, end):
	serviceref_str = ':'.join(str(serviceref).split(':')[:11])
	rt = session.nav.RecordTimer
	for timer in rt.timer_list + rt.processed_timers:
		needed_ref = ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == serviceref_str
		if needed_ref and int(timer.begin) == begin and int(timer.end) == end:
			rt.removeEntry(timer)
			return {
				"result": True,
				"message": _("The timer '%s' has been deleted successfully") % timer.name
			}

	return {
		"result": False,
		"message": _("No matching Timer found")
	}
コード例 #48
0
ファイル: info.py プロジェクト: GeirJ/e2openplugin-OpenWebif
def getNICChipSet(iface):
	nic = _("unknown")
	try:
		nic = os.path.realpath('/sys/class/net/' + iface + '/device/driver').split('/')[-1]
		nic = str(nic)
	except:
		pass
	return nic
コード例 #49
0
ファイル: info.py プロジェクト: Dima73/e2openplugin-OpenWebif
def getNICChipSet(iface):
	nic = _("unknown")
	try:
		nic = os.popen('ethtool -i ' + iface + ' | grep driver: | awk \'{ print $2 }\'').read().strip()
	except:
		pass
	nic = str(nic)
	return nic
コード例 #50
0
 def backupFiles(self, param):
     filename = param
     if not filename:
         filename = self.BACKUP_FILENAME
     invalidCharacters = re_compile(r"[^A-Za-z0-9_. ]+|^\.|\.$|^ | $|^$")
     tarFilename = "%s.tar" % invalidCharacters.sub("_", filename)
     backupFilename = path.join(self.BACKUP_PATH, tarFilename)
     if path.exists(backupFilename):
         remove(backupFilename)
     checkfile = path.join(self.BACKUP_PATH, ".webouquetedit")
     f = open(checkfile, "w")
     if f:
         files = []
         f.write("created with WebBouquetEditor")
         f.close()
         files.append(checkfile)
         files.append("/etc/enigma2/bouquets.tv")
         files.append("/etc/enigma2/bouquets.radio")
         # files.append("/etc/enigma2/userbouquet.favourites.tv")
         # files.append("/etc/enigma2/userbouquet.favourites.radio")
         files.append("/etc/enigma2/lamedb")
         for xml in ("/etc/tuxbox/cables.xml", "/etc/tuxbox/terrestrial.xml", "/etc/tuxbox/satellites.xml"):
             if path.exists(xml):
                 files.append(xml)
         if config.ParentalControl.configured.value:
             if config.ParentalControl.type.value == "blacklist":
                 files.append("/etc/enigma2/blacklist")
             else:
                 files.append("/etc/enigma2/whitelist")
         files += self.getPhysicalFilenamesFromServicereference(
             eServiceReference('1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
         )
         files += self.getPhysicalFilenamesFromServicereference(
             eServiceReference('1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet')
         )
         tarFiles = ""
         for arg in files:
             if not path.exists(arg):
                 return (False, _("Error while preparing backup file, %s does not exists.") % arg)
             tarFiles += "%s " % arg
         lines = popen("tar cvf %s %s" % (backupFilename, tarFiles)).readlines()
         remove(checkfile)
         return (True, tarFilename)
     else:
         return (False, _("Error while preparing backup file."))
コード例 #51
0
def getNICChipSet(iface):
    nic = _("unknown")
    try:
        nic = os.path.realpath('/sys/class/net/' + iface +
                               '/device/driver').split('/')[-1]
        nic = str(nic)
    except:
        pass
    return nic
コード例 #52
0
ファイル: web.py プロジェクト: OpenLD/e2openplugin-OpenWebif
    def P_message(self, request):
        res = self.testMandatoryArguments(request, ["text", "type"])
        if res:
            return res

        try:
            ttype = int(request.args["type"][0])
        except Exception, e:
            return {"result": False, "message": _("type %s is not a number") % request.args["type"][0]}
コード例 #53
0
	def removeBouquet(self, param):
		print "[WebComponents.BouquetEditor] removeBouquet with param = ", param
		refstr = sref = param["sBouquetRef"]
		if refstr is None:
			return (False, _("No bouquet name given!"))
		mode = MODE_TV # init
		if "mode" in param:
			if param["mode"] is not None:
				mode = int(param["mode"])

		if param.has_key("BouquetRefRoot"):
			bouquet_root = param["BouquetRefRoot"] # only when removing alternative
		else:
			bouquet_root = None
		pos = refstr.find('FROM BOUQUET "')
		filename = None
		if pos != -1:
			refstr = refstr[pos+14:]
			pos = refstr.find('"')
			if pos != -1:
				filename = '/etc/enigma2/' + refstr[:pos] # FIXMEEE !!! HARDCODED /etc/enigma2
		ref = eServiceReference(sref)
		bouquetName = self.getName(ref)
		if not bouquetName:
			bouquetName = filename
		if bouquet_root:
			mutableList = self.getMutableList(eServiceReference(bouquet_root))
		else:
			mutableList = self.getMutableBouquetList(mode)
			
		if ref.valid() and mutableList is not None:
			if not mutableList.removeService(ref):
				mutableList.flushChanges()
				self.setRoot(self.bouquet_rootstr)
			else:
				return (False, _("Bouquet %s removed failed.") % filename)
		else:
			return (False, _("Bouquet %s removed failed, sevicerefence or mutable list is not valid.") % filename)
		try:
			if filename is not None:
				remove(filename)
				return (True, _("Bouquet %s deleted.") % bouquetName)
		except OSError:
			return (False, _("Error: Bouquet %s could not deleted, OSError.") % filename)
コード例 #54
0
ファイル: timers.py プロジェクト: HDMU/e2openplugin-OpenWebif
def getPowerTimer(session):
	
	try:
		from PowerTimer import TIMERTYPE ,AFTEREVENT

		timers = []
		timer_list  = session.nav.PowerTimer.timer_list
		processed_timers  = session.nav.PowerTimer.processed_timers

		for timer in timer_list + processed_timers:
			list = []
			for time, code, msg in timer.log_entries:
				list.append({
					"code": str(code),
					"time": str(time),
					"msg": str(msg)
					})
			timers.append({
			"timertype": str(timer.timerType),
			"timertypename": str({
				TIMERTYPE.WAKEUP: "wakeup",
				TIMERTYPE.WAKEUPTOSTANDBY: "wakeuptostandby",
				TIMERTYPE.AUTOSTANDBY: "autostandby",
				TIMERTYPE.AUTODEEPSTANDBY: "autodeepstandby",
				TIMERTYPE.STANDBY: "standby",
				TIMERTYPE.DEEPSTANDBY: "deepstandby",
				TIMERTYPE.REBOOT: "reboot",
				TIMERTYPE.RESTART: "restart"
				}[timer.timerType]),
			"begin": str(int(timer.begin)),
			"end": str(int(timer.end)),
			"repeated": str(int(timer.repeated)),
			"afterevent": str(timer.afterEvent),
			"aftereventname": str({
				AFTEREVENT.NONE: "nothing",
				AFTEREVENT.WAKEUPTOSTANDBY: "wakeuptostandby",
				AFTEREVENT.STANDBY: "standby",
				AFTEREVENT.DEEPSTANDBY: "deepstandby"
				}[timer.afterEvent]),
			"disabled": str(int(timer.disabled)),
			"autosleepinstandbyonly": str(timer.autosleepinstandbyonly),
			"autosleepdelay": str(timer.autosleepdelay),
			"autosleeprepeat": str(timer.autosleeprepeat),
			"logentries" : list
			})

		return {
			"result": True,
			"timers": timers
		}
	except Exception, e:
		print e
		return {
			"result": False,
			"message": _("PowerTimer feature not available")
		}
コード例 #55
0
def getPowerTimer(session):
	
	try:
		from PowerTimer import TIMERTYPE ,AFTEREVENT

		timers = []
		timer_list  = session.nav.PowerTimer.timer_list
		processed_timers  = session.nav.PowerTimer.processed_timers

		for timer in timer_list + processed_timers:
			list = []
			for time, code, msg in timer.log_entries:
				list.append({
					"code": str(code),
					"time": str(time),
					"msg": str(msg)
					})
			timers.append({
			"timertype": str(timer.timerType),
			"timertypename": str({
				TIMERTYPE.WAKEUP: "wakeup",
				TIMERTYPE.WAKEUPTOSTANDBY: "wakeuptostandby",
				TIMERTYPE.AUTOSTANDBY: "autostandby",
				TIMERTYPE.AUTODEEPSTANDBY: "autodeepstandby",
				TIMERTYPE.STANDBY: "standby",
				TIMERTYPE.DEEPSTANDBY: "deepstandby",
				TIMERTYPE.REBOOT: "reboot",
				TIMERTYPE.RESTART: "restart"
				}[timer.timerType]),
			"begin": str(int(timer.begin)),
			"end": str(int(timer.end)),
			"repeated": str(int(timer.repeated)),
			"afterevent": str(timer.afterEvent),
			"aftereventname": str({
				AFTEREVENT.NONE: "nothing",
				AFTEREVENT.WAKEUPTOSTANDBY: "wakeuptostandby",
				AFTEREVENT.STANDBY: "standby",
				AFTEREVENT.DEEPSTANDBY: "deepstandby"
				}[timer.afterEvent]),
			"disabled": str(int(timer.disabled)),
			"autosleepinstandbyonly": str(timer.autosleepinstandbyonly),
			"autosleepdelay": str(timer.autosleepdelay),
			"autosleeprepeat": str(timer.autosleeprepeat),
			"logentries" : list
			})

		return {
			"result": True,
			"timers": timers
		}
	except Exception, e:
		print e
		return {
			"result": False,
			"message": _("PowerTimer feature not available")
		}
コード例 #56
0
def getLinkSpeed(iface):
    try:
        with open('/sys/class/net/' + iface + '/speed', 'r') as f:
            speed = f.read().strip()
    except:
        speed = _("unknown")
    speed = str(speed) + " MBit/s"
    speed = speed.replace("10000 MBit/s", "10 GBit/s")
    speed = speed.replace("1000 MBit/s", "1 GBit/s")
    return speed
コード例 #57
0
ファイル: info.py プロジェクト: GeirJ/e2openplugin-OpenWebif
def getLinkSpeed(iface):
	try:
		with open('/sys/class/net/' + iface + '/speed','r') as f:
			speed = f.read().strip()
	except:
		speed = _("unknown")
	speed = str(speed) + " MBit/s"
	speed = speed.replace("10000 MBit/s","10 GBit/s")
	speed = speed.replace("1000 MBit/s","1 GBit/s")
	return speed