def redownloadNews(self): if self.redownloadingNews: self.notify.warning( 'averting potential crash redownloadNews called twice, just returning' ) return else: self.percentDownloaded = 0.0 self.notify.info('starting redownloadNews') self.startRedownload = datetime.datetime.now() self.redownloadingNews = True self.addDownloadingTextTask() for issue in self.issues: issue.destroy() self.issues = [] self.curIssueIndex = 0 self.strFilenames = None self.needsParseNews = True self.newsUrl = self.getInGameNewsUrl() self.newsDir = Filename(self.findNewsDir()) Filename(self.newsDir + '/.').makeDir() http = HTTPClient.getGlobalPtr() self.url = self.newsUrl + self.NewsIndexFilename self.ch = http.makeChannel(True) self.ch.beginGetDocument(self.url) self.rf = Ramfile() self.ch.downloadToRam(self.rf) taskMgr.remove(self.RedownloadTaskName) taskMgr.add(self.downloadIndexTask, self.RedownloadTaskName) return
def ban(self, avatarId, dislid, comment): parameters = '' parameters += 'app=%s' % self.App parameters += '&product=%s' % self.Product parameters += '&user_id=%s' % dislid parameters += '&event_name=%s' % self.EventName commentWithAvatarId = 'avId-%s ' % avatarId commentWithAvatarId += comment parameters += '&comments=%s' % urllib.quote(str(commentWithAvatarId)) baseUrlToUse = self.BanUrl osBaseUrl = os.getenv('BAN_URL') if osBaseUrl: baseUrlToUse = osBaseUrl fullUrl = baseUrlToUse + '?' + parameters self.notify.info('ban request %s dislid=%s comment=%s fullUrl=%s' % (self.curBanRequestNum, dislid, comment, fullUrl)) simbase.air.writeServerEvent('ban_request', avatarId, '%s|%s|%s' % (dislid, comment, fullUrl)) if simbase.config.GetBool('do-actual-ban', True): newTaskName = 'ban-task-%d' % self.curBanRequestNum newTask = taskMgr.add(self.doBanUrlTask, newTaskName) newTask.banRequestNum = self.curBanRequestNum http = HTTPClient.getGlobalPtr() channel = http.makeChannel(False) self.channels[self.curBanRequestNum] = channel rf = Ramfile() self.ramFiles[self.curBanRequestNum] = rf channel.beginGetDocument(fullUrl) channel.downloadToRam(rf) self.curBanRequestNum += 1
def redownloadNews(self): if self.redownloadingNews: self.notify.warning('averting potential crash redownloadNews called twice, just returning') return self.percentDownloaded = 0.0 self.notify.info('starting redownloadNews') self.startRedownload = datetime.datetime.now() self.redownloadingNews = True self.addDownloadingTextTask() for issue in self.issues: issue.destroy() self.issues = [] self.curIssueIndex = 0 self.strFilenames = None self.needsParseNews = True self.newsUrl = self.getInGameNewsUrl() self.newsDir = Filename(self.findNewsDir()) Filename(self.newsDir + '/.').makeDir() http = HTTPClient.getGlobalPtr() self.url = self.newsUrl + self.NewsIndexFilename self.ch = http.makeChannel(True) self.ch.beginGetDocument(self.url) self.rf = Ramfile() self.ch.downloadToRam(self.rf) taskMgr.remove(self.RedownloadTaskName) taskMgr.add(self.downloadIndexTask, self.RedownloadTaskName) return