Prevent the use of an invalid unique_id from throwing an exception

during get_torrent_state().
This commit is contained in:
Andrew Resch 2008-01-18 03:40:38 +00:00
parent 1c3c5b76b0
commit 8fadfb8254
1 changed files with 12 additions and 10 deletions

View File

@ -465,18 +465,20 @@ class Manager:
def get_torrent_state(self, unique_ID): def get_torrent_state(self, unique_ID):
# Check to see if unique_ID exists: # Check to see if unique_ID exists:
if unique_ID not in self.unique_IDs: if unique_ID not in self.unique_IDs:
raise InvalidUniqueIDError(_("Asked for a torrent that doesn't exist")) print "Asked for a torrent that doesn't exist"
return
ret = self.get_core_torrent_state(unique_ID).copy() try:
ret = self.get_core_torrent_state(unique_ID).copy()
# Add the deluge-level things to the deluge_core data # Add the deluge-level things to the deluge_core data
ret.update(self.get_supp_torrent_state(unique_ID)) ret.update(self.get_supp_torrent_state(unique_ID))
# Get queue position # Get queue position
torrent = self.unique_IDs[unique_ID] torrent = self.unique_IDs[unique_ID]
ret['queue_pos'] = self.state.queue.index(torrent) + 1 ret['queue_pos'] = self.state.queue.index(torrent) + 1
return ret
return ret except:
return None
def get_torrent_peer_info(self, unique_ID): def get_torrent_peer_info(self, unique_ID):
# Perhaps at some time we may add info here # Perhaps at some time we may add info here