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

All Samples(6)  |  Call(4)  |  Derive(0)  |  Import(2)

        def identify_client(peerid, log=None):
    client = 'unknown'
    version = ''
    for pat, name in matches:
        m = pat.match(peerid)
        if m:
            client = name
            d = m.groupdict()
            if d.has_key('version'):
                version = d['version']
                version = version.replace('-','.')
                if version.find('.') >= 0:
                    version = ''.join(version.split('.'))

                version = list(version)
                for i,c in enumerate(version):
                    if '0' <= c <= '9':
                        version[i] = c
                    elif 'A' <= c <= 'Z':
                        version[i] = str(ord(c) - 55)
                    elif 'a' <= c <= 'z':
                        version[i] = str(ord(c) - 61)
                    elif c == '.':
                        version[i] = '62'
                    elif c == '-':
                        version[i] = '63'
                    else:
                        break
                version = '.'.join(version)
            elif d.has_key('bcver'):
                bcver = d['bcver']
                version += str(ord(bcver[0])) + '.'
                if len(bcver) > 1:
                    version += str(ord(bcver[1])/10)
                    version += str(ord(bcver[1])%10)
            elif d.has_key('rsver'):
                rsver = d['rsver']
                version += str(ord(rsver[0])) + '.'
                if len(rsver) > 1:
                    version += str(ord(rsver[1])/10) + '.'
                    version += str(ord(rsver[1])%10)
            if d.has_key('strver'):
                if d['strver'] is not None:
                    version += d['strver']
            if d.has_key('rc'):
                rc = 'RC ' + d['rc'][1:]
                if version:
                    version += ' '
                version += rc
            break
    if client == 'unknown':
        # identify Shareaza 2.0 - 2.1
        if len(peerid) == 20 and chr(0) not in peerid[:15]:
            for i in range(16,20):
                 if ord(peerid[i]) != (ord(peerid[i - 16]) ^ ord(peerid[31 - i])):
                     break
            else:
                client = "Shareaza"
        
        
    if log is not None and 'unknown' in client:
        if not unknown_clients.has_key(peerid):
            unknown_clients[peerid] = True
            log.write('%s\n'%peerid)
            log.write('------------------------------\n')
    return client, version
        


src/k/a/kamaelia-HEAD/Sketches/RJL/bittorrent/BitTorrent/bittorrent.py   kamaelia(Download)
            field.append(peer['ip']) 
 
            client, version = ClientIdentifier.identify_client(peer['id']) 
            field.append(client + ' ' + version)
 
            field.append(ip)
 
            client, version = ClientIdentifier.identify_client(stats.peerid)
            field.append(client + ' ' + version)
 

src/k/a/kamaelia-HEAD/Sketches/RJL/bittorrent/BitTorrent/BitTorrent/Encoder.py   kamaelia(Download)
from BitTorrent.Connecter import Connection
from BitTorrent.platform import is_frozen_exe
from BitTorrent.ClientIdentifier import identify_client
 
# header, reserved, download id, my id, [length, message]

src/k/a/kamaelia-HEAD/Sketches/RJL/bittorrent/BitTorrent/test/test_ClientIdentifier.py   kamaelia(Download)
def test(peerid):
    client, version = ClientIdentifier.identify_client(peerid)
    try:
        try:
            out = peerid.encode('utf8')
     '-KT11R1-693649213030'),
    ):
        id_client, id_version = ClientIdentifier.identify_client(peerid)
        show = False
        if id_client != client: