Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(37)  |  Call(29)  |  Derive(0)  |  Import(8)

src/d/h/DHTBot-HEAD/dhtbot/coding/krpc_coder.py   DHTBot(Download)
from dhtbot.coding import basic_coder
from dhtbot.coding.bencode import bdecode, bencode, BTFailure
from dhtbot.krpc_types import Query, Response, Error
 
class InvalidKRPCError(Exception):
 
    """
    q = Query()
    q._from = basic_coder.decode_network_id(rpc_dict['a']['id'])
    q.rpctype = rpctype = rpc_dict['q']

src/d/h/DHTBot-HEAD/dhtbot/protocols/krpc_sender.py   DHTBot(Download)
from dhtbot.coding import krpc_coder
from dhtbot.coding.krpc_coder import InvalidKRPCError
from dhtbot.krpc_types import Query, Response, Error
from dhtbot.transaction import Transaction
from dhtbot.protocols.errors import TimeoutError, KRPCError 

src/d/h/DHTBot-HEAD/dhtbot/protocols/krpc_responder.py   DHTBot(Download)
from dhtbot import constants, contact
from dhtbot.coding import basic_coder
from dhtbot.krpc_types import Query
from dhtbot.datastore import MemoryDataStore
from dhtbot.protocols.krpc_sender import KRPC_Sender, IKRPC_Sender
    def ping(self, address, timeout=None):
        timeout = timeout or constants.rpctimeout
        query = Query()
        query.rpctype = "ping"
        return self.sendQuery(query, address, timeout)
 
    def find_node(self, address, node_id, timeout=None):
        timeout = timeout or constants.rpctimeout
        query = Query()
    def get_peers(self, address, target_id, timeout=None):
        timeout = timeout or constants.rpctimeout
        query = Query()
        query.rpctype = "get_peers"
        query.target_id = target_id
        return self.sendQuery(query, address, timeout)
 
    def announce_peer(self, address, target_id, token, port, timeout=None):
        timeout = timeout or constants.rpctimeout
        query = Query()

src/d/h/DHTBot-HEAD/dhtbot/test/test_krpc_types.py   DHTBot(Download)
from twisted.trial import unittest
 
from dhtbot.krpc_types import _KRPC, Query, Response, Error
 
class KRPCTestCase(unittest.TestCase):
    def setUp(self):
        self.q = Query()
        self.q._transaction_id = 500
        self.q._from = 27
        self.q.rpctype = "ping"
    def _gen_equal_announce_peers(self):
        q1 = Query()
        q2 = Query()
        q1._transaction_id = q2._transaction_id = 99
        q1._from = q2._from = 55

src/d/h/DHTBot-HEAD/dhtbot/test/protocols/test_krpc_sender.py   DHTBot(Download)
from twisted.trial import unittest
from twisted.python.monkey import MonkeyPatcher
 
from dhtbot.krpc_types import Query, Response, Error
from dhtbot.kademlia.routing_table import TreeRoutingTable
    def setUp(self):
        _swap_out_reactor()
 
        q = Query()
        q._transaction_id = 50
    def test_responseReceived(self):
        # Make a query that we will "send"
        query = Query()
        query.rpctype = "ping"
        # Make the protocol and patch in our counter, transport, and reactor
    def setUp(self):
        _swap_out_reactor()
        self.k_messenger = KRPC_Sender(TreeRoutingTable, 2**50)
        self.k_messenger.transport = HollowTransport()
        self.query = Query()
    def test_errback_InvalidKRPCError(self):
        # Make an invalid query
        query = Query()
        query.rpctype = "pingpong"
        d = self.k_messenger.sendQuery(query, address, timeout)

src/d/h/DHTBot-HEAD/dhtbot/test/protocols/test_krpc_responder.py   DHTBot(Download)
from dhtbot import constants, contact
from dhtbot.coding import krpc_coder
from dhtbot.krpc_types import Query, Response
from dhtbot.protocols import krpc_responder, krpc_sender
from dhtbot.protocols.krpc_responder import KRPC_Responder, _TokenGenerator
    def test_ping_Received_sendsValidResponse(self):
        kresponder = self._patched_responder()
        incoming_query = Query()
        incoming_query.rpctype = "ping"
        incoming_query._from = 123
 
        querying_node = contact.Node(123, test_address)
        incoming_query = Query()
        incoming_query.rpctype = "find_node"
        incoming_query._from = querying_node.node_id
 
        querying_node = contact.Node(123, test_address)
        incoming_query = Query()
        incoming_query.rpctype = "find_node"
        incoming_query._from = querying_node.node_id
        # and feeding it into "datagramReceived()"
        querying_node = contact.Node(123, test_address)
        incoming_query = Query()
        incoming_query.rpctype = "get_peers"
        incoming_query._from = querying_node.node_id

src/d/h/DHTBot-HEAD/dhtbot/test/extensions/test_rate_limiter.py   DHTBot(Download)
from dhtbot.coding import krpc_coder
from dhtbot.kademlia.routing_table import TreeRoutingTable
from dhtbot.krpc_types import Query
from dhtbot.protocols.krpc_sender import KRPC_Sender
from dhtbot.test.utils import Clock, Counter, HollowTransport
    def setUp(self):
        TestingBase.setUp(self)
        # Set up a query and address for testing
        self.address = ("127.0.0.1", 55)
        self.query = Query()
 
        self.address = ("127.0.0.1", 55)
        self.query = Query()
        self.query.rpctype = "ping"
        self.query._from = 15

src/d/h/DHTBot-HEAD/dhtbot/test/coding/test_krpc_coder.py   DHTBot(Download)
        InvalidKRPCError)
from dhtbot.coding import basic_coder
from dhtbot.krpc_types import Query, Response, Error
from dhtbot.contact import Node
 
    def setUp(self):
        q = self.q = Query()
        q._transaction_id = 15
        q._from = 2**120