[Core] Decorate methods deprecated

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

View File

@ -29,6 +29,7 @@ from deluge._libtorrent import lt
from deluge.common import decode_string, utf8_encoded
from deluge.configmanager import ConfigManager, get_config_dir
from deluge.core.authmanager import AUTH_LEVEL_ADMIN
from deluge.decorators import deprecated
from deluge.event import TorrentFolderRenamedEvent, TorrentStateChangedEvent, TorrentTrackerStatusEvent
log = logging.getLogger(__name__)
@ -361,8 +362,9 @@ class Torrent(object):
value = int(m_down_speed * 1024)
self.handle.set_download_limit(value)
@deprecated
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)
def set_prioritize_first_last_pieces(self, prioritize):
@ -517,8 +519,9 @@ class Torrent(object):
if 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):
"""Deprecated, use set_download_location."""
"""Deprecated: Use set_download_location."""
self.set_download_location(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_speed': lambda: self.options['max_upload_speed'],
'message': lambda: self.statusmsg,
'move_on_completed_path': lambda: self.options['move_completed_path'], # Depr, use move_completed_path
'move_on_completed': lambda: self.options['move_completed'], # Deprecated, use move_completed
'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_completed_path': lambda: self.options['move_completed_path'],
'move_completed': lambda: self.options['move_completed'],
'next_announce': lambda: self.status.next_announce.seconds,
@ -1008,7 +1011,7 @@ class Torrent(object):
'progress': self.get_progress,
'shared': lambda: self.options['shared'],
'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'],
'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),

View File

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