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


Python AsyncOpenHttp.make_google_request方法代码示例

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


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

示例1: HandleConnection

# 需要导入模块: from httpClient import AsyncOpenHttp [as 别名]
# 或者: from httpClient.AsyncOpenHttp import make_google_request [as 别名]

#.........这里部分代码省略.........
                    elif startSpeech.coded == StartSpeech.CodecPCM_Mono_16Bit_22050HzValue:
                        encoder.initialize(22050, 1, 16)
                    elif startSpeech.coded == StartSpeech.CodecPCM_Mono_16Bit_32000HzValue:
                        encoder.initialize(32000, 1, 16)
                    # we probably need resampling for sample rates other than 16kHz...
                    
                    self.speech[startSpeech.aceId] = (decoder if speexUsed else None, encoder, dictation)
                
                elif ObjectIsCommand(reqObject, SpeechPacket):
                    self.logger.info("Decoding speech packet")
                    speechPacket = SpeechPacket(reqObject)
                    (decoder, encoder, dictation) = self.speech[speechPacket.refId]
                    if decoder:
                        pcm = decoder.decode(speechPacket.packets)
                    else:
                        pcm = SpeechPacket.data # <- probably data... if pcm
                    encoder.encode(pcm)
                        
                elif reqObject['class'] == 'StartCorrectedSpeechRequest':
                    self.process_recognized_speech({u'hypotheses': [{'confidence': 1.0, 'utterance': str.lower(reqObject['properties']['utterance'])}]}, reqObject['aceId'], False)
            
                elif ObjectIsCommand(reqObject, FinishSpeech):
                    self.logger.info("End of speech received")
                    finishSpeech = FinishSpeech(reqObject)
                    (decoder, encoder, dictation) = self.speech[finishSpeech.refId]
                    if decoder:
                        decoder.destroy()
                    encoder.finish()
                    flacBin = encoder.getBinary()
                    encoder.destroy()
                    del self.speech[finishSpeech.refId]
                    
                    self.logger.info("Sending flac to google for recognition")
                    self.httpClient.make_google_request(flacBin, finishSpeech.refId, dictation, language=self.assistant.language, allowCurses=True)
                        
                        
                elif ObjectIsCommand(reqObject, CancelRequest):
                        # this is probably called when we need to kill a plugin
                        # wait for thread to finish a send
                        cancelRequest = CancelRequest(reqObject)
                        if cancelRequest.refId in self.speech:
                            del self.speech[cancelRequest.refId]
                        
                        self.send_object(CancelSucceeded(cancelRequest.aceId))

                elif ObjectIsCommand(reqObject, GetSessionCertificate):
                    getSessionCertificate = GetSessionCertificate(reqObject)
                    response = GetSessionCertificateResponse(getSessionCertificate.aceId)
                    response.caCert = caCert.as_der()
                    response.sessionCert = serverCert.as_der()
                    self.send_object(response)

                elif ObjectIsCommand(reqObject, CreateSessionInfoRequest):
                    # how does a positive answer look like?
                    createSessionInfoRequest = CreateSessionInfoRequest(reqObject)
                    fail = CommandFailed(createSessionInfoRequest.aceId)
                    fail.reason = "Not authenticated"
                    fail.errorCode = 0
                    self.send_object(fail)

                    #self.send_plist({"class":"SessionValidationFailed", "properties":{"errorCode":"UnsupportedHardwareVersion"}, "aceId": str(uuid.uuid4()), "refId":reqObject['aceId'], "group":"com.apple.ace.system"})
                    
                elif reqObject['class'] == 'CreateAssistant':
                    #create a new assistant
                    helper = Assistant()
                    c = self.dbConnection.cursor()
开发者ID:alexandred,项目名称:SiriServer,代码行数:70,代码来源:siriServer.py

示例2: HandleConnection

# 需要导入模块: from httpClient import AsyncOpenHttp [as 别名]
# 或者: from httpClient.AsyncOpenHttp import make_google_request [as 别名]

#.........这里部分代码省略.........
        self.data = ""
        while self.hasNextObj():
            reqObject = self.read_next_object_from_unzipped()
            if reqObject != None:
                self.logger.debug("Packet with class: {0}".format(reqObject['class']))
                self.logger.debug("packet with content:\n{0}".format(pprint.pformat(reqObject, width=40)))
                
                # first handle speech stuff
                
                if reqObject['class'] == 'StartSpeechRequest' or reqObject['class'] == 'StartSpeechDictation':
                        decoder = speex.Decoder()
                        decoder.initialize(mode=speex.SPEEX_MODEID_WB)
                        encoder = flac.Encoder()
                        encoder.initialize(16000, 1, 16) #16kHz sample rate, 1 channel, 16 bits per sample
                        dictation=(reqObject['class'] == 'StartSpeechDictation')
                        self.speech[reqObject['aceId']] = (decoder, encoder, dictation)
                
                elif reqObject['class'] == 'SpeechPacket':
                    (decoder, encoder, dictation) = self.speech[reqObject['refId']]
                    pcm = decoder.decode(reqObject['properties']['packets'])
                    encoder.encode(pcm)
                        
                elif reqObject['class'] == 'StartCorrectedSpeechRequest':
                    self.process_recognized_speech({u'hypotheses': [{'confidence': 1.0, 'utterance': str.lower(reqObject['properties']['utterance'])}]}, reqObject['aceId'], False)
            
                elif reqObject['class'] == 'FinishSpeech':
                    (decoder, encoder, dictation) = self.speech[reqObject['refId']]
                    decoder.destroy()
                    encoder.finish()
                    flacBin = encoder.getBinary()
                    encoder.destroy()
                    del self.speech[reqObject['refId']]
                    
                    self.httpClient.make_google_request(flacBin, reqObject['refId'], dictation, language=self.assistant.language, allowCurses=True)
                        
                        
                elif reqObject['class'] == 'CancelRequest':
                        # this is probably called when we need to kill a plugin
                        # wait for thread to finish a send
                        if reqObject['refId'] in self.speech:
                            del self.speech[reqObject['refId']]
                        self.send_plist({"class": "CancelSucceeded", "group": "com.apple.ace.system", "aceId": str(uuid.uuid4()), "refId": reqObject['aceId'], "properties":{"callbacks": []}})
                        
                # handle responses to plugin
                elif self.current_running_plugin != None and reqObject['group'] != "com.apple.ace.system" and "refId" in reqObject:
                    if self.current_running_plugin.waitForResponse != None:
                        # just forward the object to the 
                        self.current_running_plugin.response = reqObject
                        self.current_running_plugin.refId = reqObject['refId']
                        self.current_running_plugin.waitForResponse.set()
                else:
                    # handle other stuff
                    if reqObject['class'] == 'GetSessionCertificate':
                        caDer = caCert.as_der()
                        serverDer = serverCert.as_der()
                        self.send_plist({"class": "GetSessionCertificateResponse", "group": "com.apple.ace.system", "aceId": str(uuid.uuid4()), "refId": reqObject['aceId'], "properties":{"certificate": biplist.Data("\x01\x02"+struct.pack(">I", len(caDer))+caDer + struct.pack(">I", len(serverDer))+serverDer)}})

                        #self.send_plist({"class":"CommandFailed", "properties": {"reason":"Not authenticated", "errorCode":0, "callbacks":[]}, "aceId": str(uuid.uuid4()), "refId": reqObject['aceId'], "group":"com.apple.ace.system"})
                    if reqObject['class'] == 'CreateSessionInfoRequest':
                # how does a positive answer look like?
                        self.send_plist({"class":"CommandFailed", "properties": {"reason":"Not authenticated", "errorCode":0, "callbacks":[]}, "aceId": str(uuid.uuid4()), "refId": reqObject['aceId'], "group":"com.apple.ace.system"})
                        #self.send_plist({"class":"SessionValidationFailed", "properties":{"errorCode":"UnsupportedHardwareVersion"}, "aceId": str(uuid.uuid4()), "refId":reqObject['aceId'], "group":"com.apple.ace.system"})
                        
                    if reqObject['class'] == 'CreateAssistant':
                        #create a new assistant
                        helper = Assistant()
开发者ID:Imohamed,项目名称:SiriServer,代码行数:70,代码来源:siriServer.py

示例3: SiriProtocolHandler

# 需要导入模块: from httpClient import AsyncOpenHttp [as 别名]
# 或者: from httpClient.AsyncOpenHttp import make_google_request [as 别名]

#.........这里部分代码省略.........
        
        elif ObjectIsCommand(plist, SpeechPacket):
            self.logger.debug("Decoding speech packet")
            speechPacket = SpeechPacket(plist)
            if speechPacket.refId in self.speech:
                (decoder, encoder, dictation) = self.speech[speechPacket.refId]
                if decoder:
                    pcm = decoder.decode(speechPacket.packets)
                else:
                    pcm = SpeechPacket.data # <- probably data... if pcm
                encoder.encode(pcm)
            else:
                self.logger.debug("Got a speech packet that did not match any current request")
                
        elif plist['class'] == 'StartCorrectedSpeechRequest':
            self.process_recognized_speech({u'hypotheses': [{'confidence': 1.0, 'utterance': plist['properties']['utterance']}]}, plist['aceId'], False)
    
        elif ObjectIsCommand(plist, FinishSpeech):
            self.logger.debug("End of speech received")
            finishSpeech = FinishSpeech(plist)
            if finishSpeech.refId in self.speech:
                (decoder, encoder, dictation) = self.speech[finishSpeech.refId]
                if decoder:
                    decoder.destroy()
                flacBin = None
                if encoder:
                    encoder.finish()
                    flacBin = encoder.getBinary()
                    encoder.destroy()
                del self.speech[finishSpeech.refId]
                if flacBin != None:
                    self.logger.info("Sending flac to google for recognition")
                    try:
                        self.current_google_request = self.httpClient.make_google_request(flacBin, finishSpeech.refId, dictation, language=self.assistant.language, allowCurses=True)
                    except (AttributeError, TypeError):
                        self.logger.warning("Unable to find language record for this assistant. Try turning Siri off and then back on.")
                else:
                    self.logger.info("There was no speech")
            else:
                self.logger.debug("Got a finish speech packet that did not match any current request")
                
        elif ObjectIsCommand(plist, CancelRequest):
            # this is probably called when we need to kill a plugin
            # wait for thread to finish a send
            self.logger.debug("Should cancel current request")
            cancelRequest = CancelRequest(plist)
            if cancelRequest.refId in self.speech:
                (decoder, encoder, dictation) = self.speech[cancelRequest.refId]
                if decoder:
                    decoder.destroy()
                if encoder:
                    encoder.finish()
                    encoder.destroy()
                del self.speech[cancelRequest.refId]
            if self.current_google_request != None:
                self.current_google_request.cancel()
                # if a google request is running (follow up listening..., plugin might get killed there by user)
                if self.current_running_plugin != None:
                    if self.current_running_plugin.waitForResponse != None:
                        self.current_running_plugin._abortPluginRun()
                        self.current_running_plugin.waitForResponse.set()
                        
            # if a plugin is running (processing, but not waiting for data from the device we kill it)   
            if self.current_running_plugin != None:
                if self.current_running_plugin.waitForResponse == None:
                    self.current_running_plugin._abortPluginRun()     
开发者ID:Devil-of-Chaos,项目名称:SiriServerCore,代码行数:70,代码来源:SiriProtocolHandler.py

示例4: SiriProtocolHandler

# 需要导入模块: from httpClient import AsyncOpenHttp [as 别名]
# 或者: from httpClient.AsyncOpenHttp import make_google_request [as 别名]

#.........这里部分代码省略.........
                else:
                    self.send_object(recognized)
                    self.send_object(RequestCompleted(requestId))
            else:
                self.send_object(recognized)
                self.send_object(RequestCompleted(requestId))
    
    def received_plist(self, plist):
        self.logger.debug("Packet with class: {0}".format(plist['class']))
        self.logger.debug("packet with content:\n{0}".format(pprint.pformat(plist, width=40)))
        
        # first handle speech stuff
        
        if 'refId' in plist:
            # if the following holds, this packet is an answer to a request by a plugin
            if plist['refId'] == self.plugin_lastAceId and self.current_running_plugin != None:
                if self.current_running_plugin.waitForResponse != None:
                    # just forward the object to the 
                    # don't change it's refId, further requests must reference last FinishSpeech
                    self.logger.debug("Forwarding object to plugin")
                    self.plugin_lastAceId = None
                    self.current_running_plugin.response = plist if plist['class'] != "StartRequest" else plist['properties']['utterance']
                    self.current_running_plugin.waitForResponse.set()
                    return
        
        if ObjectIsCommand(plist, StartSpeechRequest) or ObjectIsCommand(plist, StartSpeechDictation):
            self.logger.debug("New start of speech received")
            startSpeech = None
            if ObjectIsCommand(plist, StartSpeechDictation):
                dictation = True
                startSpeech = StartSpeechDictation(plist)
            else:
                dictation = False
                startSpeech = StartSpeechRequest(plist)
    
            decoder = speex.Decoder()
            encoder = flac.Encoder()
            speexUsed = False
            if startSpeech.codec == StartSpeech.CodecSpeex_WB_Quality8Value:
                decoder.initialize(mode=speex.SPEEX_MODEID_WB)
                encoder.initialize(16000, 1, 16)
                speexUsed = True
            elif startSpeech.codec == StartSpeech.CodecSpeex_NB_Quality7Value:
                decoder.initialize(mode=speex.SPEEX_MODEID_NB)
                encoder.initialize(16000, 1, 16)
                speexUsed = True
            elif startSpeech.codec == StartSpeech.CodecPCM_Mono_16Bit_8000HzValue:
                encoder.initialize(8000, 1, 16)
            elif startSpeech.codec == StartSpeech.CodecPCM_Mono_16Bit_11025HzValue:
                encoder.initialize(11025, 1, 16)
            elif startSpeech.coded == StartSpeech.CodecPCM_Mono_16Bit_16000HzValue:
                encoder.initialize(16000, 1, 16)
            elif startSpeech.coded == StartSpeech.CodecPCM_Mono_16Bit_22050HzValue:
                encoder.initialize(22050, 1, 16)
            elif startSpeech.coded == StartSpeech.CodecPCM_Mono_16Bit_32000HzValue:
                encoder.initialize(32000, 1, 16)
            # we probably need resampling for sample rates other than 16kHz...
            
            self.speech[startSpeech.aceId] = (decoder if speexUsed else None, encoder, dictation)
        
        elif ObjectIsCommand(plist, SpeechPacket):
            self.logger.debug("Decoding speech packet")
            speechPacket = SpeechPacket(plist)
            (decoder, encoder, dictation) = self.speech[speechPacket.refId]
            if decoder:
                pcm = decoder.decode(speechPacket.packets)
            else:
                pcm = SpeechPacket.data # <- probably data... if pcm
            encoder.encode(pcm)
                
        elif plist['class'] == 'StartCorrectedSpeechRequest':
            self.process_recognized_speech({u'hypotheses': [{'confidence': 1.0, 'utterance': plist['properties']['utterance']}]}, plist['aceId'], False)
    
        elif ObjectIsCommand(plist, FinishSpeech):
            self.logger.debug("End of speech received")
            finishSpeech = FinishSpeech(plist)
            (decoder, encoder, dictation) = self.speech[finishSpeech.refId]
            if decoder:
                decoder.destroy()
            encoder.finish()
            flacBin = encoder.getBinary()
            encoder.destroy()
            del self.speech[finishSpeech.refId]
            
            self.logger.info("Sending flac to google for recognition")
            try:
                self.current_google_request = self.httpClient.make_google_request(flacBin, finishSpeech.refId, dictation, language=self.assistant.language, allowCurses=True)
            except AttributeError, TypeError:
                self.logger.warning("Unable to find language record for this assistant. Try turning Siri off and then back on.")
                
        elif ObjectIsCommand(plist, CancelRequest):
                # this is probably called when we need to kill a plugin
                # wait for thread to finish a send
                self.logger.debug("Should cancel current request")
                cancelRequest = CancelRequest(plist)
                if cancelRequest.refId in self.speech:
                    del self.speech[cancelRequest.refId]
                if self.current_google_request != None:
                    self.current_google_request.cancel()
                self.send_object(CancelSucceeded(cancelRequest.aceId))
开发者ID:Drewch,项目名称:SiriServerCore,代码行数:104,代码来源:SiriProtocolHandler.py

示例5: SiriProtocolHandler

# 需要导入模块: from httpClient import AsyncOpenHttp [as 别名]
# 或者: from httpClient.AsyncOpenHttp import make_google_request [as 别名]

#.........这里部分代码省略.........
        
        elif ObjectIsCommand(plist, SpeechPacket):
            self.logger.debug("Decoding speech packet")
            speechPacket = SpeechPacket(plist)
            if speechPacket.refId in self.speech:
                (decoder, encoder, dictation) = self.speech[speechPacket.refId]
                if decoder:
                    pcm = decoder.decode(speechPacket.packets)
                else:
                    pcm = SpeechPacket.data # <- probably data... if pcm
                encoder.encode(pcm)
            else:
                self.logger.debug("Got a speech packet that did not match any current request")
                
        elif plist['class'] == 'StartCorrectedSpeechRequest':
            self.process_recognized_speech({u'hypotheses': [{'confidence': 1.0, 'utterance': plist['properties']['utterance']}]}, plist['aceId'], False)
    
        elif ObjectIsCommand(plist, FinishSpeech):
            self.logger.debug("End of speech received")
            finishSpeech = FinishSpeech(plist)
            if finishSpeech.refId in self.speech:
                (decoder, encoder, dictation) = self.speech[finishSpeech.refId]
                if decoder:
                    decoder.destroy()
                flacBin = None
                if encoder:
                    encoder.finish()
                    flacBin = encoder.getBinary()
                    encoder.destroy()
                del self.speech[finishSpeech.refId]
                if flacBin != None:
                    self.logger.info("Sending flac to google for recognition")
                    try:
                        self.current_google_request = self.httpClient.make_google_request(flacBin, finishSpeech.refId, dictation, language=self.assistant.language, allowCurses=True)
                    except (AttributeError, TypeError):
                        self.logger.warning("Unable to find language record for this assistant. Try turning Siri off and then back on.")
                else:
                    self.logger.info("There was no speech")
            else:
                self.logger.debug("Got a finish speech packet that did not match any current request")
                
        elif ObjectIsCommand(plist, CancelRequest):
            # this is probably called when we need to kill a plugin
            # wait for thread to finish a send
            self.logger.debug("Should cancel current request")
            cancelRequest = CancelRequest(plist)
            if cancelRequest.refId in self.speech:
                (decoder, encoder, dictation) = self.speech[cancelRequest.refId]
                if decoder:
                    decoder.destroy()
                if encoder:
                    encoder.finish()
                    encoder.destory()
                del self.speech[cancelRequest.refId]
            if self.current_google_request != None:
                self.current_google_request.cancel()
                # if a google request is running (follow up listening..., plugin might get killed there by user)
                if self.current_running_plugin != None:
                    if self.current_running_plugin.waitForResponse != None:
                        self.current_running_plugin._abortPluginRun()
                        self.current_running_plugin.waitForResponse.set()
                        
            # if a plugin is running (processing, but not waiting for data from the device we kill it)
            if self.current_running_plugin != None:
                if self.current_running_plugin.waitForResponse == None:
                    self.current_running_plugin._abortPluginRun()
开发者ID:iPhoneV8,项目名称:SiriServerCore,代码行数:70,代码来源:SiriProtocolHandler.py

示例6: HandleConnection

# 需要导入模块: from httpClient import AsyncOpenHttp [as 别名]
# 或者: from httpClient.AsyncOpenHttp import make_google_request [as 别名]

#.........这里部分代码省略.........
					self.send_plist({"class": "GetSessionCertificateResponse", "group": "com.apple.ace.system", "aceId": str(uuid.uuid4()), "refId": object['aceId'], "properties":{"certificate": biplist.Data("\x01\x02"+struct.pack(">I", len(caDer))+caDer + struct.pack(">I", len(serverDer))+serverDer)}})

					#self.send_plist({"class":"CommandFailed", "properties": {"reason":"Not authenticated", "errorCode":0, "callbacks":[]}, "aceId": str(uuid.uuid4()), "refId": object['aceId'], "group":"com.apple.ace.system"})
				if object['class'] == 'CreateSessionInfoRequest':
			# how does a positive answer look like?
					print "returning response"
					self.send_plist({"class":"CommandFailed", "properties": {"reason":"Not authenticated", "errorCode":0, "callbacks":[]}, "aceId": str(uuid.uuid4()), "refId": object['aceId'], "group":"com.apple.ace.system"})
					#self.send_plist({"class":"SessionValidationFailed", "properties":{"errorCode":"UnsupportedHardwareVersion"}, "aceId": str(uuid.uuid4()), "refId":object['aceId'], "group":"com.apple.ace.system"})
					
				if object['class'] == 'CreateAssistant':
					self.send_plist({"class": "AssistantCreated", "properties": {"speechId": str(uuid.uuid4()), "assistantId": str(uuid.uuid4())}, "group":"com.apple.ace.system", "callbacks":[], "aceId": str(uuid.uuid4()), "refId": object['aceId']})
			
				if object['class'] == 'SetAssistantData':
					# grab assistant data, how is a device identified?
					pass
				
		#probably Create Set and Load assistant work together, first we create one response with success, fill it with set..data and later can load it again using load... however.. what are valid responses to all three requests?
				if object['class'] == 'LoadAssistant':
				# reply with a AssistentLoaded
				#  self.send_plist({"class": "AssistantNotFound", "aceId":str(uuid.uuid4()), "refId":object['aceId'], "group":"com.apple.ace.system"})
					self.send_plist({"class": "AssistantLoaded", "properties": {"version": "20111216-32234-branches/telluride?cnxn=293552c2-8e11-4920-9131-5f5651ce244e", "requestSync":False, "dataAnchor":"removed"}, "aceId":str(uuid.uuid4()), "refId":object['aceId'], "group":"com.apple.ace.system"})
					pass
				if object['class'] == 'DestroyAssistant':
					self.send_plist({"class": "AssistantDestroyed", "properties": {"assistantId": object['properties']['assistantId']}, "aceId":str(uuid.uuid4()), "refId":object['aceId'], "group":"com.apple.ace.system"})

				if object['class'] == 'StartSpeechRequest' or object['class'] == 'StartSpeechDictation':
					decoder = speex.Decoder()
					decoder.initialize(mode=speex.SPEEX_MODEID_WB)
					encoder = flac.Encoder()
					encoder.initialize(16000, 1, 16) #16kHz sample rate, 1 channel, 16 bits per sample
					dictation=(object['class'] == 'StartSpeechDictation')
					self.speech[object['aceId']] = (decoder, encoder, dictation)
					
				if object['class'] == 'SpeechPacket':
					(decoder, encoder, dictation) = self.speech[object['refId']]
					pcm = decoder.decode(object['properties']['packets'])
					encoder.encode(pcm)
				
				if object['class'] == 'CancelRequest':
					# we should test if this stil exists..
					del self.speech[object['refId']]

				if object['class'] == 'StartCorrectedSpeechRequest':
					self.process_recognized_speech({u'hypotheses': [{u'confidence': 1.0, u'utterance': str.lower(object['properties']['utterance'])}]}, object['aceId'], False)
				elif object['class'] == 'FinishSpeech':
					(decoder, encoder, dictation) = self.speech[object['refId']]
					decoder.destroy()
					encoder.finish()
					flacBin = encoder.getBinary()
					encoder.destroy()
					del self.speech[object['refId']]
					
					self.httpClient.make_google_request(flacBin, object['refId'], dictation, language='de-DE', allowCurses=True)
					
	def hasNextObj(self):
		if len(self.unzipped_input) == 0:
			return False
		cmd, inter1, inter2, data = struct.unpack('>BBBH', self.unzipped_input[:5])
		if cmd in (3,4): #ping pong
			return True
		if cmd == 2:
			#print "expect: ", data+5,  " received: ", len(self.unzipped_input)
			return ((data + 5) < len(self.unzipped_input))
	
	def read_next_object_from_unzipped(self):
		cmd, inter1, inter2, data = struct.unpack('>BBBH', self.unzipped_input[:5])
		print cmd, inter1, inter2, data
		
		if cmd == 3: #ping
			self.ping = data
			self.send_pong(self.pong)
			self.pong += 1
			print "Returning a Pong"
			self.unzipped_input = self.unzipped_input[5:]
			return None

		object_size = data
		prefix = self.unzipped_input[:5]
		object_data = self.unzipped_input[5:object_size+5]
		self.unzipped_input = self.unzipped_input[object_size+5:]
		return self.parse_object(object_data)
	
	def parse_object(self, object_data):
		#this is a binary plist file
		plist = biplist.readPlistFromString(object_data)
		return plist

	def flush_unzipped_output(self):
			
		self.output_buffer += self.compressor.compress(self.unzipped_output_buffer)
		#make sure everything is compressed
		self.output_buffer += self.compressor.flush(zlib.Z_SYNC_FLUSH)
		self.unzipped_output_buffer = ""

		self.flush_output_buffer()

	def flush_output_buffer(self):
		if len(self.output_buffer) > 0:
			self.send(self.output_buffer)
			self.output_buffer = ""
开发者ID:Bubelbub,项目名称:SiriServer-,代码行数:104,代码来源:siriServer.py


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