Add some more error checking.
This commit is contained in:
parent
38312177ef
commit
f5a00e8d58
|
@ -157,7 +157,14 @@ class Core(dbus.service.Object):
|
|||
for key in keys:
|
||||
nkeys.append(str(key))
|
||||
# Pickle the status dictionary from the torrent
|
||||
status = self.torrents[torrent_id].get_status(nkeys)
|
||||
try:
|
||||
status = self.torrents[torrent_id].get_status(nkeys)
|
||||
except KeyError:
|
||||
# The torrent_id is not found in the torrentmanager, so return None
|
||||
status = None
|
||||
status.pickle.dumps(status)
|
||||
return status
|
||||
|
||||
# Get the leftover fields and ask the plugin manager to fill them
|
||||
leftover_fields = list(set(nkeys) - set(status.keys()))
|
||||
if len(leftover_fields) > 0:
|
||||
|
|
|
@ -78,7 +78,10 @@ class Core(dbus.service.Object):
|
|||
|
||||
## Status field function ##
|
||||
def status_field_queue(self, torrent_id):
|
||||
return self.queue[torrent_id]+1
|
||||
try:
|
||||
return self.queue[torrent_id]+1
|
||||
except TypeError:
|
||||
return None
|
||||
|
||||
## Queueing functions ##
|
||||
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge.Queue",
|
||||
|
|
|
@ -44,7 +44,10 @@ class TorrentQueue:
|
|||
|
||||
def __getitem__(self, torrent_id):
|
||||
"""Return the queue position of the torrent_id"""
|
||||
return self.queue.index(torrent_id)
|
||||
try:
|
||||
return self.queue.index(torrent_id)
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
def load_state(self):
|
||||
"""Load the queue state"""
|
||||
|
|
|
@ -199,8 +199,11 @@ class TorrentView(listview.ListView):
|
|||
def get_selected_torrents(self):
|
||||
"""Returns a list of selected torrents or None"""
|
||||
torrent_ids = []
|
||||
paths = self.treeview.get_selection().get_selected_rows()[1]
|
||||
|
||||
try:
|
||||
paths = self.treeview.get_selection().get_selected_rows()[1]
|
||||
except AttributeError:
|
||||
# paths is likely None .. so lets return None
|
||||
return None
|
||||
try:
|
||||
for path in paths:
|
||||
torrent_ids.append(
|
||||
|
|
Loading…
Reference in New Issue