More removal of lt deprecated params and funcs

Due to a deprecation mistake get_settings() should be used for python
bindings and it will return a dict.
This commit is contained in:
Calum Lind 2014-01-17 18:29:48 +00:00
parent da6d0ba7bf
commit 9e62304852
5 changed files with 33 additions and 36 deletions

View File

@ -89,22 +89,20 @@ class Core(component.Component):
self.__load_session_state() self.__load_session_state()
# Set the user agent # Set the user agent
self.settings = lt.session_settings() settings = self.session.get_settings()
self.settings.user_agent = "Deluge/%(deluge_version)s libtorrent/%(lt_version)s" % { settings["user_agent"] = "Deluge/%(deluge_version)s libtorrent/%(lt_version)s" % {
'deluge_version': deluge.common.get_version(), 'deluge_version': deluge.common.get_version(),
'lt_version': self.get_libtorrent_version().rpartition(".")[0] 'lt_version': self.get_libtorrent_version().rpartition(".")[0]
} }
# Increase the alert queue size so that alerts don't get lost # Increase the alert queue size so that alerts don't get lost
self.settings.alert_queue_size = 10000 settings["alert_queue_size"] = 10000
# Set session settings # Set session settings
self.settings.send_redundant_have = True settings["send_redundant_have"] = True
if deluge.common.windows_check(): if deluge.common.windows_check():
self.settings.disk_io_write_mode = \ settings["disk_io_write_mode"] = lt.io_buffer_mode_t.disable_os_cache
lt.io_buffer_mode_t.disable_os_cache settings["disk_io_read_mode"] = lt.io_buffer_mode_t.disable_os_cache
self.settings.disk_io_read_mode = \ self.session.set_settings(settings)
lt.io_buffer_mode_t.disable_os_cache
self.session.set_settings(self.settings)
self.session.add_extension("metadata_transfer") self.session.add_extension("metadata_transfer")
self.session.add_extension("ut_metadata") self.session.add_extension("ut_metadata")

View File

@ -78,7 +78,7 @@ DEFAULT_PREFS = {
"max_download_speed": -1.0, "max_download_speed": -1.0,
"max_upload_slots_global": 4, "max_upload_slots_global": 4,
"max_half_open_connections": (lambda: deluge.common.windows_check() and "max_half_open_connections": (lambda: deluge.common.windows_check() and
(lambda: deluge.common.vista_check() and 4 or 8)() or 50)(), (lambda: deluge.common.vista_check() and 4 or 8)() or 50)(),
"max_connections_per_second": 20, "max_connections_per_second": 20,
"ignore_limits_on_local_network": True, "ignore_limits_on_local_network": True,
"max_connections_per_torrent": -1, "max_connections_per_torrent": -1,
@ -151,6 +151,7 @@ DEFAULT_PREFS = {
"shared": False "shared": False
} }
class PreferencesManager(component.Component): class PreferencesManager(component.Component):
def __init__(self): def __init__(self):
component.Component.__init__(self, "PreferencesManager") component.Component.__init__(self, "PreferencesManager")
@ -184,8 +185,8 @@ class PreferencesManager(component.Component):
on_set_func(key, value) on_set_func(key, value)
def session_set_setting(self, key, value): def session_set_setting(self, key, value):
settings = self.session.settings() settings = self.session.get_settings()
setattr(settings, key, value) settings[key] = value
self.session.set_settings(settings) self.session.set_settings(settings)
def _on_config_value_change(self, key, value): def _on_config_value_change(self, key, value):
@ -225,8 +226,7 @@ class PreferencesManager(component.Component):
listen_ports = self.config["listen_ports"] listen_ports = self.config["listen_ports"]
# Set the listen ports # Set the listen ports
log.debug("listen port range set to %s-%s", listen_ports[0], log.debug("listen port range set to %s-%s", listen_ports[0], listen_ports[1])
listen_ports[1])
self.session.listen_on( self.session.listen_on(
listen_ports[0], listen_ports[1], listen_ports[0], listen_ports[1],
str(self.config["listen_interface"]) str(self.config["listen_interface"])
@ -313,10 +313,10 @@ class PreferencesManager(component.Component):
set = self.session.get_pe_settings() set = self.session.get_pe_settings()
log.debug("encryption settings:\n\t\t\tout_policy: %s\n\t\t\ log.debug("encryption settings:\n\t\t\tout_policy: %s\n\t\t\
in_policy: %s\n\t\t\tlevel: %s\n\t\t\tprefer_rc4: %s", in_policy: %s\n\t\t\tlevel: %s\n\t\t\tprefer_rc4: %s",
set.out_enc_policy, set.out_enc_policy,
set.in_enc_policy, set.in_enc_policy,
set.allowed_enc_level, set.allowed_enc_level,
set.prefer_rc4) set.prefer_rc4)
def _on_set_max_connections_global(self, key, value): def _on_set_max_connections_global(self, key, value):
log.debug("max_connections_global set to %s..", value) log.debug("max_connections_global set to %s..", value)
@ -392,6 +392,7 @@ class PreferencesManager(component.Component):
def __init__(self, config): def __init__(self, config):
self.config = config self.config = config
threading.Thread.__init__(self) threading.Thread.__init__(self)
def run(self): def run(self):
import time import time
now = time.time() now = time.time()

View File

@ -151,7 +151,7 @@ class Torrent(object):
except RuntimeError: except RuntimeError:
self.torrent_info = None self.torrent_info = None
self.has_metadata = self.handle.has_metadata() self.has_metadata = self.status.has_metadata
self.status_funcs = None self.status_funcs = None
# Default total_uploaded to 0, this may be changed by the state # Default total_uploaded to 0, this may be changed by the state
@ -329,7 +329,7 @@ class Torrent(object):
def set_auto_managed(self, auto_managed): def set_auto_managed(self, auto_managed):
self.options["auto_managed"] = auto_managed self.options["auto_managed"] = auto_managed
if not (self.handle.is_paused() and not self.handle.is_auto_managed()): if not (self.status.paused and not self.status.auto_managed):
self.handle.auto_managed(auto_managed) self.handle.auto_managed(auto_managed)
self.update_state() self.update_state()
@ -444,8 +444,6 @@ class Torrent(object):
self.state = str(ltstate) self.state = str(ltstate)
session_is_paused = component.get("Core").session.is_paused() session_is_paused = component.get("Core").session.is_paused()
is_auto_managed = self.handle.is_auto_managed()
handle_is_paused = self.handle.is_paused()
if log.isEnabledFor(logging.DEBUG): if log.isEnabledFor(logging.DEBUG):
log.debug("set_state_based_on_ltstate: %s", deluge.common.LT_TORRENT_STATE[ltstate]) log.debug("set_state_based_on_ltstate: %s", deluge.common.LT_TORRENT_STATE[ltstate])
@ -457,12 +455,12 @@ class Torrent(object):
# This is an error'd torrent # This is an error'd torrent
self.state = "Error" self.state = "Error"
self.set_status_message(status.error) self.set_status_message(status.error)
if handle_is_paused: if status.paused:
self.handle.auto_managed(False) self.handle.auto_managed(False)
return return
if ltstate == LTSTATE["Queued"] or ltstate == LTSTATE["Checking"]: if ltstate == LTSTATE["Queued"] or ltstate == LTSTATE["Checking"]:
if handle_is_paused: if status.paused:
self.state = "Paused" self.state = "Paused"
else: else:
self.state = "Checking" self.state = "Checking"
@ -474,9 +472,9 @@ class Torrent(object):
elif ltstate == LTSTATE["Allocating"]: elif ltstate == LTSTATE["Allocating"]:
self.state = "Allocating" self.state = "Allocating"
if not session_is_paused and handle_is_paused and is_auto_managed: if not session_is_paused and status.paused and status.auto_managed:
self.state = "Queued" self.state = "Queued"
elif session_is_paused or (handle_is_paused and not is_auto_managed): elif session_is_paused or (status.paused and not status.auto_managed):
self.state = "Paused" self.state = "Paused"
def set_state(self, state): def set_state(self, state):
@ -743,7 +741,7 @@ class Torrent(object):
"eta": self.get_eta, "eta": self.get_eta,
"file_progress": self.get_file_progress, # Adjust progress to be 0-100 value "file_progress": self.get_file_progress, # Adjust progress to be 0-100 value
"files": self.get_files, "files": self.get_files,
"is_seed": self.handle.is_seed, "is_seed": lambda: self.status.is_seeding,
"peers": self.get_peers, "peers": self.get_peers,
"queue": self.handle.queue_position, "queue": self.handle.queue_position,
"ratio": self.get_ratio, "ratio": self.get_ratio,
@ -776,7 +774,7 @@ class Torrent(object):
"""Pause this torrent""" """Pause this torrent"""
# Turn off auto-management so the torrent will not be unpaused by lt queueing # Turn off auto-management so the torrent will not be unpaused by lt queueing
self.handle.auto_managed(False) self.handle.auto_managed(False)
if self.handle.is_paused(): if self.status.paused:
# This torrent was probably paused due to being auto managed by lt # This torrent was probably paused due to being auto managed by lt
# Since we turned auto_managed off, we should update the state which should # Since we turned auto_managed off, we should update the state which should
# show it as 'Paused'. We need to emit a torrent_paused signal because # show it as 'Paused'. We need to emit a torrent_paused signal because
@ -795,14 +793,14 @@ class Torrent(object):
def resume(self): def resume(self):
"""Resumes this torrent""" """Resumes this torrent"""
if self.handle.is_paused() and self.handle.is_auto_managed(): if self.status.paused and self.status.auto_managed:
log.debug("Torrent is being auto-managed, cannot resume!") log.debug("Torrent is being auto-managed, cannot resume!")
return return
else: else:
# Reset the status message just in case of resuming an Error'd torrent # Reset the status message just in case of resuming an Error'd torrent
self.set_status_message("OK") self.set_status_message("OK")
if self.handle.is_finished(): if self.status.is_finished:
# If the torrent has already reached it's 'stop_seed_ratio' then do not do anything # If the torrent has already reached it's 'stop_seed_ratio' then do not do anything
if self.options["stop_at_ratio"]: if self.options["stop_at_ratio"]:
if self.get_ratio() >= self.options["stop_ratio"]: if self.get_ratio() >= self.options["stop_ratio"]:
@ -916,7 +914,7 @@ class Torrent(object):
def force_recheck(self): def force_recheck(self):
"""Forces a recheck of the torrents pieces""" """Forces a recheck of the torrents pieces"""
paused = self.handle.is_paused() paused = self.status.paused
try: try:
self.handle.force_recheck() self.handle.force_recheck()
self.handle.resume() self.handle.resume()

View File

@ -281,7 +281,7 @@ class TorrentManager(component.Component):
if torrent.options["remove_at_ratio"]: if torrent.options["remove_at_ratio"]:
self.remove(torrent_id) self.remove(torrent_id)
break break
if not torrent.handle.is_paused(): if not torrent.handle.status().paused:
torrent.pause() torrent.pause()
def __getitem__(self, torrent_id): def __getitem__(self, torrent_id):

View File

@ -148,10 +148,10 @@ class Core(CorePluginBase):
session = component.get("Core").session session = component.get("Core").session
session.set_download_rate_limit(int(self.config["low_down"] * 1024)) session.set_download_rate_limit(int(self.config["low_down"] * 1024))
session.set_upload_rate_limit(int(self.config["low_up"] * 1024)) session.set_upload_rate_limit(int(self.config["low_up"] * 1024))
settings = session.settings() settings = session.get_settings()
settings.active_limit = self.config["low_active"] settings["active_limit"] = self.config["low_active"]
settings.active_downloads = self.config["low_active_down"] settings["active_downloads"] = self.config["low_active_down"]
settings.active_seeds = self.config["low_active_up"] settings["active_seeds"] = self.config["low_active_up"]
session.set_settings(settings) session.set_settings(settings)
# Resume the session if necessary # Resume the session if necessary
component.get("Core").session.resume() component.get("Core").session.resume()