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

@ -245,11 +245,19 @@ class Torrent:
except UnicodeDecodeError: except UnicodeDecodeError:
client = str(peer.client).decode("latin-1") 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({ ret.append({
"ip": "%s:%s" % (peer.ip[0], peer.ip[1]), "ip": "%s:%s" % (peer.ip[0], peer.ip[1]),
"up_speed": peer.up_speed, "up_speed": peer.up_speed,
"down_speed": peer.down_speed, "down_speed": peer.down_speed,
"country": deluge.xmlrpclib.Binary(peer.country), "country": country,
"client": client, "client": client,
"seed": peer.flags & peer.seed "seed": peer.flags & peer.seed
}) })

View File

@ -217,8 +217,7 @@ class PeersTab:
client.get_torrent_status(self._on_get_torrent_status, torrent_id, ["peers"]) client.get_torrent_status(self._on_get_torrent_status, torrent_id, ["peers"])
def get_flag_pixbuf(self, country): def get_flag_pixbuf(self, country):
country = str(country) if country == " ":
if not country.isalpha():
return None return None
if not self.cached_flag_pixbufs.has_key(country): if not self.cached_flag_pixbufs.has_key(country):
@ -266,6 +265,7 @@ class PeersTab:
# Create an int IP address for sorting purposes # Create an int IP address for sorting purposes
ip_int = sum([int(byte) << shift ip_int = sum([int(byte) << shift
for byte, shift in izip(peer["ip"].split(":")[0].split("."), (24, 16, 8, 0))]) for byte, shift in izip(peer["ip"].split(":")[0].split("."), (24, 16, 8, 0))])
if peer["seed"]: if peer["seed"]:
icon = self.seed_pixbuf icon = self.seed_pixbuf
else: else: