当前位置: 首页>>代码示例>>Python>>正文


Python HTTPClient.makeChannel方法代码示例

本文整理汇总了Python中pandac.PandaModules.HTTPClient.makeChannel方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPClient.makeChannel方法的具体用法?Python HTTPClient.makeChannel怎么用?Python HTTPClient.makeChannel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandac.PandaModules.HTTPClient的用法示例。


在下文中一共展示了HTTPClient.makeChannel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Heartbeat

# 需要导入模块: from pandac.PandaModules import HTTPClient [as 别名]
# 或者: from pandac.PandaModules.HTTPClient import makeChannel [as 别名]
class Heartbeat():
    
    def __init__(self):
        self.http = HTTPClient()
        
        self.SendHeartbeat()
        #taskMgr.doMethodLater(10, self.SendHeartbeat, 'SendHeartbeat')
        
    def SendHeartbeat(self, task = None):
        baseUrl = 'http://modifire.net/heartbeat.php?'
        values = {'name' : Settings.SERVER_NAME,
                  'currentPlayers' : Globals.CURRENT_PLAYERS,
                  'maxPlayers' : Globals.MAX_PLAYERS,
                  'public' : Settings.SERVER_PUBLIC,
                  'port' : Globals.PORT_SERVER_LISTENER,
                  'version' : Globals.VERSION}
        
        for key, value in values.iteritems():
            values[key] = urllib.quote(str(value))
        
        params = [
                  baseUrl,
                  'name=%s' % (values['name']),
                  'currentPlayers=%s' % (values['currentPlayers']),
                  'maxPlayers=%s' % (values['maxPlayers']),
                  'public=%s' % (values['public']),
                  'port=%s' % (values['port']),
                  'version=%s' % (values['version'])
                  ]
        
        req = '&'.join(params)
        self.channel = self.http.makeChannel(True)
        self.channel.beginGetDocument(DocumentSpec(req))
        self.rf = Ramfile()
        self.channel.downloadToRam(self.rf)
        taskMgr.add(self.downloadTask, 'download')
        
        if(task):
            return task.again
         
    def downloadTask(self, task):
        if self.channel.run():
            return task.cont
        if not self.channel.isDownloadComplete():
            return task.done
        data = self.rf.getData()
        return task.done
开发者ID:czorn,项目名称:Modifire,代码行数:49,代码来源:Heartbeat.py

示例2: __init__

# 需要导入模块: from pandac.PandaModules import HTTPClient [as 别名]
# 或者: from pandac.PandaModules.HTTPClient import makeChannel [as 别名]

#.........这里部分代码省略.........
                loc = temp[1]
                variable = temp[2]
                value = temp[3]
                if variable == 'CTG':
                    self.pandaHTTPClientVarCTG = [domain,
                     loc,
                     variable,
                     value]
                    self.setTheHTTPCookie(self.pandaHTTPClientVarCTG)
                if variable == self.hitboxAcct + 'V6':
                    self.pandaHTTPClientVarDM = [domain,
                     loc,
                     variable,
                     value]
                    self.setTheHTTPCookie(self.pandaHTTPClientVarDM)
                if variable == 'WSS_GW':
                    self.pandaHTTPClientVarWSS = [domain,
                     loc,
                     variable,
                     value]
                    self.setTheHTTPCookie(self.pandaHTTPClientVarWSS)

        except IndexError:
            print 'UserFunnel(Warning): Cookie Data file bad'

        del thedata

    def updateInstanceCookieValues(self):
        a = self.httpSession.getCookie(HTTPCookie('WSS_GW', '/', '.hitbox.com'))
        if a.getName():
            self.pandaHTTPClientVarWSS = ['.hitbox.com',
             '/',
             'WSS_GW',
             a.getValue()]
        b = self.httpSession.getCookie(HTTPCookie('CTG', '/', '.hitbox.com'))
        if b.getName():
            self.pandaHTTPClientVarCTG = ['.hitbox.com',
             '/',
             'CTG',
             b.getValue()]
        c = self.httpSession.getCookie(HTTPCookie(self.hitboxAcct + 'V6', '/', 'ehg-dig.hitbox.com'))
        if c.getName():
            self.pandaHTTPClientVarDM = ['ehg-dig.hitbox.com',
             '/',
             self.hitboxAcct + 'V6',
             c.getValue()]
        del a
        del b
        del c

    def setTheHTTPCookie(self, cookieParams):
        c = HTTPCookie(cookieParams[2], cookieParams[1], cookieParams[0])
        c.setValue(cookieParams[3])
        self.httpSession.setCookie(c)

    def writeOutPandaCookie(self):
        try:
            thefile = open(self.cfCookieFile, 'w')
            if len(self.pandaHTTPClientVarWSS) == 4:
                thefile.write(self.pandaHTTPClientVarWSS[0] + '\t' + self.pandaHTTPClientVarWSS[1] + '\t' + self.pandaHTTPClientVarWSS[2] + '\t' + self.pandaHTTPClientVarWSS[3] + '\n')
            if len(self.pandaHTTPClientVarCTG) == 4:
                thefile.write(self.pandaHTTPClientVarCTG[0] + '\t' + self.pandaHTTPClientVarCTG[1] + '\t' + self.pandaHTTPClientVarCTG[2] + '\t' + self.pandaHTTPClientVarCTG[3] + '\n')
            if len(self.pandaHTTPClientVarDM) == 4:
                thefile.write(self.pandaHTTPClientVarDM[0] + '\t' + self.pandaHTTPClientVarDM[1] + '\t' + self.pandaHTTPClientVarDM[2] + '\t' + self.pandaHTTPClientVarDM[3] + '\n')
            thefile.close()
        except IOError:
            return

    def prerun(self):
        self.getFunnelURL()
        self.buildURL()
        if os.path.isfile(self.cfCookieFile) == True:
            if self.CurrentHost == 1 or self.CurrentHost == 2:
                self.readInPandaCookie()

    def run(self):
        if self.CurrentHost == 0 and patcherVer() == ['OFFLINE']:
            return
        self.nonBlock = self.httpSession.makeChannel(False)
        self.nonBlock.beginGetDocument(DocumentSpec(self.URLtoSend))
        instanceMarker = str(random.randint(1, 1000))
        instanceMarker = 'FunnelLoggingRequest-%s' % instanceMarker
        self.startCheckingAsyncRequest(instanceMarker)

    def startCheckingAsyncRequest(self, name):
        taskMgr.remove(name)
        taskMgr.doMethodLater(0.5, self.pollFunnelTask, name)

    def stopCheckingFunnelTask(self, name):
        taskMgr.remove('pollFunnelTask')

    def pollFunnelTask(self, task):
        result = self.nonBlock.run()
        if result == 0:
            self.stopCheckingFunnelTask(task)
            if self.CurrentHost == 1 or self.CurrentHost == 2:
                self.updateInstanceCookieValues()
                self.writeOutPandaCookie()
        else:
            return Task.again
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leaked-Source,代码行数:104,代码来源:UserFunnel.py

示例3: LoadingScreen

# 需要导入模块: from pandac.PandaModules import HTTPClient [as 别名]
# 或者: from pandac.PandaModules.HTTPClient import makeChannel [as 别名]

#.........这里部分代码省略.........
        
        if len(targetName):
            self._LoadingScreen__setLocationText(targetName)

    def setLoadingScreenShot(self, screenshot):
        if not screenshot:
            return

        self._LoadingScreen__setLoadingArt(screenshot)
    
    def _LoadingScreen__setLoadingArt(self, screenshot):
        if self.snapshot:
            return None
        
        if self.parent and hasattr(base, 'localAvatar') and base.localAvatar.style.getTutorial() < PiratesGlobals.TUT_MET_JOLLY_ROGER and screenshot not in tutorialShots:
            screenshot = random.choice(tutorialShots)
        
        self.snapshot = loader.loadModel(screenshot)
        if self.snapshot:
            if self.parent and base.cr.isPaid() == OTPGlobals.AccessVelvetRope and base.config.GetBool('loading-screen-interstitial', 0):
                self.snapshot.setScale(2.3500000000000001, 1.0, 1.3)
                self.snapshot.setPos(-3.7400000000000002, 0, -1.8300000000000001)
                if self.model is not None:
                    root = self.model.find('**/loading_screen_top')
                    frame_little = self.model.find('**/frame_little')
                    self.snapshot.reparentTo(root, 0)
                    frame_little.reparentTo(root, 1)
                
            else:
                self.snapshot.reparentTo(aspect2dp, NO_FADE_SORT_INDEX)
                self.snapshot.setScale(2.1499999999999999, 1, 1.2)
                self.snapshot.setPos(0.0, 0.0, 0.089999999999999997)
                self.snapshot.setBin('fixed', 1)
            if not self._LoadingScreen__isVisible():
                self.snapshot.hide()
            
        

    
    def _LoadingScreen__setLocationText(self, locationText):
        self.locationText = locationText
        if self._LoadingScreen__isVisible():
            self.locationLabel['text'] = locationText
            self.locationLabel.show()
            self.showTitleFrame()
        
        launcher.setValue('gameLocation', self.locationText)

    
    def _LoadingScreen__setHintText(self, hintText):
        self.hintText = hintText
        if self._LoadingScreen__isVisible():
            self.hintLabel['text'] = hintText
            self.hintLabel.show()
        

    
    def _LoadingScreen__isVisible(self):
        return self.state

    
    def scheduleHide(self, function):
        base.cr.queueAllInterestsCompleteEvent()
        self.acceptOnce(function, self.hide)

    
    def _LoadingScreen__setAdArt(self):
        imageFrame = self.model.find('**/frame')
        randomImageNumber = random.randint(0, len(screenShots) - 1)
        imageFileName = screenShots[randomImageNumber]
        self.adImage = loader.loadModel(imageFileName)
        self.adImage.reparentTo(imageFrame)
        self.adImage.setScale(2.1499999999999999 * 5, 1, 1.2 * 5)
        self.adImage.setPos(0, 0, 2.2999999999999998)
        self.adImage.setBin('fixed', 1)
        if randomImageNumber == 0:
            urlToGet = 'http://log.go.com/log?srvc=dis&guid=951C36F8-3ACD-4EB2-9F02-8E8A0A217AF5&drop=0&addata=3232:64675:408091:64675&a=0'
            self.httpSession = HTTPClient()
            self.nonBlockHTTP = self.httpSession.makeChannel(False)
            self.nonBlockHTTP.beginGetDocument(DocumentSpec(urlToGet))
            instanceMarker = 'FunnelLoggingRequest-%s' % str(random.randint(1, 1000))
            self.startCheckingAsyncRequest(instanceMarker)
        

    
    def startCheckingAsyncRequest(self, name):
        taskMgr.remove(name)
        taskMgr.doMethodLater(0.5, self.pollAdTask, name)

    
    def pollAdTask(self, task):
        result = self.nonBlockHTTP.run()
        if result == 0:
            self.stopCheckingAdTask(task)
        else:
            return Task.again

    
    def stopCheckingAdTask(self, name):
        taskMgr.remove(name)
开发者ID:TTGhost,项目名称:POTCOR-src,代码行数:104,代码来源:LoadingScreen.py

示例4: __init__

# 需要导入模块: from pandac.PandaModules import HTTPClient [as 别名]
# 或者: from pandac.PandaModules.HTTPClient import makeChannel [as 别名]

#.........这里部分代码省略.........
        if a.getName():
            self.pandaHTTPClientVarSVI = [
                '.go.com',
                '/',
                's_vi',
                a.getValue()]

        del a


    def setTheHTTPCookie(self, cookieParams):
        c = HTTPCookie(cookieParams[2], cookieParams[1], cookieParams[0])
        c.setValue(cookieParams[3])
        self.httpSession.setCookie(c)


    def writeOutPandaCookie(self):

        try:
            thefile = open(self.cfCookieFile, 'w')
            if len(self.pandaHTTPClientVarWSS) == 4:
                thefile.write(self.pandaHTTPClientVarWSS[0] + '\t' + self.pandaHTTPClientVarWSS[1] + '\t' + self.pandaHTTPClientVarWSS[2] + '\t' + self.pandaHTTPClientVarWSS[3] + '\n')

            if len(self.pandaHTTPClientVarCTG) == 4:
                thefile.write(self.pandaHTTPClientVarCTG[0] + '\t' + self.pandaHTTPClientVarCTG[1] + '\t' + self.pandaHTTPClientVarCTG[2] + '\t' + self.pandaHTTPClientVarCTG[3] + '\n')

            if len(self.pandaHTTPClientVarDM) == 4:
                thefile.write(self.pandaHTTPClientVarDM[0] + '\t' + self.pandaHTTPClientVarDM[1] + '\t' + self.pandaHTTPClientVarDM[2] + '\t' + self.pandaHTTPClientVarDM[3] + '\n')

            thefile.close()
        except IOError:
            return None



    def writeOutPandaCookieOmniture(self):

        try:
            thefile = open(self.cfCookieFileOmniture, 'w')
            if len(self.pandaHTTPClientVarSVI) == 4:
                thefile.write(self.pandaHTTPClientVarSVI[0] + '\t' + self.pandaHTTPClientVarSVI[1] + '\t' + self.pandaHTTPClientVarSVI[2] + '\t' + self.pandaHTTPClientVarSVI[3] + '\n')

            thefile.close()
        except IOError:
            return None



    def prerun(self):
        self.getFunnelURL()
        self.buildURL()
        if os.path.isfile(self.cfCookieFile) == True:
            if self.CurrentHost == 1 or self.CurrentHost == 2:
                self.readInPandaCookie()


        if os.path.isfile(self.cfCookieFileOmniture) == True and self.CurrentHost == 3:
            self.readInPandaCookieOmniture()



    def run(self):
        if self.CurrentHost == 0 and patcherVer() == [
            'OFFLINE']:
            return None

        self.nonBlock = self.httpSession.makeChannel(False)
        self.nonBlock.beginGetDocument(DocumentSpec(self.URLtoSend))
        instanceMarker = str(random.randint(1, 1000))
        instanceMarker = 'FunnelLoggingRequest-%s' % instanceMarker
        self.startCheckingAsyncRequest(instanceMarker)


    def startCheckingAsyncRequest(self, name):
        taskMgr.remove(name)
        taskMgr.doMethodLater(0.5, self.pollFunnelTask, name)


    def stopCheckingFunnelTask(self, name):
        taskMgr.remove('pollFunnelTask')


    def pollFunnelTask(self, task):
        result = self.nonBlock.run()
        if result == 0:
            self.stopCheckingFunnelTask(task)
            if self.CurrentHost == 1 or self.CurrentHost == 2:
                self.updateInstanceCookieValues()
                self.writeOutPandaCookie()

            if self.CurrentHost == 3:
                self.updateInstanceCookieValuesOmniture()
                self.writeOutPandaCookieOmniture()

        else:
            return Task.again


    def cacheBuster(self):
        return str(time.time())
开发者ID:Puggyblue999,项目名称:PiratesOfTheCarribeanOnline,代码行数:104,代码来源:UserFunnel.py

示例5: FancyLoadingScreen

# 需要导入模块: from pandac.PandaModules import HTTPClient [as 别名]
# 或者: from pandac.PandaModules.HTTPClient import makeChannel [as 别名]

#.........这里部分代码省略.........
        self.hintLabel['text'] = self.hintText
        if self._FancyLoadingScreen__isVisible():
            self.hintLabel.show()



    def _FancyLoadingScreen__isVisible(self):
        return self.state


    def scheduleHide(self, function):
        base.cr.queueAllInterestsCompleteEvent()
        self.acceptOnce(function, self.interestComplete)


    def interestComplete(self):
        self.endStep('scheduleHide')
        self.hide()


    def _FancyLoadingScreen__setAdArt(self):
        return None
        imageFrame = self.model.find('**/frame')
        randomImageNumber = random.randint(0, len(screenShots) - 1)
        imageFileName = screenShots[randomImageNumber]
        self.adImage = loader.loadModel(imageFileName)
        self.adImage.reparentTo(imageFrame)
        self.adImage.setScale(2.1499999999999999 * 5, 1, 1.2 * 5)
        self.adImage.setPos(0, 0, 2.2999999999999998)
        self.adImage.setBin('fixed', 1)
        if randomImageNumber == 0:
            urlToGet = 'http://log.go.com/log?srvc=dis&guid=951C36F8-3ACD-4EB2-9F02-8E8A0A217AF5&drop=0&addata=3232:64675:408091:64675&a=0'
            self.httpSession = HTTPClient()
            self.nonBlockHTTP = self.httpSession.makeChannel(False)
            self.nonBlockHTTP.beginGetDocument(DocumentSpec(urlToGet))
            instanceMarker = 'FunnelLoggingRequest-%s' % str(random.randint(1, 1000))
            self.startCheckingAsyncRequest(instanceMarker)



    def startCheckingAsyncRequest(self, name):
        taskMgr.remove(name)
        taskMgr.doMethodLater(0.5, self.pollAdTask, name)


    def pollAdTask(self, task):
        result = self.nonBlockHTTP.run()
        if result == 0:
            self.stopCheckingAdTask(task)
        else:
            return Task.again


    def stopCheckingAdTask(self, name):
        taskMgr.remove(name)


    def cleanupLoadingScreen(self):
        if self.debugMode:
            self.loadingBarRoot.removeChildren()
            self.cleanupAnalysis()
            self.stepInfo = { }
            self.unmappedTicks = []


开发者ID:Puggyblue999,项目名称:PiratesOfTheCarribeanOnline,代码行数:67,代码来源:FancyLoadingScreen.py


注:本文中的pandac.PandaModules.HTTPClient.makeChannel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。