Esempio n. 1
0
 def _do_handle(self):
     Log.v(self._msg)
     if self._glance["content_type"] == "text":
         if self._msg["text"].startswith("/"):
             self._handle_cmd(self._msg["text"])
         else:
             self._handle_text(self._msg["text"])
Esempio n. 2
0
	def _do_handle(self):
		Log.v(self._msg)
		if self._glance["content_type"] == "text":
			if self._msg["text"].startswith("/"):
				self._handle_command(self._msg["text"])
			else:
				self._handle_text(self._msg["text"])
		else:
			self._bot.sendMessage(self._glance["chat_id"],
					self.RESPONSE_NON_TEXTUAL_INPUT)
Esempio n. 3
0
	def _do_handle(self):
		Log.v(self._msg)
		query = _QueryHandler(self._glance["query_string"])
		if query.is_empty:
			return []
		try:
			response = CustomSearchApi().list(**query.request_args)
		except CustomSearchApi.NetworkError as e:
			Log.e("Failed while list %d: %s" % (e.status_code, e.message))
			if e.status_code == 403:
				return self.RESPONSE_NO_MORE_QUOTA
			else:
				raise e
		if not response or "items" not in response:
			return self.RESPONSE_NO_RESULTS

		if query.is_image:
			return self._build_image_response(response)
		else:
			return self._build_text_response(response)
Esempio n. 4
0
                if DEF.STEP_BY_STEP:
                    raw_input()
            # ...and stop execution on Ctrl+C
            except KeyboardInterrupt:
                self.finish( cancelled=True )

    def finish( self, cancelled=False ):
        if cancelled:
            l.e( "Execution ABORTED", "finish" )
        else:
            l.v( "Execution FINISHED", "finish" )
        self.running = False

    def has_trapped( self ):
        return self.trap_count > 0

    def increment_PC( self ):
        l.v( self.PC, "PC" )
        self.PC += 1

if __name__ == '__main__':
    l.v( "Test Init", "CPU" )
    cpu = CPU()
    l.d( cpu.imem, "InstructionMemory" )
    l.d( cpu.ib, "InstructionBuffer" )
    l.d( cpu.iw, "InstructionWindow" )
    l.d( cpu.rob, "ReorderBuffer" )
    l.d( cpu.dmem, "DataMemory" )
    l.d( cpu.regs, "Registers" )
    l.v( "Test End", "CPU" )