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

All Samples(11)  |  Call(10)  |  Derive(0)  |  Import(1)

src/d/h/DHTBot-HEAD/dhtbot/coding/krpc_coder.py   DHTBot(Download)
def _query_encoder(query):
    """@see encode"""
    query_dict = {"q": query.rpctype,
                  "a": { "id": basic_coder.encode_network_id(query._from)}}
    # Perform specific rpc encoding
    if query.rpctype == 'ping':
        pass
    elif query.rpctype == 'find_node':
        query_dict['a']['target'] = (
                basic_coder.encode_network_id(query.target_id))
    elif query.rpctype == 'get_peers':
        query_dict['a']['info_hash'] = (
                basic_coder.encode_network_id(query.target_id))
    elif query.rpctype == 'announce_peer':
        query_dict['a']['token'] = basic_coder.ltob(query.token)
        # Try encoding the port, to see if it is within range
        basic_coder.encode_port(query.port)
        query_dict['a']['port'] = query.port
        query_dict['a']['info_hash'] = (
                basic_coder.encode_network_id(query.target_id))
def _response_encoder(response):
    """@see encode"""
    resp_dict = {"r": {"id": basic_coder.encode_network_id(response._from)}}
    if response.nodes is not None:
        encoded_nodes = [contact.encode_node(node) for node in response.nodes]

src/d/h/DHTBot-HEAD/dhtbot/contact.py   DHTBot(Download)
    def __init__(self, node_id, address):
        # Verify the node_id and address are in the proper format
        basic_coder.encode_address(address)
        basic_coder.encode_network_id(node_id)
        # Network information
 
    """
    return "%s%s" % (basic_coder.encode_network_id(node.node_id),
                     basic_coder.encode_address(node.address))
 

src/d/h/DHTBot-HEAD/dhtbot/protocols/krpc_responder.py   DHTBot(Download)
    def __init__(self, routing_table_class=TreeRoutingTable, node_id=None):
        node_id = (node_id if node_id is not None
                           else random.getrandbits(160))
        # Verify the node_id is valid
        basic_coder.encode_network_id(node_id)
        # the querier, and a secret that changes every
        # constants._secret_timeout seconds
        hash.update(basic_coder.encode_network_id(node_id))
        hash.update(basic_coder.encode_network_id(infohash))
        hash.update(basic_coder.encode_address(address))

src/d/h/DHTBot-HEAD/dhtbot/test/coding/test_basic_coder.py   DHTBot(Download)
from twisted.trial import unittest
 
# Functions being tested
from dhtbot.coding.basic_coder import (ltob, btol, encode_address,
        decode_address, encode_port, decode_port, encode_network_id,