コード例 #1
0
 def __init__(self, config, doneflag, errorfunc, listen_fail_ok=False):
     self.config = dict(config)
     self.errorfunc = errorfunc
     self.rawserver = RawServer(doneflag, config, errorfunc=errorfunc,
                                tos=config['peer_socket_tos'])
     self.singleport_listener = SingleportListener(self.rawserver)
     self._find_port(listen_fail_ok)
     self.filepool = FilePool(config['max_files_open'])
     self.ratelimiter = RateLimiter(self.rawserver.add_task)
     self.ratelimiter.set_parameters(config['max_upload_rate'],
                                     config['upload_unit_size'])
     set_filesystem_encoding(config['filesystem_encoding'],
                                              errorfunc)
コード例 #2
0
                    del self.times[key]
                    del self.downloads[key]
                    del self.seedcount[key]
        self.rawserver.add_task(self.expire_downloaders, self.timeout_downloaders_interval)

def track(args):
    if len(args) == 0:
        print formatDefinitions(defaults, 80)
        return
    try:
        config, files = parseargs(args, defaults, 0, 0)
    except ValueError, e:
        print 'error: ' + str(e)
        print 'run with no arguments for parameter explanations'
        return
    r = RawServer(Event(), config['timeout_check_interval'],
                  config['socket_timeout'], bindaddr = config['bind'])
    t = Tracker(config, r)
    s = r.create_serversocket(config['port'], config['bind'], True)
    r.start_listening(s, HTTPHandler(t.get, config['min_time_between_log_flushes']))
    r.listen_forever()
    t.save_dfile()
    print '# Shutting down: ' + isotime()

def size_format(s):
    if (s < 1024):
        r = str(s) + 'B'
    elif (s < 1048576):
        r = str(int(s/1024)) + 'KiB'
    elif (s < 1073741824):
        r = str(int(s/1048576)) + 'MiB'
    elif (s < 1099511627776):
コード例 #3
0
 def create_socket_inet(self):
     try:
         controlsocket = RawServer.create_serversocket(56881,
                                                '127.0.0.1', reuse=True)
     except socket.error, e:
         raise BTFailure("Could not create control socket: "+str(e))
コード例 #4
0
                    del self.seedcount[key]
        self.rawserver.add_task(self.expire_downloaders,
                                self.timeout_downloaders_interval)


def track(args):
    if len(args) == 0:
        print formatDefinitions(defaults, 80)
        return
    try:
        config, files = parseargs(args, defaults, 0, 0)
    except ValueError, e:
        print 'error: ' + str(e)
        print 'run with no arguments for parameter explanations'
        return
    r = RawServer(Event(), config)
    t = Tracker(config, r)
    s = r.create_serversocket(config['port'], config['bind'], True)
    r.start_listening(
        s, HTTPHandler(t.get, config['min_time_between_log_flushes']))
    r.listen_forever()
    t.save_dfile()
    print '# Shutting down: ' + isotime()


def size_format(s):
    if (s < 1024):
        r = str(s) + 'B'
    elif (s < 1048576):
        r = str(int(s / 1024)) + 'KiB'
    elif (s < 1073741824):
コード例 #5
0
ファイル: track.py プロジェクト: nobyte99/bittorrent
        self.rawserver.add_task(self.expire_downloaders,
                                self.timeout_downloaders_interval)


def track(args):
    if len(args) == 0:
        print formatDefinitions(defaults, 80)
        return
    try:
        config, files = parseargs(args, defaults, 0, 0)
    except ValueError, e:
        print 'error: ' + str(e)
        print 'run with no arguments for parameter explanations'
        return
    r = RawServer(Event(),
                  config['timeout_check_interval'],
                  config['socket_timeout'],
                  bindaddr=config['bind'])
    t = Tracker(config, r)
    s = r.create_serversocket(config['port'], config['bind'], True)
    r.start_listening(
        s, HTTPHandler(t.get, config['min_time_between_log_flushes']))
    r.listen_forever()
    t.save_dfile()
    print '# Shutting down: ' + isotime()


def size_format(s):
    if (s < 1024):
        r = str(s) + 'B'
    elif (s < 1048576):
        r = str(int(s / 1024)) + 'KiB'