This commit is contained in:
Andrew Resch 2008-04-10 05:52:38 +00:00
parent 622a0053d8
commit c012427edc
2 changed files with 14 additions and 6 deletions

View File

@ -244,12 +244,20 @@ class Torrent:
client = str(peer.client).decode("utf-8")
except UnicodeDecodeError:
client = str(peer.client).decode("latin-1")
# Make country a proper string
country = str()
for c in peer.country:
if not c.isalpha():
country += " "
else:
country += c
ret.append({
"ip": "%s:%s" % (peer.ip[0], peer.ip[1]),
"up_speed": peer.up_speed,
"down_speed": peer.down_speed,
"country": deluge.xmlrpclib.Binary(peer.country),
"country": country,
"client": client,
"seed": peer.flags & peer.seed
})

View File

@ -217,10 +217,9 @@ class PeersTab:
client.get_torrent_status(self._on_get_torrent_status, torrent_id, ["peers"])
def get_flag_pixbuf(self, country):
country = str(country)
if not country.isalpha():
if country == " ":
return None
if not self.cached_flag_pixbufs.has_key(country):
# We haven't created a pixbuf for this country yet
try:
@ -266,13 +265,14 @@ class PeersTab:
# Create an int IP address for sorting purposes
ip_int = sum([int(byte) << shift
for byte, shift in izip(peer["ip"].split(":")[0].split("."), (24, 16, 8, 0))])
if peer["seed"]:
icon = self.seed_pixbuf
else:
icon = self.peer_pixbuf
row = self.liststore.append([
self.get_flag_pixbuf(peer["country"]),
self.get_flag_pixbuf(peer["country"]),
peer["ip"],
peer["client"],
peer["down_speed"],