def __init__(self, session): self.skin = OpenWebifConfig.skin Screen.__init__(self, session) self.list = [] ConfigListScreen.__init__(self, self.list) self["key_red"] = Label(_("Cancel")) self["key_green"] = Label(_("Save")) owif_protocol = "https" if config.OpenWebif.https_enabled.value else "http" owif_port = config.OpenWebif.https_port.value if config.OpenWebif.https_enabled.value else config.OpenWebif.port.value ip = getIP() if ip == None: ip = _("box_ip") ports = ":%d" % owif_port if (owif_protocol == "http" and owif_port == 80) or (owif_protocol == "https" and owif_port == 443): ports = "" self["lab1"] = Label("%s %s://%s%s" % (_("OpenWebif url:"), owif_protocol, ip, ports)) self["actions"] = ActionMap(["WizardActions", "ColorActions"], { "red": self.keyCancel, "back": self.keyCancel, "green": self.keySave, }, -2) self.runSetup() self.onLayoutFinish.append(self.setWindowTitle)
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