def setAccountsSettings(self, account_nodes): for account_node in account_nodes: account_name = account_node.nodeName if account_name != "#text": # Create account settings list. The amount of # empty strings in the list represent the # amount of account settings. self.accountsDictionary[account_name] = [""] for node in account_node.childNodes: if node.nodeName == "World": self.accountsDictionary[account_name][0] = GetText( node.childNodes) self.focusAccount = False
def GetNews(self): try: with urllib.request.urlopen( self.worldQueueConfig.newsStyleSheetURL, context=self.sslContext) as xml_feed: doc = defusedxml.minidom.parseString(xml_feed.read(), forbid_entities=False) nodes = doc.getElementsByTagName("div") for node in nodes: if node.nodeType == node.ELEMENT_NODE and ( node.attributes.item(0).firstChild.nodeValue == "launcherNewsItemDate"): timeCode = GetText(node.childNodes).strip() timeCode = (timeCode.replace("\t", "").replace(",", "").replace( "-", "")) if len(timeCode) > 0: timeCode = " %s" % (timeCode) links = doc.getElementsByTagName("link") for link in links: if link.nodeType == link.ELEMENT_NODE: href = link.attributes["href"] # Ignore broken href (as of 3/30/16) in the style sheet and use Launcher. # NewsFeedCSSUrl defined in launcher.config href.value = self.worldQueueConfig.newsFeedCSSURL HTMLTEMPLATE = '<html><head><link rel="stylesheet" type="text/css" href="' HTMLTEMPLATE += href.value HTMLTEMPLATE += ( '"/><base target="_blank"/></head><body><div ' 'class="launcherNewsItemsContainer" style="width:auto">') # DDO test client doesn't provide a news feed, so one from the forums is used. if self.settings.currentGame == "DDO.Test": urlNewsFeed = ( "https://www.ddo.com/forums/external.php?type=RSS2&forumids=266" ) else: urlNewsFeed = self.worldQueueConfig.newsFeedURL.replace( "{lang}", self.settings.language.lower()) result = HTMLTEMPLATE with urllib.request.urlopen(urlNewsFeed, context=self.sslContext) as xml_feed: doc = defusedxml.minidom.parseString(xml_feed.read()) items = doc.getElementsByTagName("item") for item in items: title = "" description = "" date = "" for node in item.childNodes: if node.nodeType == node.ELEMENT_NODE: if node.nodeName == "title": title = ( '<font color="gold"><div class="launcherNewsItemTitle">%s</div></font>' % (GetText(node.childNodes))) elif node.nodeName == "description": description = ( '<div class="launcherNewsItemDescription">%s</div>' % (GetText(node.childNodes))) elif node.nodeName == "pubDate": tempDate = GetText(node.childNodes) dispDate = "%s %s %s %s%s" % ( tempDate[8:11], tempDate[5:7], tempDate[12:16], tempDate[17:22], timeCode, ) date = ( '<small><i><div align="right"class="launcherNewsItemDate">%s</div></i></small>' % (dispDate)) result += '<div class="launcherNewsItemContainer">%s%s%s%s</div>' % ( title, date, description, "<hr>", ) result += "</div></body></html>" self.ReturnNews.emit(result) except Exception as error: self.ReturnLog.emit("[E12] Error getting news") self.logger.warning(error)
def LoadSettings(self, useGame=None): self.hiResEnabled = True self.language = "EN" # Key is account name and content is list of details relating to account. self.accountsDictionary = OrderedDict() self.wineProg = "wine" self.wineDebug = "fixme-all" self.patchClient = "patchclient.dll" self.focusAccount = True self.winePrefix = self.settingsDir + "wine/prefix" self.builtInPrefixEnabled = True self.gameDir = "" self.x64ClientEnabled = True self.savePassword = False self.startupScripts = [] success = False if self.winePrefix is None: self.winePrefix = "" try: if os.path.exists(self.settingsFile): doc = defusedxml.minidom.parse(self.settingsFile) if useGame is None: defaultGame = GetText( doc.getElementsByTagName("Default.Game")[0].childNodes) else: defaultGame = useGame self.currentGame = defaultGame nodes = doc.getElementsByTagName(defaultGame)[0].childNodes for node in nodes: if node.nodeName == "Wine.Program": self.wineProg = GetText(node.childNodes) elif node.nodeName == "Wine.Debug": self.wineDebug = GetText(node.childNodes) elif node.nodeName == "Wine.Prefix": winePrefix = GetText(node.childNodes) # Checks if prefix is set to built in wine prefix if winePrefix != self.winePrefix: self.winePrefix = winePrefix self.builtInPrefixEnabled = False elif node.nodeName == "HiRes": self.hiResEnabled = True if GetText( node.childNodes) == "True" else False elif node.nodeName == "x64Client": self.x64ClientEnabled = True if GetText( node.childNodes) == "True" else False elif node.nodeName == "Save.Password": self.savePassword = True if GetText( node.childNodes) == "True" else False elif node.nodeName == "Game.Directory": self.gameDir = GetText(node.childNodes) elif node.nodeName == "Language": self.language = GetText(node.childNodes) elif node.nodeName == "PatchClient": self.patchClient = GetText(node.childNodes) elif node.nodeName == "Accounts" and not self.currentGame.endswith( ".Test"): account_nodes = node.childNodes self.setAccountsSettings(account_nodes) elif node.nodeName == "StartupScripts" and not self.currentGame.endswith( ".Test"): startup_script_nodes = node.childNodes self.setStartupScriptSettings(startup_script_nodes) # Test/preview clients use accounts and startups scripts from normal clients if self.currentGame.endswith(".Test"): normalClientNode = self.getNormalClientNode( self.currentGame, doc) if normalClientNode: # Load in accounts and their settings from normal client node accountsNode = normalClientNode.getElementsByTagName( "Accounts") if accountsNode: account_nodes = accountsNode[0].childNodes self.setAccountsSettings(account_nodes) # Load in startup scripts from normal client node startupScriptsNode = normalClientNode.getElementsByTagName( "StartupScripts") if startupScriptsNode: startup_script_nodes = startupScriptsNode[ 0].childNodes self.setStartupScriptSettings(startup_script_nodes) # Disables 64-bit client if it is unavailable for LOTRO if not os.path.exists( self.gameDir + os.sep + "x64" + os.sep + "lotroclient64.exe") and self.currentGame.startswith( "LOTRO"): self.x64ClientEnabled = False # Disables 64-bit client if it is unavailable for DDO if not os.path.exists(self.gameDir + os.sep + "x64" + os.sep + "dndclient64.exe" ) and self.currentGame.startswith("DDO"): self.x64ClientEnabled = False success = True if (not os.path.exists(self.wineProg) and self.wineProg != "wine" and not self.builtInPrefixEnabled): success = "[E16] Wine executable set does not exist" except Exception as error: self.logger.error(error, exc_info=True) success = False return success
def setStartupScriptSettings(self, startup_script_nodes): for node in startup_script_nodes: if node.nodeName == "script": self.startupScripts.append(GetText(node.childNodes))