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


Python querier.Querier类代码示例

本文整理汇总了Python中querier.Querier的典型用法代码示例。如果您正苦于以下问题:Python Querier类的具体用法?Python Querier怎么用?Python Querier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

    def __init__(self, dht_addr):
        my_addr = dht_addr
        my_id = identifier.RandomId()
        my_node = Node(my_addr, my_id)
        tracker_ = tracker.Tracker()
        token_m = token_manager.TokenManager()

        self.reactor = ThreadedReactor()
        rpc_m = RPCManager(self.reactor, my_addr[1])
        querier_ = Querier(rpc_m, my_id)
        routing_m = RoutingManager(my_node, querier_,
                                   bootstrap_nodes)
        responder_ = Responder(my_id, routing_m,
                              tracker_, token_m)

        responder_.set_on_query_received_callback(
            routing_m.on_query_received)
        querier_.set_on_response_received_callback(
            routing_m.on_response_received)
        querier_.set_on_error_received_callback(
            routing_m.on_error_received)
        querier_.set_on_timeout_callback(routing_m.on_timeout)
        querier_.set_on_nodes_found_callback(routing_m.on_nodes_found)

        routing_m.do_bootstrap()

        rpc_m.add_msg_callback(QUERY,
                               responder_.on_query_received)

        self.lookup_m = LookupManager(my_id, querier_,
                                      routing_m)
        self._routing_m = routing_m
开发者ID:Anaconda84,项目名称:Anaconda,代码行数:32,代码来源:controller.py

示例2: do_query

 def do_query(self, query):
     """
     Renders the results page
     """
     q = Querier()
     results = None
     try:
         # extracts only the bindings from the result dictionary
         bindings = [r['results']['bindings'] for r in q.query(str(query)) if r['results']['bindings'] != []]
         results = self.unpack_results(bindings)
     except:
         # in case of any exception should render an error page
         results = "ERROR"
     return self.serve_template('results.txt', results=results)
开发者ID:iferminm,项目名称:Semantic-Search,代码行数:14,代码来源:searcher.py

示例3: cancelLinking

	def cancelLinking(self):
		"""cancelLinking()
		takes modem out of linking or unlinking mode"""
		self.querier = Querier(InsteonAddress("00.00.00"))
		self.querier.setMsgHandler(DefaultMsgHandler("cancel linking"))
		msg = Msg.s_makeMessage("CancelALLLinking")
		self.querier.sendMsg(msg)
开发者ID:MattM178,项目名称:insteon-terminal,代码行数:7,代码来源:modem2413U.py

示例4: __init__

    def __init__(self, dht_addr):
        self.my_addr = dht_addr
        self.my_id = identifier.RandomId()
        self.my_node = Node(self.my_addr, self.my_id)
        self.tracker = tracker.Tracker()
        self.token_m = token_manager.TokenManager()

        self.reactor = ThreadedReactor()
        self.rpc_m = RPCManager(self.reactor, self.my_addr[1])
        self.querier = Querier(self.rpc_m, self.my_id)
        self.routing_m = RoutingManager(self.my_node, self.querier,
                                        bootstrap_nodes)
        self.responder = Responder(self.my_id, self.routing_m,
                                   self.tracker, self.token_m)

        self.responder.set_on_query_received_callback(
            self.routing_m.on_query_received)
        self.querier.set_on_response_received_callback(
            self.routing_m.on_response_received)
        self.querier.set_on_error_received_callback(
            self.routing_m.on_error_received)
        self.querier.set_on_timeout_callback(self.routing_m.on_timeout)
        self.querier.set_on_nodes_found_callback(self.routing_m.on_nodes_found)

        self.routing_m.do_bootstrap()

        self.rpc_m.add_msg_callback(QUERY,
                                    self.responder.on_query_received)

        self.lookup_m = LookupManager(self.my_id, self.querier,
                                      self.routing_m)
开发者ID:Anaconda84,项目名称:Anaconda,代码行数:31,代码来源:controller.py

示例5: __init__

    def __init__(self, version_label,
                 my_node, conf_path,
                 routing_m_mod, lookup_m_mod,
                 experimental_m_mod,
                 private_dht_name,
                 bootstrap_mode):
        self.bootstrapper = bootstrap.OverlayBootstrapper(conf_path)
        my_addr = my_node.addr
        self._my_id = my_node.id # id indicated by user 
        if not self._my_id:
            self._my_id = self._my_id = identifier.RandomId() # random id
        self._my_node = Node(my_addr, self._my_id, version=version_label)
        self.msg_f = message.MsgFactory(version_label, self._my_id,
                                        private_dht_name)
        self._querier = Querier()
        self._routing_m = routing_m_mod.RoutingManager(
            self._my_node, self.msg_f, self.bootstrapper)

        self._responder = responder.Responder(self._my_id, self._routing_m,
                                              self.msg_f, bootstrap_mode)
        self._tracker = self._responder._tracker
        
        self._lookup_m = lookup_m_mod.LookupManager(self._my_id, self.msg_f,
                                                    self.bootstrapper)
        self._experimental_m = experimental_m_mod.ExperimentalManager(
            self._my_node.id, self.msg_f) 
                  
        current_ts = time.time()
        self._next_maintenance_ts = current_ts
        self._next_timeout_ts = current_ts
        self._next_main_loop_call_ts = current_ts
        self._cached_lookups = []
开发者ID:GlobalSquare,项目名称:pymdht,代码行数:32,代码来源:controller.py

示例6: __init__

    def __init__(self, dht_addr, state_filename,
                 routing_m_mod, lookup_m_mod,
                 experimental_m_mod,
                 private_dht_name):
        #TODO: don't do this evil stuff!!!
        message.private_dht_name = private_dht_name

        if size_estimation:
            self._size_estimation_file = open('size_estimation.dat', 'w')
        
        
        self.state_filename = state_filename
        saved_id, saved_bootstrap_nodes = state.load(self.state_filename)
        if saved_id:
            self._my_id = saved_id
        else:
            self._my_id = identifier.RandomId()
        self._my_node = Node(dht_addr, self._my_id)
        self._tracker = tracker.Tracker()
        self._token_m = token_manager.TokenManager()

        self._querier = Querier()
        self._routing_m = routing_m_mod.RoutingManager(self._my_node, 
                                                       saved_bootstrap_nodes)
        self._lookup_m = lookup_m_mod.LookupManager(self._my_id)
        self._experimental_m = experimental_m_mod.ExperimentalManager(self._my_node.id) 
                  
        current_ts = time.time()
        self._next_save_state_ts = current_ts + SAVE_STATE_DELAY
        self._next_maintenance_ts = current_ts
        self._next_timeout_ts = current_ts
        self._next_main_loop_call_ts = current_ts
        self._pending_lookups = []
开发者ID:csasm,项目名称:pymdht,代码行数:33,代码来源:controller.py

示例7: __init__

    def __init__(self, dht_addr, state_path,
                 routing_m_mod, lookup_m_mod,
                 private_dht_name):
        #TODO: don't do this evil stuff!!!
        message.private_dht_name = private_dht_name
        
        self.state_filename = os.path.join(state_path, STATE_FILENAME)
        self.load_state()
        if not self._my_id:
            self._my_id = identifier.RandomId()
        self._my_node = Node(dht_addr, self._my_id)
        self._tracker = tracker.Tracker()
        self._token_m = token_manager.TokenManager()

        self._reactor = ThreadedReactor()
        self._reactor.listen_udp(self._my_node.addr[1],
                                 self._on_datagram_received)
        #self._rpc_m = RPCManager(self._reactor)
        self._querier = Querier(self._my_id)
        bootstrap_nodes = self.loaded_nodes or BOOTSTRAP_NODES
        del self.loaded_nodes
        self._routing_m = routing_m_mod.RoutingManager(self._my_node, 
                                                       bootstrap_nodes)
#        self._responder = Responder(self._my_id, self._routing_m,
#                                    self._tracker, self._token_m)

        self._lookup_m = lookup_m_mod.LookupManager(self._my_id)
        current_time = time.time()
        self._next_maintenance_ts = current_time
        self._next_save_state_ts = current_time + SAVE_STATE_DELAY
        
        self._running = False
开发者ID:futtre,项目名称:pymdht,代码行数:32,代码来源:controller.py

示例8: getid

	def getid(self):
		"""getid()
		get modem id data"""
		self.querier = Querier(InsteonAddress("00.00.00"))
		self.querier.setMsgHandler(IMInfoMsgHandler("getid"))
		msg = Msg.s_makeMessage("GetIMInfo")
		self.querier.sendMsg(msg)
开发者ID:MattM178,项目名称:insteon-terminal,代码行数:7,代码来源:modem2413U.py

示例9: unlinkAsController

	def unlinkAsController(self, otherDevice, group):
		"""unlinkAsController(otherDevice, group)
		puts modem in unlink mode to unlink as controller from device "otherDevice" on group "group" """
		addr = InsteonAddress(otherDevice)
		self.querier = Querier(addr)
		self.querier.setMsgHandler(DefaultMsgHandler("unlink as controller"))
		msg = Msg.s_makeMessage("StartALLLinking")
		msg.setByte("LinkCode", 0xFF)
		msg.setByte("ALLLinkGroup", group)
		self.querier.sendMsg(msg)
开发者ID:MattM178,项目名称:insteon-terminal,代码行数:10,代码来源:modem2413U.py

示例10: linkAsResponder

	def linkAsResponder(self, otherDevice, group):
		"""linkAsResponder(otherDevice, group)
		puts modem in link mode to respond to device "otherDevice" on group "group" """
		addr = InsteonAddress(otherDevice)
		self.querier = Querier(addr)
		self.querier.setMsgHandler(DefaultMsgHandler("start linking"))
		msg = Msg.s_makeMessage("StartALLLinking")
		msg.setByte("LinkCode", 0x00)
		msg.setByte("ALLLinkGroup", group)
		self.querier.sendMsg(msg)
开发者ID:MattM178,项目名称:insteon-terminal,代码行数:10,代码来源:modem2413U.py

示例11: __init__

    def __init__(self, version_label,
                 my_node, state_filename,
                 routing_m_mod, lookup_m_mod,
                 experimental_m_mod,
                 private_dht_name,
                 bootstrap_mode):
        
        if size_estimation:
            self._size_estimation_file = open('size_estimation.dat', 'w')
        
        
        self.state_filename = state_filename
        saved_id, saved_bootstrap_nodes = state.load(self.state_filename)
        my_addr = my_node.addr
        self._my_id = my_node.id # id indicated by user 
        if not self._my_id:
            self._my_id = saved_id # id loaded from file
        if not self._my_id:
            self._my_id = self._my_id = identifier.RandomId() # random id
        self._my_node = Node(my_addr, self._my_id, version=version_label)
        self.msg_f = message.MsgFactory(version_label, self._my_id,
                                        private_dht_name)
        self._querier = Querier()
        self._routing_m = routing_m_mod.RoutingManager(
            self._my_node, saved_bootstrap_nodes, self.msg_f)

        self._responder = responder.Responder(self._my_id, self._routing_m,
                                              self.msg_f, bootstrap_mode)
        self._tracker = self._responder._tracker
        
        self._lookup_m = lookup_m_mod.LookupManager(self._my_id, self.msg_f)
        self._experimental_m = experimental_m_mod.ExperimentalManager(
            self._my_node.id, self.msg_f) 
                  
        current_ts = time.time()
        self._next_save_state_ts = current_ts + SAVE_STATE_DELAY
        self._next_maintenance_ts = current_ts
        self._next_timeout_ts = current_ts
        self._next_main_loop_call_ts = current_ts
        self._pending_lookups = []
        self._cached_lookups = []
开发者ID:AnandMurugan,项目名称:tgs-android,代码行数:41,代码来源:controller.py

示例12: setup

 def setup(self):
     global time
     time = querier.time = MockTime()
     self.querier = Querier(tc.CLIENT_ID)
开发者ID:csasm,项目名称:Look-MLKademlia,代码行数:4,代码来源:test_querier.py

示例13: startWatch

	def startWatch(self):
		"""startWatch()
		modem will print all incoming messages on terminal"""
		self.querier = Querier(InsteonAddress("00.00.00"))
		self.querier.setMsgHandler(MsgDumper("modem"))
		self.querier.startWait(10000)
开发者ID:MattM178,项目名称:insteon-terminal,代码行数:6,代码来源:modem2413U.py

示例14: setup

 def setup(self):
     time.mock_mode()
     self.querier = Querier()#tc.CLIENT_ID)
开发者ID:GlobalSquare,项目名称:pymdht,代码行数:3,代码来源:test_querier.py

示例15: __init__

	def __init__(self, name, addr):
		self.name = name
		self.address = addr
		self.db = DB()
		self.querier = Querier(addr)
		addDev(self)
开发者ID:PhilippeLibioulle,项目名称:insteon-terminal,代码行数:6,代码来源:device.py


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