All pastes #898778 Raw Edit

Stuff

public diff v1 · immutable
·published 2008-02-10 16:35 UTC
rendered paste body
Index: deluge/core/torrentmanager.py===================================================================--- deluge/core/torrentmanager.py	(revision 2758)+++ deluge/core/torrentmanager.py	(working copy)@@ -46,6 +46,7 @@ from deluge.configmanager import ConfigManager from deluge.core.torrent import Torrent from deluge.log import LOG as log+import deluge.error  class TorrentState:     def __init__(self, torrent_id, filename, compact, paused, save_path,@@ -125,6 +126,9 @@                              def __getitem__(self, torrent_id):         """Return the Torrent with torrent_id"""+        if torrent_id not in self.torrents:+            log.debug("torrent_id '%s' doesn't exist.", torrent_id)+            raise deluge.error.InvalidTorrent("Invalid torrent id")         return self.torrents[torrent_id]          def get_torrent_list(self):@@ -291,7 +295,7 @@                 option = 1             self.session.remove_torrent(self.torrents[torrent_id].handle,                  option)-        except (RuntimeError, KeyError), e:+        except (RuntimeError), e:             log.warning("Error removing torrent: %s", e)             return False             @@ -311,7 +315,7 @@         # Remove the torrent from deluge's session         try:             del self.torrents[torrent_id]-        except KeyError, ValueError:+        except ValueError:             return False                      # Save the session state@@ -356,7 +360,7 @@         # We start by removing it from the lt session                     try:             self.session.remove_torrent(torrent.handle, 0)-        except (RuntimeError, KeyError), e:+        except (RuntimeError), e:             log.warning("Error removing torrent: %s", e)             return False @@ -481,11 +485,8 @@         # Get the torrent_id         torrent_id = str(alert.handle.info_hash())         # Set the tracker status for the torrent-        try:-            if alert.msg != "Got peers from DHT":-                self.torrents[torrent_id].set_tracker_status(_("Announce OK"))-        except KeyError:-            log.debug("torrent_id doesn't exist.")+        if alert.msg != "Got peers from DHT":+            self.torrents[torrent_id].set_tracker_status(_("Announce OK"))                  # Check to see if we got any peer information from the tracker         if alert.handle.status().num_complete == -1 or \@@ -498,10 +499,7 @@         # Get the torrent_id         torrent_id = str(alert.handle.info_hash())         # Set the tracker status for the torrent-        try:-            self.torrents[torrent_id].set_tracker_status(_("Announce Sent"))-        except KeyError:-            log.debug("torrent_id doesn't exist.")+        self.torrents[torrent_id].set_tracker_status(_("Announce Sent"))      def on_alert_tracker(self, alert):         log.debug("on_alert_tracker")@@ -510,10 +508,7 @@         tracker_status = "%s: %s" % \             (_("Alert"), str(alert.msg()).strip('"')[8:])         # Set the tracker status for the torrent-        try:-            self.torrents[torrent_id].set_tracker_status(tracker_status)-        except KeyError:-            log.debug("torrent_id doesn't exist.")+        self.torrents[torrent_id].set_tracker_status(tracker_status)                      def on_alert_tracker_warning(self, alert):         log.debug("on_alert_tracker_warning")@@ -521,17 +516,11 @@         torrent_id = str(alert.handle.info_hash())         tracker_status = '%s: %s' % (_("Warning"), str(alert.msg()))         # Set the tracker status for the torrent-        try:-            self.torrents[torrent_id].set_tracker_status(tracker_status)-        except KeyError:-            log.debug("torrent_id doesn't exist.")+        self.torrents[torrent_id].set_tracker_status(tracker_status)                  def on_alert_storage_moved(self, alert):         log.debug("on_alert_storage_moved")         # Get the torrent_id         torrent_id = str(alert.handle.info_hash())-        try:-            self.torrents[torrent_id].set_save_path(alert.handle.save_path())-        except KeyError:-            log.debug("torrent_id doesn't exist.")-                    +        self.torrents[torrent_id].set_save_path(alert.handle.save_path())+Index: deluge/error.py===================================================================--- deluge/error.py	(revision 2758)+++ deluge/error.py	(working copy)@@ -40,3 +40,5 @@ class NoCoreError(DelugeError):     pass     +class InvalidTorrent(DelugeError):+    pass