try to fix #89, by assuming name,tracker,tracker_status could be non-unicode

This commit is contained in:
Martijn Voncken 2008-03-24 08:22:26 +00:00
parent adf36fac1d
commit 3857a564a1
1 changed files with 4 additions and 3 deletions

View File

@ -91,7 +91,7 @@ class DbusManager(dbus.service.Object):
torrent = self.core.unique_IDs[torrent_id] torrent = self.core.unique_IDs[torrent_id]
status = { status = {
"name": state["name"], "name": state["name"].decode('utf-8','ignore'),
"total_size": state["total_size"], "total_size": state["total_size"],
"num_pieces": state["num_pieces"], "num_pieces": state["num_pieces"],
"state": state['state'], "state": state['state'],
@ -109,15 +109,16 @@ class DbusManager(dbus.service.Object):
"eta": common.estimate_eta(state), "eta": common.estimate_eta(state),
"ratio": self.interface.manager.calc_ratio(torrent_id,state), "ratio": self.interface.manager.calc_ratio(torrent_id,state),
#non 0.6 values follow here: #non 0.6 values follow here:
"tracker_status": state.get("tracker_status","?"), "tracker_status": state.get("tracker_status","?").decode('utf-8','ignore'),
"uploaded_memory": torrent.uploaded_memory, "uploaded_memory": torrent.uploaded_memory,
"tracker":state["tracker"].decode('utf-8','ignore')
} }
#more non 0.6 values #more non 0.6 values
for key in ["total_seeds", "total_peers","is_seed", "total_done", for key in ["total_seeds", "total_peers","is_seed", "total_done",
"total_download", "total_upload" "total_download", "total_upload"
#, "download_rate","upload_rate" #, "download_rate","upload_rate"
, "num_files", "piece_length", "distributed_copies" , "num_files", "piece_length", "distributed_copies"
,"next_announce","tracker","queue_pos"]: ,"next_announce","queue_pos"]:
status[key] = state[key] status[key] = state[key]
#print 'all_keys:',sorted(status.keys()) #print 'all_keys:',sorted(status.keys())