def announce(self, event=3, callback=lambda: None, specialurl=None): if specialurl is not None: s = self.url + '&uploaded=0&downloaded=0&left=1' # don't add to statistics if self.howmany() >= self.maxpeers: s += '&numwant=0' else: s += '&no_peer_id=1&compact=1' self.last_failed = True # force true, so will display an error self.special = specialurl self.rerequest(s, callback) return else: s = ('%s&uploaded=%s&downloaded=%s&left=%s' % (self.url, str(self.up()), str( self.down()), str(self.amount_left()))) if self.last is not None: s += '&last=' + quote(str(self.last)) if self.trackerid is not None: s += '&trackerid=' + quote(str(self.trackerid)) if self.howmany() >= self.maxpeers: s += '&numwant=0' else: s += '&no_peer_id=1&compact=1' if event != 3: s += '&event=' + ['started', 'completed', 'stopped'][event] if event == 2: self.stopped = True self.rerequest(s, callback)
def announce(self, event = 3, callback = lambda: None, specialurl = None): if specialurl is not None: s = self.url+'&uploaded=0&downloaded=0&left=1' # don't add to statistics if self.howmany() >= self.maxpeers: s += '&numwant=0' else: s += '&no_peer_id=1&compact=1' self.last_failed = True # force true, so will display an error self.special = specialurl self.rerequest(s, callback) return else: s = ('%s&uploaded=%s&downloaded=%s&left=%s' % (self.url, str(self.up()), str(self.down()), str(self.amount_left()))) if self.last is not None: s += '&last=' + quote(str(self.last)) if self.trackerid is not None: s += '&trackerid=' + quote(str(self.trackerid)) if self.howmany() >= self.maxpeers: s += '&numwant=0' else: s += '&no_peer_id=1&compact=1' if event != 3: s += '&event=' + ['started', 'completed', 'stopped'][event] if event == 2: self.stopped = True self.rerequest(s, callback)
def __init__(self, trackerlist, interval, sched, howmany, minpeers, connect, externalsched, amount_left, up, down, port, ip, myid, infohash, timeout, errorfunc, excfunc, maxpeers, doneflag, upratefunc, downratefunc, unpauseflag = fakeflag(True), seed_id = '', seededfunc = None, force_rapid_update = False ): self.excfunc = excfunc newtrackerlist = [] for tier in trackerlist: if len(tier)>1: shuffle(tier) newtrackerlist += [tier] self.trackerlist = newtrackerlist self.lastsuccessful = '' self.rejectedmessage = 'rejected by tracker - ' self.url = ('?info_hash=%s&peer_id=%s&port=%s' % (quote(infohash), quote(myid), str(port))) self.ip = ip self.interval = interval self.last = None self.trackerid = None self.announce_interval = 30 * 60 self.sched = sched self.howmany = howmany self.minpeers = minpeers self.connect = connect self.externalsched = externalsched self.amount_left = amount_left self.up = up self.down = down self.timeout = timeout self.errorfunc = errorfunc self.maxpeers = maxpeers self.doneflag = doneflag self.upratefunc = upratefunc self.downratefunc = downratefunc self.unpauseflag = unpauseflag if seed_id: self.url += '&seed_id='+quote(seed_id) self.seededfunc = seededfunc if seededfunc: self.url += '&check_seeded=1' self.force_rapid_update = force_rapid_update self.last_failed = True self.never_succeeded = True self.errorcodes = {} self.lock = SuccessLock() self.special = None self.stopped = False
def __init__(self, trackerlist, interval, sched, howmany, minpeers, connect, externalsched, amount_left, up, down, port, ip, myid, infohash, timeout, errorfunc, excfunc, maxpeers, doneflag, upratefunc, downratefunc, unpauseflag=fakeflag(True), seed_id='', seededfunc=None, force_rapid_update=False): self.excfunc = excfunc newtrackerlist = [] for tier in trackerlist: if len(tier) > 1: shuffle(tier) newtrackerlist += [tier] self.trackerlist = newtrackerlist self.lastsuccessful = '' self.rejectedmessage = 'rejected by tracker - ' self.url = ('?info_hash=%s&peer_id=%s&port=%s' % (quote(infohash), quote(myid), str(port))) self.ip = ip self.interval = interval self.last = None self.trackerid = None self.announce_interval = 30 * 60 self.sched = sched self.howmany = howmany self.minpeers = minpeers self.connect = connect self.externalsched = externalsched self.amount_left = amount_left self.up = up self.down = down self.timeout = timeout self.errorfunc = errorfunc self.maxpeers = maxpeers self.doneflag = doneflag self.upratefunc = upratefunc self.downratefunc = downratefunc self.unpauseflag = unpauseflag if seed_id: self.url += '&seed_id=' + quote(seed_id) self.seededfunc = seededfunc if seededfunc: self.url += '&check_seeded=1' self.force_rapid_update = force_rapid_update self.last_failed = True self.never_succeeded = True self.errorcodes = {} self.lock = SuccessLock() self.special = None self.stopped = False