def isLeech(self): # If I don't meet the minimum share, yell and return True osm = self.main.osm minshare = self.main.dcfg.minshare if osm.me.shared < minshare: self.pushStatus( "*** You must share at least %s in order to download! " "(You currently have %s)" % (format_bytes(minshare), format_bytes(osm.me.shared))) return True return False
def handleCmd_RANK(self, out, args, prefix): if not self.dch.isOnline(): out("You must be online to use %sRANK." % prefix) return osm = self.main.osm tie = False rank = 1 target = None if len(args) == 0: target = osm.me elif len(args) == 1: try: target = osm.nkm.lookupNick(args[0]) except KeyError: out("The nick <%s> cannot be located." % args[0]) return else: self.syntaxHelp(out, 'RANK', prefix) return if target is osm.me: who = "You are" else: who = "%s is" % target.nick for n in osm.nkm.nickmap.values(): if n is target: continue if n.shared > target.shared: rank += 1 elif n.shared == target.shared: tie = True try: suffix = {1:'st',2:'nd',3:'rd'}[rank % 10] if 11 <= (rank % 100) <= 13: raise KeyError except KeyError: suffix = 'th' if tie: tie = "tied for" else: tie = "in" out("%s %s %d%s place, with a share size of %s." % (who, tie, rank, suffix, format_bytes(target.shared)) )
def handleCmd_SHARED(self, out, args, prefix): if not self.dch.isOnline(): out("You must be online to use %sSHARED." % prefix) return self.showStats(out, "Bytes Shared", lambda u, b: b, lambda v: "%s" % format_bytes(v), peers_only=True)
def handleCmd_RANK(self, out, args, prefix): if not self.dch.isOnline(): out("You must be online to use %sRANK." % prefix) return osm = self.main.osm tie = False rank = 1 target = None if len(args) == 0: target = osm.me elif len(args) == 1: try: target = osm.nkm.lookupNick(args[0]) except KeyError: out("The nick <%s> cannot be located." % args[0]) return else: self.syntaxHelp(out, 'RANK', prefix) return if target is osm.me: who = "You are" else: who = "%s is" % target.nick for n in osm.nkm.nickmap.values(): if n is target: continue if n.shared > target.shared: rank += 1 elif n.shared == target.shared: tie = True try: suffix = {1: 'st', 2: 'nd', 3: 'rd'}[rank % 10] if 11 <= (rank % 100) <= 13: raise KeyError except KeyError: suffix = 'th' if tie: tie = "tied for" else: tie = "in" out("%s %s %d%s place, with a share size of %s." % (who, tie, rank, suffix, format_bytes(target.shared)))
def handleCmd_SHARED(self, out, args, prefix): if not self.dch.isOnline(): out("You must be online to use %sSHARED." % prefix) return self.showStats( out, "Bytes Shared", lambda u,b: b, lambda v: "%s" % format_bytes(v), peers_only=True )
def handleCmd_DENSE(self, out, args, prefix): if not self.dch.isOnline(): out("You must be online to use %sDENSE." % prefix) return def compute(u, b): try: return (b / u, u) except ZeroDivisionError: return (0, u) self.showStats(out, "Share Density", compute, lambda v: "%s/user (%d)" % (format_bytes(v[0]), v[1]), peers_only=True)
def handleCmd_DENSE(self, out, args, prefix): if not self.dch.isOnline(): out("You must be online to use %sDENSE." % prefix) return def compute(u,b): try: return (b/u, u) except ZeroDivisionError: return (0, u) self.showStats( out, "Share Density", compute, lambda v: "%s/user (%d)" % (format_bytes(v[0]), v[1]), peers_only=True )