def prepareMainTemplate(self, request): # here will be generated the dictionary for the main template ret = getCollapsedMenus() ret['configsections'] = getConfigsSections()['sections'] 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 if hasattr(eEPGCache, 'FULL_DESCRIPTION_SEARCH'): ret['epgsearchcaps'] = True else: ret['epgsearchcaps'] = False extras = [{'key': 'ajax/settings', 'description': _("Settings")}] ip = getIP() if ip != None: if fileExists( resolveFilename( SCOPE_PLUGINS, "Extensions/LCD4linux/WebSite.pyo")) or fileExists( resolveFilename( SCOPE_PLUGINS, "Extensions/LCD4linux/WebSite.py")): lcd4linux_key = "lcd4linux/config" if fileExists( resolveFilename(SCOPE_PLUGINS, "Extensions/WebInterface/plugin.pyo") ) or fileExists( resolveFilename(SCOPE_PLUGINS, "Extensions/WebInterface/plugin.py")): try: lcd4linux_port = "http://" + ip + ":" + str( config.plugins.Webinterface.http.port.value) + "/" lcd4linux_key = lcd4linux_port + 'lcd4linux/config' except: # nosec # noqa: E722 lcd4linux_key = None if lcd4linux_key: extras.append({ 'key': lcd4linux_key, 'description': _("LCD4Linux Setup"), 'nw': '1' }) oscamwebif, port, oscamconf, variant = self.oscamconfPath() # Assume http until we know better ... proto = "http" # config file exists if oscamwebif and oscamconf is not None: # oscam defaults to NOT to start the web interface unless a section for it exists, so reset port to None until we find one port = None data = open(oscamconf, "r").readlines() for i in data: if "httpport" in i.lower(): port = i.split("=")[1].strip() if port[0] == '+': proto = "https" port = port[1:] if oscamwebif and port is not None: url = "%s://%s:%s" % (proto, request.getRequestHostname(), port) if variant == "oscam": extras.append({ 'key': url, 'description': _("OSCam Webinterface"), 'nw': '1' }) elif variant == "ncam": extras.append({ 'key': url, 'description': _("NCam Webinterface"), 'nw': '1' }) url1 = "http://%s:8000" % request.getRequestHostname() extras.append({'key': url1, 'description': _("FileLoad"), 'nw': '1'}) if HASAUTOTIMER: extras.append({'key': 'ajax/at', 'description': _('AutoTimers')}) if fileExists( resolveFilename( SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/bqe.tmpl") ) or fileExists( resolveFilename( SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/bqe.pyo")): extras.append({ 'key': 'ajax/bqe', 'description': _('BouquetEditor') }) try: from Plugins.Extensions.EPGRefresh.EPGRefresh import epgrefresh # noqa: F401 extras.append({'key': 'ajax/epgr', 'description': _('EPGRefresh')}) except ImportError: pass try: # this will currenly only works if NO Webiterface plugin installed # TODO: test if webinterface AND openwebif installed # 'nw'='1' -> target _blank # 'nw'='2' -> target popup # 'nw'=None -> target _self # syntax # addExternalChild( (Link, Resource, Name, Version, HasGUI, WebTarget) ) # example addExternalChild( ("webadmin", root, "WebAdmin", 1, True, "_self") ) from Plugins.Extensions.WebInterface.WebChilds.Toplevel import loaded_plugins for plugins in loaded_plugins: if plugins[0] in ["fancontrol", "iptvplayer"]: try: extras.append({ 'key': plugins[0], 'description': plugins[2], 'nw': '2' }) except KeyError: pass elif len(plugins) > 4: if plugins[4] == True: try: if len(plugins) > 5 and plugins[5] == "_self": extras.append({ 'key': plugins[0], 'description': plugins[2] }) else: extras.append({ 'key': plugins[0], 'description': plugins[2], 'nw': '1' }) except KeyError: pass except ImportError: pass if os.path.exists('/usr/bin/shellinaboxd') and (fileExists( resolveFilename( SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/terminal.tmpl" ) ) or fileExists( resolveFilename( SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/terminal.pyo") )): extras.append({ 'key': 'ajax/terminal', 'description': _('Terminal') }) ret['extras'] = extras theme = 'original' if config.OpenWebif.webcache.theme.value: theme = config.OpenWebif.webcache.theme.value if not os.path.exists(getPublicPath('themes')): if not (theme == 'original' or theme == 'clear'): theme = 'original' config.OpenWebif.webcache.theme.value = theme config.OpenWebif.webcache.theme.save() ret['theme'] = theme moviedb = config.OpenWebif.webcache.moviedb.value if config.OpenWebif.webcache.moviedb.value else EXT_EVENT_INFO_SOURCE config.OpenWebif.webcache.moviedb.value = moviedb config.OpenWebif.webcache.moviedb.save() ret['moviedb'] = moviedb imagedistro = getInfo()['imagedistro'] ret['vti'] = "1" if imagedistro in ("VTi-Team Image") else "0" ret['webtv'] = os.path.exists(getPublicPath('webtv')) ret['stbLang'] = STB_LANG return ret
def prepareMainTemplate(self, request): # here will be generated the dictionary for the main template ret = getCollapsedMenus() ret['configsections'] = getConfigsSections()['sections'] 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 if hasattr(eEPGCache, 'FULL_DESCRIPTION_SEARCH'): ret['epgsearchcaps'] = True else: ret['epgsearchcaps'] = False extras = [{'key': 'ajax/settings', 'description': _("Settings")}] ifaces = iNetwork.getConfiguredAdapters() if len(ifaces): ip_list = iNetwork.getAdapterAttribute(ifaces[0], "ip") # use only the first configured interface if ip_list: ip = "%d.%d.%d.%d" % (ip_list[0], ip_list[1], ip_list[2], ip_list[3]) if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/LCD4linux/WebSite.pyo")): lcd4linux_key = "lcd4linux/config" if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/WebInterface/plugin.pyo")): try: lcd4linux_port = "http://" + ip + ":" + str(config.plugins.Webinterface.http.port.value) + "/" lcd4linux_key = lcd4linux_port + 'lcd4linux/config' except: # noqa: E722 lcd4linux_key = None if lcd4linux_key: extras.append({'key': lcd4linux_key, 'description': _("LCD4Linux Setup"), 'nw': '1'}) oscamwebif, port, oscamconf, variant = self.oscamconfPath() # Assume http until we know better ... proto = "http" # config file exists if oscamwebif and oscamconf is not None: # oscam defaults to NOT to start the web interface unless a section for it exists, so reset port to None until we find one port = None data = open(oscamconf, "r").readlines() for i in data: if "httpport" in i.lower(): port = i.split("=")[1].strip() if port[0] == '+': proto = "https" port = port[1:] if oscamwebif and port is not None: url = "%s://%s:%s" % (proto, request.getRequestHostname(), port) if variant == "oscam": extras.append({'key': url, 'description': _("OSCam Webinterface"), 'nw': '1'}) elif variant == "ncam": extras.append({'key': url, 'description': _("NCam Webinterface"), 'nw': '1'}) try: from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer # noqa: F401 extras.append({'key': 'ajax/at', 'description': _('AutoTimer')}) except ImportError: pass if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/bqe.tmpl")) or fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/bqe.pyo")): extras.append({'key': 'ajax/bqe', 'description': _('BouquetEditor')}) try: from Plugins.Extensions.EPGRefresh.EPGRefresh import epgrefresh # noqa: F401 extras.append({'key': 'ajax/epgr', 'description': _('EPGRefresh')}) except ImportError: pass try: # this will currenly only works if NO Webiterface plugin installed # TODO: test if webinterface AND openwebif installed from Plugins.Extensions.WebInterface.WebChilds.Toplevel import loaded_plugins for plugins in loaded_plugins: if plugins[0] in ["fancontrol", "iptvplayer", "serienrecorderui"]: try: extras.append({'key': plugins[0], 'description': plugins[2], 'nw': '2'}) except KeyError: pass except ImportError: pass if os.path.exists('/usr/bin/shellinaboxd') and (fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/terminal.tmpl")) or fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/terminal.pyo"))): extras.append({'key': 'ajax/terminal', 'description': _('Terminal')}) ret['extras'] = extras theme = 'original' if config.OpenWebif.webcache.theme.value: theme = config.OpenWebif.webcache.theme.value if not os.path.exists(getPublicPath('themes')): if not (theme == 'original' or theme == 'clear'): theme = 'original' config.OpenWebif.webcache.theme.value = theme config.OpenWebif.webcache.theme.save() ret['theme'] = theme moviedb = config.OpenWebif.webcache.moviedb.value if config.OpenWebif.webcache.moviedb.value else 'IMDb' config.OpenWebif.webcache.moviedb.value = moviedb config.OpenWebif.webcache.moviedb.save() ret['moviedb'] = moviedb imagedistro = getInfo()['imagedistro'] ret['vti'] = imagedistro in ("vti") and 1 or 0 ret['webtv'] = os.path.exists(getPublicPath('webtv')) return ret