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
 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
Beispiel #3
0
    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
Beispiel #4
0
 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 __init__(self, platform, hostDir, hostUrl):
     self.platform = platform
     self.hosts = {}
     self.packages = {}
     self.hostUrl = hostUrl
     self.hostDir = Filename(hostDir)
     self.hostDir.makeDir()
     self.http = HTTPClient.getGlobalPtr()
 def __init__(self, platform, hostDir, hostUrl):
     self.platform = platform
     self.hosts = {}
     self.packages = {}
     self.hostUrl = hostUrl
     self.hostDir = Filename(hostDir)
     self.hostDir.makeDir()
     self.http = HTTPClient.getGlobalPtr()
    def __init__(self, p3dfile, tokens={}):
        self.p3dfile = Filename(p3dfile)
        self.basename = self.p3dfile.getBasenameWoExtension()
        self.tokens = tokens

        self.tempDir = Filename.temporary("", self.basename, "") + "/"
        self.tempDir.makeDir()
        self.host = HostInfo(
            PandaSystem.getPackageHostUrl(), appRunner=appRunner, hostDir=self.tempDir, asMirror=False, perPlatform=True
        )

        self.http = HTTPClient.getGlobalPtr()
        if not self.host.hasContentsFile:
            if not self.host.readContentsFile():
                if not self.host.downloadContentsFile(self.http):
                    Standalone.notify.error("couldn't read host")
                    return
    def __init__(self, p3dfile, tokens={}):
        self.p3dfile = Filename(p3dfile)
        self.basename = self.p3dfile.getBasenameWoExtension()
        self.tokens = tokens

        self.tempDir = Filename.temporary("", self.basename, "") + "/"
        self.tempDir.makeDir()
        self.host = HostInfo(PandaSystem.getPackageHostUrl(),
                             appRunner=appRunner,
                             hostDir=self.tempDir,
                             asMirror=False,
                             perPlatform=True)

        self.http = HTTPClient.getGlobalPtr()
        if not self.host.hasContentsFile:
            if not self.host.readContentsFile():
                if not self.host.downloadContentsFile(self.http):
                    Standalone.notify.error("couldn't read host")
                    return
Beispiel #9
0
    def redownloadNews(self):
        """Get the new issue that came out while he was playing."""
        if self.redownloadingNews:
            self.notify.warning(
                "averting potential crash redownloadNews called twice, just returning"
            )
            return
        # I know it's info, it's important enough I feel to appear in the logs
        self.percentDownloaded = 0.0
        self.notify.info("starting redownloadNews")
        self.startRedownload = datetime.datetime.now()

        self.redownloadingNews = True
        self.addDownloadingTextTask()

        # Clean up the old issues and start new stuff downloading.
        for issue in self.issues:
            issue.destroy()
        self.issues = []
        self.curIssueIndex = 0
        self.strFilenames = None
        self.needsParseNews = True

        # Start by downloading the index file.
        self.newsUrl = self.getInGameNewsUrl()
        self.newsDir = Filename(self.findNewsDir())

        # Ensure self.newsDir exists and is a directory.
        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)
Beispiel #10
0
    def ban(self, avatarId, dislid, comment):
        """Ban the player"""

        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))

        # get the base ban url from the environment variable first
        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', False):
            newTaskName = "ban-task-%d" % self.curBanRequestNum
            newTask = taskMgr.add(self.doBanUrlTask, newTaskName)
            newTask.banRequestNum = self.curBanRequestNum
            http = HTTPClient.getGlobalPtr()
            channel = http.makeChannel(
                False)  # hmm should we make true for a persistent connection?
            self.channels[self.curBanRequestNum] = channel
            rf = Ramfile()
            self.ramFiles[self.curBanRequestNum] = rf

            channel.beginGetDocument(fullUrl)
            channel.downloadToRam(rf)

        self.curBanRequestNum += 1