def save_page(self): self.ARTICLES = self.ARTICLES[::-1] for page in range(1, int(ceil(len(self.ARTICLES) / float(per_page))) + 1): # maybe slow, making a new instance of a # paginator for every article? paginator = Paginator(page, self.ARTICLES, per_page) if (page != 1): self.page_url = 'index%i.html' % page with uopen(os.path.join(self.output_dir, self.page_url), 'w', 'utf-8') as myfile: myfile.write(self.render_html(paginator)) # make the tags? html = self.render_tag_page() if html: with uopen(os.path.join(self.output_dir, 'tags.html'), 'w', 'utf-8') as myfile: myfile.write(html) # make the archive html = self.render_archive_page() if html: with uopen(os.path.join(self.output_dir, 'archive.html'), 'w', 'utf-8') as myfile: myfile.write(html)
def save(self, file = None): file = self.file_check(file) # save the list to file with uopen(file, 'w', 'utf-8') as f: f.write(u'\r\n'.join(self.list)) self.file = file
def __init__(self, urlGLSDataCentreService, gameName, baseDir, osType): SM_TEMPLATE = '<?xml version="1.0" encoding="utf-8"?>\ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">\ <soap:Body><GetDatacenters xmlns="http://www.turbine.com/SE/GLS"><game>%s</game>\ </GetDatacenters></soap:Body></soap:Envelope>' SoapMessage = SM_TEMPLATE % (gameName) try: msg = string_encode(SoapMessage) webservice, post = WebConnection(urlGLSDataCentreService) webservice.putrequest("POST", post) webservice.putheader("Content-type", 'text/xml; charset="UTF-8"') webservice.putheader("Content-length", "%d" % len(msg)) webservice.putheader("SOAPAction", "http://www.turbine.com/SE/GLS/GetDatacenters") webservice.endheaders() webservice.send(msg) webresp = webservice.getresponse() tempxml = string_decode(webresp.read()) filename = "%s%sGLSDataCenter.config" % (baseDir, osType.appDir) outfile = uopen(filename, "w", "utf-8") outfile.write(tempxml) outfile.close() if tempxml == "": self.loadSuccess = False else: doc = xml.dom.minidom.parseString(tempxml) self.authServer = GetText(doc.getElementsByTagName("AuthServer")[0].childNodes) self.patchServer = GetText(doc.getElementsByTagName("PatchServer")[0].childNodes) self.launchConfigServer = GetText(doc.getElementsByTagName("LauncherConfigurationServer")[0].childNodes) self.realmList = [] name = "" urlChatServer = "" urlStatusServer = "" for node in doc.getElementsByTagName("World"): for realm in node.childNodes: if realm.nodeName == "Name": name = realm.firstChild.nodeValue elif realm.nodeName == "ChatServerUrl": urlChatServer = realm.firstChild.nodeValue elif realm.nodeName == "StatusServerUrl": urlStatusServer = realm.firstChild.nodeValue self.realmList.append(Realm(name, urlChatServer, urlStatusServer)) self.loadSuccess = True except: self.loadSuccess = False
def __init__(self, argTemplate, account, ticket, queue, urlIn, baseDir, osType): try: webservice, post = WebConnection(urlIn) argComplete = ( argTemplate.replace("{0}", account) .replace("{1}", quote(ticket)) .replace("{2}", quote(queue)) ) msg = string_encode(argComplete) webservice.putrequest("POST", post) webservice.putheader("Content-type", "application/x-www-form-urlencoded") webservice.putheader("Content-length", "%d" % len(msg)) webservice.putheader( "SOAPAction", "http://www.turbine.com/SE/GLS/LoginAccount" ) webservice.endheaders() webservice.send(msg) webresp = webservice.getresponse() tempxml = string_decode(webresp.read()) filename = "%s%sWorldQueue.config" % (baseDir, osType.appDir) with uopen(filename, "w", "utf-8") as outfile: outfile.write(tempxml) if tempxml == "": self.joinSuccess = False else: doc = defusedxml.minidom.parseString(tempxml) if ( GetText(doc.getElementsByTagName("HResult")[0].childNodes) == "0x00000000" ): self.number = GetText( doc.getElementsByTagName("QueueNumber")[0].childNodes ) self.serving = GetText( doc.getElementsByTagName("NowServingNumber")[0].childNodes ) self.joinSuccess = True else: self.joinSuccess = False except: self.joinSuccess = False
def clean_html(file_addr, save_addr= None): with open( file_addr) as reader: text = ' '.join(reader.readlines()) text = text.decode('utf-8') result = re.findall(paragraphRegex, text) if result: text = ' '.join(result) text = html_regex.sub(' ', text) text = non_persian_regex.sub(' ', text) #text = puncRegex.sub(' ', text) text = space_regex.sub(' ', text) text = dot2enter_regex.sub(' \n', text) if save_addr is None: save_addr = file_addr with uopen(save_addr, 'w', 'utf-8') as writer : writer.write(text)
def load(self, file = None): file = self.file_check(file) # load the list from file self.list = [] with uopen(file, 'r', 'utf-8') as f: lines = f.readlines() for line in lines: if (len(line) > 0 and line[0] == '#') or len(line.split()) == 0: continue items = line.split(',') for item in items: if len(item.strip()) == 0: continue item = item.strip() if item != u"": self.list.append(item) return self.list
def sendRequest(filename, timeout=None): with uopen(filename, encoding="utf-8") as fin: try: request = fin.read() # print request start = time.time() resp = requests.post( OMS, request.encode("utf-8"), headers={"Content-Type": "charset=UTF-8"}, timeout=timeout ) dur = time.time() - start # print resp.text xml = et.fromstring(resp.text) status = getTagText(xml, "Status") code = getTagText(xml, "Code") message = getTagText(xml, "Description") print status, code, message print "Time: " + str(dur) except Exception as e: print e
def CheckRealm(self, useDND, baseDir, osType): try: webservice, post = WebConnection(self.urlServerStatus) webservice.putrequest("GET", post) webservice.endheaders() webresp = webservice.getresponse() tempxml = string_decode(webresp.read()) filename = "%s%sserver.config" % (baseDir, osType.appDir) outfile = uopen(filename, "w", "utf-8") outfile.write(tempxml) outfile.close() if tempxml == "": self.realmAvailable = False else: doc = xml.dom.minidom.parseString(tempxml) try: self.nowServing = GetText( doc.getElementsByTagName("nowservingqueuenumber") [0].childNodes) except: self.nowServing = "" try: self.queueURL = GetText( doc.getElementsByTagName("queueurls") [0].childNodes).split(";")[0] except: self.queueURL = "" self.loginServer = GetText( doc.getElementsByTagName("loginservers") [0].childNodes).split(";")[0] self.realmAvailable = True except: self.realmAvailable = False
def __init__(self, argTemplate, account, ticket, queue, urlIn, baseDir, osType): try: webservice, post = WebConnection(urlIn) argComplete = argTemplate.replace("{0}", account).replace("{1}", quote(ticket)).replace("{2}", quote(queue)) msg = string_encode(argComplete) webservice.putrequest("POST", post) webservice.putheader("Content-type", "application/x-www-form-urlencoded") webservice.putheader("Content-length", "%d" % len(msg)) webservice.putheader("SOAPAction", "http://www.turbine.com/SE/GLS/LoginAccount") webservice.endheaders() webservice.send(msg) webresp = webservice.getresponse() tempxml = string_decode(webresp.read()) filename = "%s%sWorldQueue.config" % (baseDir, osType.appDir) outfile = uopen(filename, "w", "utf-8") outfile.write(tempxml) outfile.close() if tempxml == "": self.joinSuccess = False else: doc = xml.dom.minidom.parseString(tempxml) if GetText(doc.getElementsByTagName("HResult")[0].childNodes) == "0x00000000": self.number = GetText(doc.getElementsByTagName("QueueNumber")[0].childNodes) self.serving = GetText(doc.getElementsByTagName("NowServingNumber")[0].childNodes) self.joinSuccess = True else: self.joinSuccess = False except: self.joinSuccess = False
def CheckRealm(self, useDND, baseDir, osType): try: webservice, post = WebConnection(self.urlServerStatus) webservice.putrequest("GET", post) webservice.endheaders() webresp = webservice.getresponse() tempxml = string_decode(webresp.read()) filename = "%s%sserver.config" % (baseDir, osType.appDir) outfile = uopen(filename, "w", "utf-8") outfile.write(tempxml) outfile.close() if tempxml == "": self.realmAvailable = False else: doc = xml.dom.minidom.parseString(tempxml) try: self.nowServing = GetText(doc.getElementsByTagName("nowservingqueuenumber")[0].childNodes) except: self.nowServing = "" try: self.queueURL = GetText(doc.getElementsByTagName("queueurls")[0].childNodes).split(";")[0] except: self.queueURL = "" self.loginServer = GetText(doc.getElementsByTagName("loginservers")[0].childNodes).split(";")[0] self.realmAvailable = True except: self.realmAvailable = False
#!/usr/bin/env fab from csv import DictReader from codecs import open as uopen from json import loads, dumps from string import ascii_letters, punctuation from fabric.api import * from cStringIO import StringIO from os import urandom keyFd = DictReader( uopen("/Users/ss/keys/aliyun_key.csv", 'r', encoding='utf-8-sig')) d = keyFd.next() env.user = '******' env.region = 'ap-southeast-1' env.key_filename = ['/Users/ss/keys/ralali_production_key.pem'] env.access_key = d['AccessKeyId'] env.access_secret = d['AccessKeySecret'] env.key_pair = 'default_aliyun' env.instance = 'ecs.n1.small' env.zone = 'a' env.imageid = 'ubuntu_16_0402_64_20G_alibase_20171227.vhd' env.wp_tarball = 'http://wordpress.org/latest.tar.gz' env.domain = 'test-aliyun.wordpress' env.dbname = 'test_aliyun_db' @task def provision_ecs(): instance_details = local("aliyuncli ecs CreateInstance --AccessKeyId %s --AccessKeySecret %s --KeyPairName %s --RegionId %s --InstanceType %s --ImageId %s" % \ (env.access_key, env.access_secret, env.key_pair, env.region, env.instance, env.imageid)) env.ecs_instance = loads(instance_details)['InstanceId']
def __init__(self, urlGLSDataCentreService, gameName, baseDir, osType): SM_TEMPLATE = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\ <soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\ <soap:Body><GetDatacenters xmlns=\"http://www.turbine.com/SE/GLS\"><game>%s</game>\ </GetDatacenters></soap:Body></soap:Envelope>" SoapMessage = SM_TEMPLATE % (gameName) try: msg = string_encode(SoapMessage) webservice, post = WebConnection(urlGLSDataCentreService) webservice.putrequest("POST", post) webservice.putheader("Content-type", "text/xml; charset=\"UTF-8\"") webservice.putheader("Content-length", "%d" % len(msg)) webservice.putheader( "SOAPAction", "http://www.turbine.com/SE/GLS/GetDatacenters") webservice.endheaders() webservice.send(msg) webresp = webservice.getresponse() tempxml = string_decode(webresp.read()) filename = "%s%sGLSDataCenter.config" % (baseDir, osType.appDir) outfile = uopen(filename, "w", "utf-8") outfile.write(tempxml) outfile.close() if tempxml == "": self.loadSuccess = False else: doc = xml.dom.minidom.parseString(tempxml) self.authServer = GetText( doc.getElementsByTagName("AuthServer")[0].childNodes) self.patchServer = GetText( doc.getElementsByTagName("PatchServer")[0].childNodes) self.launchConfigServer = GetText(doc.getElementsByTagName( "LauncherConfigurationServer")[0].childNodes) self.realmList = [] name = "" urlChatServer = "" urlStatusServer = "" for node in doc.getElementsByTagName("World"): for realm in node.childNodes: if realm.nodeName == "Name": name = realm.firstChild.nodeValue elif realm.nodeName == "ChatServerUrl": urlChatServer = realm.firstChild.nodeValue elif realm.nodeName == "StatusServerUrl": urlStatusServer = realm.firstChild.nodeValue self.realmList.append( Realm(name, urlChatServer, urlStatusServer)) self.loadSuccess = True except: self.loadSuccess = False
def save_page(self): with uopen(os.path.join(self.output_dir, self.page_url), 'w', 'utf-8') as myfile: myfile.write(self.render_html())
def __init__(self, urlGLSDataCenterService, gameName, baseDir, osType): SM_TEMPLATE = '<?xml version="1.0" encoding="utf-8"?>\ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">\ <soap:Body><GetDatacenters xmlns="http://www.turbine.com/SE/GLS"><game>%s</game>\ </GetDatacenters></soap:Body></soap:Envelope>' SoapMessage = SM_TEMPLATE % (gameName) try: msg = string_encode(SoapMessage) webservice, post = WebConnection(urlGLSDataCenterService) webservice.putrequest("POST", post) webservice.putheader("Content-type", 'text/xml; charset="UTF-8"') webservice.putheader("Content-length", "%d" % len(msg)) webservice.putheader( "SOAPAction", "http://www.turbine.com/SE/GLS/GetDatacenters") webservice.endheaders() webservice.send(msg) webresp = webservice.getresponse() tempxml = string_decode(webresp.read()) filename = "%s%sGLSDataCenter.config" % (baseDir, osType.appDir) with uopen(filename, "w", "utf-8") as outfile: outfile.write(tempxml) if tempxml == "": self.loadSuccess = False else: doc = defusedxml.minidom.parseString(tempxml) self.authServer = GetText( doc.getElementsByTagName("AuthServer")[0].childNodes) self.patchServer = GetText( doc.getElementsByTagName("PatchServer")[0].childNodes) self.launchConfigServer = GetText( doc.getElementsByTagName("LauncherConfigurationServer") [0].childNodes) self.worldList = [] name = "" urlChatServer = "" urlStatusServer = "" for node in doc.getElementsByTagName("World"): for world in node.childNodes: if world.nodeName == "Name": name = world.firstChild.nodeValue elif world.nodeName == "ChatServerUrl": urlChatServer = world.firstChild.nodeValue elif world.nodeName == "StatusServerUrl": urlStatusServer = world.firstChild.nodeValue # Fix for legendary servers always returning nothing for status urlStatusServer = ( f"{urlGLSDataCenterService.rsplit('/Service.asmx', maxsplit=1)[0]}/StatusServer.aspx?s=" f"{urlStatusServer.rsplit('StatusServer.aspx?s=', maxsplit=1)[1]}" ) self.worldList.append( World(name, urlChatServer, urlStatusServer)) self.loadSuccess = True except: self.loadSuccess = False
def __init__(self, urlConfigServer, usingDND, baseDir, osType): self.gameClientFilename = "" self.gameClientArgTemplate = "" self.crashreceiver = "" self.DefaultUploadThrottleMbps = "" self.bugurl = "" self.authserverurl = "" self.supporturl = "" self.supportserviceurl = "" self.glsticketlifetime = "" self.newsFeedURL = "" self.newsStyleSheetURL = "" self.patchProductCode = "" self.worldQueueURL = "" self.worldQueueParam = "" try: webservice, post = WebConnection(urlConfigServer) webservice.putrequest("GET", post) webservice.endheaders() webresp = webservice.getresponse() tempxml = string_decode(webresp.read()) filename = "%s%slauncher.config" % (baseDir, osType.appDir) outfile = uopen(filename, "w", "utf-8") outfile.write(tempxml) outfile.close() if tempxml == "": self.loadSuccess = False else: doc = xml.dom.minidom.parseString(tempxml) nodes = doc.getElementsByTagName("appSettings")[0].childNodes for node in nodes: if node.nodeType == node.ELEMENT_NODE: if node.getAttribute( "key") == "GameClient.WIN32.Filename": self.gameClientFilename = node.getAttribute( "value") elif node.getAttribute( "key") == "GameClient.WIN32.ArgTemplate": self.gameClientArgTemplate = node.getAttribute( "value") elif node.getAttribute( "key") == "GameClient.Arg.crashreceiver": self.crashreceiver = node.getAttribute("value") elif node.getAttribute( "key" ) == "GameClient.Arg.DefaultUploadThrottleMbps": self.DefaultUploadThrottleMbps = node.getAttribute( "value") elif node.getAttribute( "key") == "GameClient.Arg.bugurl": self.bugurl = node.getAttribute("value") elif node.getAttribute( "key") == "GameClient.Arg.authserverurl": self.authserverurl = node.getAttribute("value") elif node.getAttribute( "key") == "GameClient.Arg.supporturl": self.supporturl = node.getAttribute("value") elif node.getAttribute( "key") == "GameClient.Arg.supportserviceurl": self.supportserviceurl = node.getAttribute("value") elif node.getAttribute( "key") == "GameClient.Arg.glsticketlifetime": self.glsticketlifetime = node.getAttribute("value") elif node.getAttribute( "key") == "Launcher.NewsFeedCSSUrl": self.newsFeedCSSURL = node.getAttribute("value") elif node.getAttribute("key") == "URL.NewsFeed": self.newsFeedURL = node.getAttribute("value") elif node.getAttribute("key") == "URL.NewsStyleSheet": self.newsStyleSheetURL = node.getAttribute("value") elif node.getAttribute( "key") == "Patching.ProductCode": self.patchProductCode = node.getAttribute("value") elif node.getAttribute( "key") == "WorldQueue.LoginQueue.URL": self.worldQueueURL = node.getAttribute("value") elif node.getAttribute( "key") == "WorldQueue.TakeANumber.Parameters": self.worldQueueParam = node.getAttribute("value") self.loadSuccess = True except: self.loadSuccess = False raise
def __init__(self, urlConfigServer, usingDND, baseDir, osType, gameDir, x86): self.gameClientFilename = "" self.gameClientArgTemplate = "" self.crashreceiver = "" self.DefaultUploadThrottleMbps = "" self.bugurl = "" self.authserverurl = "" self.supporturl = "" self.supportserviceurl = "" self.glsticketlifetime = "" self.newsFeedURL = "" self.newsStyleSheetURL = "" self.patchProductCode = "" self.worldQueueURL = "" self.worldQueueParam = "" try: webservice, post = WebConnection(urlConfigServer) webservice.putrequest("GET", post) webservice.endheaders() webresp = webservice.getresponse() tempxml = string_decode(webresp.read()) filename = "%s%slauncher.config" % (baseDir, osType.appDir) outfile = uopen(filename, "w", "utf-8") outfile.write(tempxml) outfile.close() if tempxml == "": self.loadSuccess = False else: doc = xml.dom.minidom.parseString(tempxml) nodes = doc.getElementsByTagName("appSettings")[0].childNodes for node in nodes: if node.nodeType == node.ELEMENT_NODE: if node.getAttribute("key") == "GameClient.WIN64.Filename": if x86: self.gameClientFilename = node.getAttribute( "value") if node.getAttribute("key") == "GameClient.WIN32.Filename": if x86 == False: self.gameClientFilename = node.getAttribute( "value") elif node.getAttribute("key") == "GameClient.WIN32.ArgTemplate": self.gameClientArgTemplate = node.getAttribute( "value") elif node.getAttribute("key") == "GameClient.Arg.crashreceiver": self.crashreceiver = node.getAttribute("value") elif node.getAttribute("key") == "GameClient.Arg.DefaultUploadThrottleMbps": self.DefaultUploadThrottleMbps = node.getAttribute( "value") elif node.getAttribute("key") == "GameClient.Arg.bugurl": self.bugurl = node.getAttribute("value") elif node.getAttribute("key") == "GameClient.Arg.authserverurl": self.authserverurl = node.getAttribute("value") elif node.getAttribute("key") == "GameClient.Arg.supporturl": self.supporturl = node.getAttribute("value") elif node.getAttribute("key") == "GameClient.Arg.supportserviceurl": self.supportserviceurl = node.getAttribute("value") elif node.getAttribute("key") == "GameClient.Arg.glsticketlifetime": self.glsticketlifetime = node.getAttribute("value") elif node.getAttribute("key") == "Launcher.NewsFeedCSSUrl": self.newsFeedCSSURL = node.getAttribute("value") elif node.getAttribute("key") == "URL.NewsFeed": self.newsFeedURL = node.getAttribute("value") elif node.getAttribute("key") == "URL.NewsStyleSheet": self.newsStyleSheetURL = node.getAttribute("value") elif node.getAttribute("key") == "Patching.ProductCode": self.patchProductCode = node.getAttribute("value") elif node.getAttribute("key") == "WorldQueue.LoginQueue.URL": self.worldQueueURL = node.getAttribute("value") elif node.getAttribute("key") == "WorldQueue.TakeANumber.Parameters": self.worldQueueParam = node.getAttribute("value") self.loadSuccess = True # check launcher configs in gameDir for local game client override tempxml = "" filenames = ["TurbineLauncher.exe.config", "ddo.launcherconfig", "lotro.launcherconfig"] for filename in filenames: filepath = (gameDir + os.sep + filename) if os.path.exists(filepath): infile = uopen(filepath, "r", "utf-8") tempxml = infile.read() infile.close() doc = xml.dom.minidom.parseString(tempxml) nodes = doc.getElementsByTagName("appSettings")[0].childNodes self.message = "" for node in nodes: if node.nodeType == node.ELEMENT_NODE: if node.getAttribute("key") == "GameClient.WIN32.Filename": self.gameClientFilename = node.getAttribute( "value") self.message = ("<font color=\"Khaki\">" + filename + " 32-bit and/or legacy" " client override activated</font>") if node.getAttribute("key") == "GameClient.WIN64.Filename": self.gameClientFilename = node.getAttribute( "value") self.message = ("<font color=\"Khaki\">" + filename + " 64-bit client" " override activated</font>") except: self.loadSuccess = False raise
def __init__(self, urlLoginServer, name, password, game, baseDir, osType): self.authSuccess = False SM_TEMPLATE = '<?xml version="1.0" encoding="utf-8"?>\ <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \ xmlns:xsd="http://www.w3.org/2001/XMLSchema" \ xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">\ <soap:Body><LoginAccount xmlns="http://www.turbine.com/SE/GLS"><username>%s</username>\ <password>%s</password><additionalInfo></additionalInfo></LoginAccount></soap:Body></soap:Envelope>' SoapMessage = SM_TEMPLATE % (xml_escape(name), xml_escape(password)) webresp = None try: msg = string_encode(SoapMessage) webservice, post = WebConnection(urlLoginServer) webservice.putrequest("POST", post) webservice.putheader("Content-type", 'text/xml; charset="UTF-8"') webservice.putheader("Content-length", "%d" % len(msg)) webservice.putheader("SOAPAction", "http://www.turbine.com/SE/GLS/LoginAccount") webservice.endheaders() webservice.send(msg) webresp = webservice.getresponse() self.gameList = [] activeAccount = False self.ticket = "" tempxml = string_decode(webresp.read()) filename = "%s%sGLSAuthServer.config" % (baseDir, osType.appDir) outfile = uopen(filename, "w", "utf-8") outfile.write(tempxml) outfile.close() if tempxml == "": self.messError = "[E08] Server not found - may be down" else: doc = xml.dom.minidom.parseString(tempxml) self.ticket = GetText(doc.getElementsByTagName("Ticket")[0].childNodes) for nodes in doc.getElementsByTagName("GameSubscription"): game2 = "" status = "" name = "" desc = "" for node in nodes.childNodes: if node.nodeName == "Game": game2 = GetText(node.childNodes) elif node.nodeName == "Status": status = GetText(node.childNodes) elif node.nodeName == "Name": name = GetText(node.childNodes) elif node.nodeName == "Description": desc = GetText(node.childNodes) if game2 == game: activeAccount = True self.gameList.append(Game(name, desc)) if activeAccount: self.messError = "No Error" self.authSuccess = True else: self.messError = "[E14] Game account not associated with user account - please visit games website and check account details" except ssl.SSLError: self.messError = "[E15] SSL Error occured in HTTPS connection" except: if webresp and webresp.status == 500: self.messError = "[E07] Account details incorrect" else: self.messError = "[E08] Server not found - may be down (%s)" % (webresp and webresp.status or "N/A")
def __init__(self, urlConfigServer, usingDND, baseDir, osType): self.gameClientFilename = "" self.gameClientArgTemplate = "" self.crashreceiver = "" self.DefaultUploadThrottleMbps = "" self.bugurl = "" self.authserverurl = "" self.supporturl = "" self.supportserviceurl = "" self.glsticketlifetime = "" self.newsFeedURL = "" self.newsStyleSheetURL = "" self.patchProductCode = "" self.worldQueueURL = "" self.worldQueueParam = "" try: webservice, post = WebConnection(urlConfigServer) webservice.putrequest("GET", post) webservice.endheaders() webresp = webservice.getresponse() tempxml = string_decode(webresp.read()) filename = "%s%slauncher.config" % (baseDir, osType.appDir) outfile = uopen(filename, "w", "utf-8") outfile.write(tempxml) outfile.close() if tempxml == "": self.loadSuccess = False else: doc = xml.dom.minidom.parseString(tempxml) nodes = doc.getElementsByTagName("appSettings")[0].childNodes for node in nodes: if node.nodeType == node.ELEMENT_NODE: if node.getAttribute("key") == "GameClient.WIN32.Filename": self.gameClientFilename = node.getAttribute("value") elif node.getAttribute("key") == "GameClient.WIN32.ArgTemplate": self.gameClientArgTemplate = node.getAttribute("value") elif node.getAttribute("key") == "GameClient.Arg.crashreceiver": self.crashreceiver = node.getAttribute("value") elif node.getAttribute("key") == "GameClient.Arg.DefaultUploadThrottleMbps": self.DefaultUploadThrottleMbps = node.getAttribute("value") elif node.getAttribute("key") == "GameClient.Arg.bugurl": self.bugurl = node.getAttribute("value") elif node.getAttribute("key") == "GameClient.Arg.authserverurl": self.authserverurl = node.getAttribute("value") elif node.getAttribute("key") == "GameClient.Arg.supporturl": self.supporturl = node.getAttribute("value") elif node.getAttribute("key") == "GameClient.Arg.supportserviceurl": self.supportserviceurl = node.getAttribute("value") elif node.getAttribute("key") == "GameClient.Arg.glsticketlifetime": self.glsticketlifetime = node.getAttribute("value") elif node.getAttribute("key") == "URL.NewsFeed": self.newsFeedURL = node.getAttribute("value") elif node.getAttribute("key") == "URL.NewsStyleSheet": self.newsStyleSheetURL = node.getAttribute("value") elif node.getAttribute("key") == "Patching.ProductCode": self.patchProductCode = node.getAttribute("value") elif node.getAttribute("key") == "WorldQueue.LoginQueue.URL": self.worldQueueURL = node.getAttribute("value") elif node.getAttribute("key") == "WorldQueue.TakeANumber.Parameters": self.worldQueueParam = node.getAttribute("value") self.loadSuccess = True except: self.loadSuccess = False raise
def __init__(self, file): super(Config, self).__init__(uopen(file, 'r', 'utf8'))
def __init__(self, urlLoginServer, name, password, game, baseDir, osType): self.authSuccess = False SM_TEMPLATE = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\ <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \ xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \ xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\ <soap:Body><LoginAccount xmlns=\"http://www.turbine.com/SE/GLS\"><username>%s</username>\ <password>%s</password><additionalInfo></additionalInfo></LoginAccount></soap:Body></soap:Envelope>" SoapMessage = SM_TEMPLATE % (xml_escape(name), xml_escape(password)) webresp = None try: msg = string_encode(SoapMessage) webservice, post = WebConnection(urlLoginServer) webservice.putrequest("POST", post) webservice.putheader("Content-type", "text/xml; charset=\"UTF-8\"") webservice.putheader("Content-length", "%d" % len(msg)) webservice.putheader( "SOAPAction", "http://www.turbine.com/SE/GLS/LoginAccount") webservice.endheaders() webservice.send(msg) webresp = webservice.getresponse() self.gameList = [] activeAccount = False self.ticket = "" tempxml = string_decode(webresp.read()) filename = "%s%sGLSAuthServer.config" % (baseDir, osType.appDir) outfile = uopen(filename, "w", "utf-8") outfile.write(tempxml) outfile.close() if tempxml == "": self.messError = "[E08] Server not found - may be down" else: doc = xml.dom.minidom.parseString(tempxml) self.ticket = GetText( doc.getElementsByTagName("Ticket")[0].childNodes) for nodes in doc.getElementsByTagName("GameSubscription"): game2 = "" status = "" name = "" desc = "" for node in nodes.childNodes: if node.nodeName == "Game": game2 = GetText(node.childNodes) elif node.nodeName == "Status": status = GetText(node.childNodes) elif node.nodeName == "Name": name = GetText(node.childNodes) elif node.nodeName == "Description": desc = GetText(node.childNodes) if game2 == game: activeAccount = True self.gameList.append(Game(name, desc)) if activeAccount: self.messError = "No Error" self.authSuccess = True else: self.messError = "[E14] Game account not associated with user account - please visit games website and check account details" except ssl.SSLError: self.messError = "[E15] SSL Error occured in HTTPS connection" except: if webresp and webresp.status == 500: self.messError = "[E07] Account details incorrect" else: self.messError = "[E08] Server not found - may be down (%s)" % ( webresp and webresp.status or "N/A")
def __init__(self, file): super(Config, self).__init__(uopen(file, 'r', 'utf8')) def get_sections(self): return [e for e in self]