mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-11 19:08:40 +00:00
Add some more error checking.
This commit is contained in:
parent
38312177ef
commit
f5a00e8d58
4 changed files with 21 additions and 5 deletions
|
@ -157,7 +157,14 @@ class Core(dbus.service.Object):
|
||||||
for key in keys:
|
for key in keys:
|
||||||
nkeys.append(str(key))
|
nkeys.append(str(key))
|
||||||
# Pickle the status dictionary from the torrent
|
# Pickle the status dictionary from the torrent
|
||||||
|
try:
|
||||||
status = self.torrents[torrent_id].get_status(nkeys)
|
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
|
# Get the leftover fields and ask the plugin manager to fill them
|
||||||
leftover_fields = list(set(nkeys) - set(status.keys()))
|
leftover_fields = list(set(nkeys) - set(status.keys()))
|
||||||
if len(leftover_fields) > 0:
|
if len(leftover_fields) > 0:
|
||||||
|
|
|
@ -78,7 +78,10 @@ class Core(dbus.service.Object):
|
||||||
|
|
||||||
## Status field function ##
|
## Status field function ##
|
||||||
def status_field_queue(self, torrent_id):
|
def status_field_queue(self, torrent_id):
|
||||||
|
try:
|
||||||
return self.queue[torrent_id]+1
|
return self.queue[torrent_id]+1
|
||||||
|
except TypeError:
|
||||||
|
return None
|
||||||
|
|
||||||
## Queueing functions ##
|
## Queueing functions ##
|
||||||
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge.Queue",
|
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge.Queue",
|
||||||
|
|
|
@ -44,7 +44,10 @@ class TorrentQueue:
|
||||||
|
|
||||||
def __getitem__(self, torrent_id):
|
def __getitem__(self, torrent_id):
|
||||||
"""Return the queue position of the torrent_id"""
|
"""Return the queue position of the torrent_id"""
|
||||||
|
try:
|
||||||
return self.queue.index(torrent_id)
|
return self.queue.index(torrent_id)
|
||||||
|
except ValueError:
|
||||||
|
return None
|
||||||
|
|
||||||
def load_state(self):
|
def load_state(self):
|
||||||
"""Load the queue state"""
|
"""Load the queue state"""
|
||||||
|
|
|
@ -199,8 +199,11 @@ class TorrentView(listview.ListView):
|
||||||
def get_selected_torrents(self):
|
def get_selected_torrents(self):
|
||||||
"""Returns a list of selected torrents or None"""
|
"""Returns a list of selected torrents or None"""
|
||||||
torrent_ids = []
|
torrent_ids = []
|
||||||
|
try:
|
||||||
paths = self.treeview.get_selection().get_selected_rows()[1]
|
paths = self.treeview.get_selection().get_selected_rows()[1]
|
||||||
|
except AttributeError:
|
||||||
|
# paths is likely None .. so lets return None
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
for path in paths:
|
for path in paths:
|
||||||
torrent_ids.append(
|
torrent_ids.append(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue