[Core] Decorate methods deprecated

This commit is contained in:
Calum Lind 2016-11-08 18:28:36 +00:00
commit 4a9d2d2129
3 changed files with 43 additions and 34 deletions

View file

@ -35,6 +35,7 @@ from deluge.core.pluginmanager import PluginManager
from deluge.core.preferencesmanager import PreferencesManager from deluge.core.preferencesmanager import PreferencesManager
from deluge.core.rpcserver import export from deluge.core.rpcserver import export
from deluge.core.torrentmanager import TorrentManager from deluge.core.torrentmanager import TorrentManager
from deluge.decorators import deprecated
from deluge.error import AddTorrentError, DelugeError, InvalidPathError, InvalidTorrentError from deluge.error import AddTorrentError, DelugeError, InvalidPathError, InvalidTorrentError
from deluge.event import NewVersionAvailableEvent, SessionPausedEvent, SessionResumedEvent, TorrentQueueChangedEvent from deluge.event import NewVersionAvailableEvent, SessionPausedEvent, SessionResumedEvent, TorrentQueueChangedEvent
from deluge.httpdownloader import download_file from deluge.httpdownloader import download_file
@ -572,10 +573,12 @@ class Core(component.Component):
"""Returns the active listen port""" """Returns the active listen port"""
return self.session.listen_port() return self.session.listen_port()
@deprecated
@export @export
def get_i2p_proxy(self): def get_i2p_proxy(self):
"""Returns the active listen port""" """Returns the active listen port"""
i2p_settings = self.session.i2p_proxy() # Deprecated, moved to proxy types # Deprecated: Moved to proxy types
i2p_settings = self.session.i2p_proxy()
i2p_dict = {'hostname': i2p_settings.hostname, 'port': i2p_settings.port} i2p_dict = {'hostname': i2p_settings.hostname, 'port': i2p_settings.port}
return i2p_dict return i2p_dict
@ -640,77 +643,76 @@ class Core(component.Component):
"""Sets a torrents tracker list. trackers will be [{"url", "tier"}]""" """Sets a torrents tracker list. trackers will be [{"url", "tier"}]"""
return self.torrentmanager[torrent_id].set_trackers(trackers) return self.torrentmanager[torrent_id].set_trackers(trackers)
@deprecated
@export @export
def set_torrent_max_connections(self, torrent_id, value): def set_torrent_max_connections(self, torrent_id, value):
# Deprecated method, use set_torrent_options instead """Deprecated: Use set_torrent_options with 'max_connections'"""
"""Sets a torrents max number of connections"""
self.set_torrent_options([torrent_id], {'max_connections': value}) self.set_torrent_options([torrent_id], {'max_connections': value})
@deprecated
@export @export
def set_torrent_max_upload_slots(self, torrent_id, value): def set_torrent_max_upload_slots(self, torrent_id, value):
# Deprecated method, use set_torrent_options instead """Deprecated: Use set_torrent_options with 'max_upload_slots'"""
"""Sets a torrents max number of upload slots"""
self.set_torrent_options([torrent_id], {'max_upload_slots': value}) self.set_torrent_options([torrent_id], {'max_upload_slots': value})
@deprecated
@export @export
def set_torrent_max_upload_speed(self, torrent_id, value): def set_torrent_max_upload_speed(self, torrent_id, value):
# Deprecated method, use set_torrent_options instead """Deprecated: Use set_torrent_options with 'max_upload_speed'"""
"""Sets a torrents max upload speed"""
self.set_torrent_options([torrent_id], {'max_upload_speed': value}) self.set_torrent_options([torrent_id], {'max_upload_speed': value})
@deprecated
@export @export
def set_torrent_max_download_speed(self, torrent_id, value): def set_torrent_max_download_speed(self, torrent_id, value):
# Deprecated method, use set_torrent_options instead """Deprecated: Use set_torrent_options with 'max_download_speed'"""
"""Sets a torrents max download speed"""
self.set_torrent_options([torrent_id], {'max_download_speed': value}) self.set_torrent_options([torrent_id], {'max_download_speed': value})
@deprecated
@export @export
def set_torrent_file_priorities(self, torrent_id, priorities): def set_torrent_file_priorities(self, torrent_id, priorities):
# Deprecated method, use set_torrent_options instead """Deprecated: Use set_torrent_options with 'file_priorities'"""
# Used by at least one 3rd party plugin:
"""Sets a torrents file priorities"""
self.set_torrent_options([torrent_id], {'file_priorities': priorities}) self.set_torrent_options([torrent_id], {'file_priorities': priorities})
@deprecated
@export @export
def set_torrent_prioritize_first_last(self, torrent_id, value): def set_torrent_prioritize_first_last(self, torrent_id, value):
# Deprecated method, use set_torrent_options instead """Deprecated: Use set_torrent_options with 'prioritize_first_last'"""
"""Sets a higher priority to the first and last pieces"""
self.set_torrent_options([torrent_id], {'prioritize_first_last_pieces': value}) self.set_torrent_options([torrent_id], {'prioritize_first_last_pieces': value})
@deprecated
@export @export
def set_torrent_auto_managed(self, torrent_id, value): def set_torrent_auto_managed(self, torrent_id, value):
# Deprecated method, use set_torrent_options instead """Deprecated: Use set_torrent_options with 'auto_managed'"""
"""Sets the auto managed flag for queueing purposes"""
self.set_torrent_options([torrent_id], {'auto_managed': value}) self.set_torrent_options([torrent_id], {'auto_managed': value})
@deprecated
@export @export
def set_torrent_stop_at_ratio(self, torrent_id, value): def set_torrent_stop_at_ratio(self, torrent_id, value):
# Deprecated method, use set_torrent_options instead """Deprecated: Use set_torrent_options with 'stop_at_ratio'"""
"""Sets the torrent to stop at 'stop_ratio'"""
self.set_torrent_options([torrent_id], {'stop_at_ratio': value}) self.set_torrent_options([torrent_id], {'stop_at_ratio': value})
@deprecated
@export @export
def set_torrent_stop_ratio(self, torrent_id, value): def set_torrent_stop_ratio(self, torrent_id, value):
# Deprecated method, use set_torrent_options instead """Deprecated: Use set_torrent_options with 'stop_ratio'"""
"""Sets the ratio when to stop a torrent if 'stop_at_ratio' is set"""
self.set_torrent_options([torrent_id], {'stop_ratio': value}) self.set_torrent_options([torrent_id], {'stop_ratio': value})
@deprecated
@export @export
def set_torrent_remove_at_ratio(self, torrent_id, value): def set_torrent_remove_at_ratio(self, torrent_id, value):
# Deprecated method, use set_torrent_options instead """Deprecated: Use set_torrent_options with 'remove_at_ratio'"""
"""Sets the torrent to be removed at 'stop_ratio'"""
self.set_torrent_options([torrent_id], {'remove_at_ratio': value}) self.set_torrent_options([torrent_id], {'remove_at_ratio': value})
@deprecated
@export @export
def set_torrent_move_completed(self, torrent_id, value): def set_torrent_move_completed(self, torrent_id, value):
# Deprecated method, use set_torrent_options instead """Deprecated: Use set_torrent_options with 'move_completed'"""
"""Sets the torrent to be moved when completed"""
self.set_torrent_options([torrent_id], {'move_completed': value}) self.set_torrent_options([torrent_id], {'move_completed': value})
@deprecated
@export @export
def set_torrent_move_completed_path(self, torrent_id, value): def set_torrent_move_completed_path(self, torrent_id, value):
# Deprecated method, use set_torrent_options instead """Deprecated: Use set_torrent_options with 'move_completed_path'"""
"""Sets the path for the torrent to be moved when completed"""
self.set_torrent_options([torrent_id], {'move_completed_path': value}) self.set_torrent_options([torrent_id], {'move_completed_path': value})
@export @export

View file

@ -29,6 +29,7 @@ from deluge._libtorrent import lt
from deluge.common import decode_string, utf8_encoded from deluge.common import decode_string, utf8_encoded
from deluge.configmanager import ConfigManager, get_config_dir from deluge.configmanager import ConfigManager, get_config_dir
from deluge.core.authmanager import AUTH_LEVEL_ADMIN from deluge.core.authmanager import AUTH_LEVEL_ADMIN
from deluge.decorators import deprecated
from deluge.event import TorrentFolderRenamedEvent, TorrentStateChangedEvent, TorrentTrackerStatusEvent from deluge.event import TorrentFolderRenamedEvent, TorrentStateChangedEvent, TorrentTrackerStatusEvent
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -361,8 +362,9 @@ class Torrent(object):
value = int(m_down_speed * 1024) value = int(m_down_speed * 1024)
self.handle.set_download_limit(value) self.handle.set_download_limit(value)
@deprecated
def set_prioritize_first_last(self, prioritize): def set_prioritize_first_last(self, prioritize):
"""Deprecated due to mismatch between option and func name.""" """Deprecated: Use set_prioritize_first_last_pieces."""
self.set_prioritize_first_last_pieces(prioritize) self.set_prioritize_first_last_pieces(prioritize)
def set_prioritize_first_last_pieces(self, prioritize): def set_prioritize_first_last_pieces(self, prioritize):
@ -517,8 +519,9 @@ class Torrent(object):
if self.options['prioritize_first_last_pieces']: if self.options['prioritize_first_last_pieces']:
self.set_prioritize_first_last_pieces(self.options['prioritize_first_last_pieces']) self.set_prioritize_first_last_pieces(self.options['prioritize_first_last_pieces'])
@deprecated
def set_save_path(self, download_location): def set_save_path(self, download_location):
"""Deprecated, use set_download_location.""" """Deprecated: Use set_download_location."""
self.set_download_location(download_location) self.set_download_location(download_location)
def set_download_location(self, download_location): def set_download_location(self, download_location):
@ -994,8 +997,8 @@ class Torrent(object):
'max_upload_slots': lambda: self.options['max_upload_slots'], 'max_upload_slots': lambda: self.options['max_upload_slots'],
'max_upload_speed': lambda: self.options['max_upload_speed'], 'max_upload_speed': lambda: self.options['max_upload_speed'],
'message': lambda: self.statusmsg, 'message': lambda: self.statusmsg,
'move_on_completed_path': lambda: self.options['move_completed_path'], # Depr, use move_completed_path 'move_on_completed_path': lambda: self.options['move_completed_path'], # Deprecated: move_completed_path
'move_on_completed': lambda: self.options['move_completed'], # Deprecated, use move_completed 'move_on_completed': lambda: self.options['move_completed'], # Deprecated: Use move_completed
'move_completed_path': lambda: self.options['move_completed_path'], 'move_completed_path': lambda: self.options['move_completed_path'],
'move_completed': lambda: self.options['move_completed'], 'move_completed': lambda: self.options['move_completed'],
'next_announce': lambda: self.status.next_announce.seconds, 'next_announce': lambda: self.status.next_announce.seconds,
@ -1008,7 +1011,7 @@ class Torrent(object):
'progress': self.get_progress, 'progress': self.get_progress,
'shared': lambda: self.options['shared'], 'shared': lambda: self.options['shared'],
'remove_at_ratio': lambda: self.options['remove_at_ratio'], 'remove_at_ratio': lambda: self.options['remove_at_ratio'],
'save_path': lambda: self.options['download_location'], # Deprecated, use download_location 'save_path': lambda: self.options['download_location'], # Deprecated: Use download_location
'download_location': lambda: self.options['download_location'], 'download_location': lambda: self.options['download_location'],
'seeds_peers_ratio': lambda: -1.0 if self.status.num_incomplete == 0 else ( # Use -1.0 to signify infinity 'seeds_peers_ratio': lambda: -1.0 if self.status.num_incomplete == 0 else ( # Use -1.0 to signify infinity
self.status.num_complete / self.status.num_incomplete), self.status.num_complete / self.status.num_incomplete),

View file

@ -17,6 +17,7 @@ from twisted.internet.protocol import ClientFactory
import deluge.common import deluge.common
from deluge import error from deluge import error
from deluge.decorators import deprecated
from deluge.transfer import DelugeTransferProtocol from deluge.transfer import DelugeTransferProtocol
from deluge.ui.common import get_localhost_auth from deluge.ui.common import get_localhost_auth
@ -608,12 +609,14 @@ class Client(object):
self._daemon_proxy = None self._daemon_proxy = None
self.__started_standalone = False self.__started_standalone = False
@deprecated
def start_classic_mode(self): def start_classic_mode(self):
"""Deprecated""" """Deprecated: Use start_standalone"""
self.start_standalone() self.start_standalone()
@deprecated
def stop_classic_mode(self): def stop_classic_mode(self):
"""Deprecated""" """Deprecated: Use stop_standalone"""
self.stop_standalone() self.stop_standalone()
def start_daemon(self, port, config): def start_daemon(self, port, config):
@ -671,8 +674,9 @@ class Client(object):
""" """
return self.__started_standalone return self.__started_standalone
@deprecated
def is_classicmode(self): def is_classicmode(self):
"""Deprecated""" """Deprecated: Use is_standalone"""
self.is_standalone() self.is_standalone()
def connected(self): def connected(self):