mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-07 00:48:41 +00:00
Flake8 codebase
Fixes error E265 and E714 that have been added to newest version of pep8
This commit is contained in:
parent
142e96b246
commit
83262afda1
40 changed files with 214 additions and 200 deletions
|
@ -720,7 +720,7 @@ def decode_string(s, encoding="utf8"):
|
||||||
lambda: (chardet.detect(s)["encoding"], 'strict'),
|
lambda: (chardet.detect(s)["encoding"], 'strict'),
|
||||||
lambda: (encoding, 'ignore')]
|
lambda: (encoding, 'ignore')]
|
||||||
|
|
||||||
if not encoding is "utf8":
|
if encoding is not "utf8":
|
||||||
encodings.insert(0, lambda: (encoding, 'strict'))
|
encodings.insert(0, lambda: (encoding, 'strict'))
|
||||||
|
|
||||||
for l in encodings:
|
for l in encodings:
|
||||||
|
|
|
@ -59,7 +59,7 @@ class Core(component.Component):
|
||||||
# Load the session state if available
|
# Load the session state if available
|
||||||
self.__load_session_state()
|
self.__load_session_state()
|
||||||
|
|
||||||
## Set session settings ##
|
# --- Set session settings ---
|
||||||
settings = self.session.get_settings()
|
settings = self.session.get_settings()
|
||||||
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(),
|
||||||
|
@ -73,7 +73,7 @@ class Core(component.Component):
|
||||||
settings["disk_io_read_mode"] = lt.io_buffer_mode_t.disable_os_cache
|
settings["disk_io_read_mode"] = lt.io_buffer_mode_t.disable_os_cache
|
||||||
self.session.set_settings(settings)
|
self.session.set_settings(settings)
|
||||||
|
|
||||||
## libtorrent plugins ##
|
# --- libtorrent plugins ---
|
||||||
# Allows peers to download the metadata from the swarm directly
|
# Allows peers to download the metadata from the swarm directly
|
||||||
self.session.add_extension("metadata_transfer")
|
self.session.add_extension("metadata_transfer")
|
||||||
self.session.add_extension("ut_metadata")
|
self.session.add_extension("ut_metadata")
|
||||||
|
|
|
@ -167,7 +167,7 @@ class Daemon(object):
|
||||||
Returns:
|
Returns:
|
||||||
bool: True if authorized to call RPC, otherwise False.
|
bool: True if authorized to call RPC, otherwise False.
|
||||||
"""
|
"""
|
||||||
if not rpc in self.get_method_list():
|
if rpc not in self.get_method_list():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return self.rpcserver.get_session_auth_level() >= self.rpcserver.get_rpc_auth_level(rpc)
|
return self.rpcserver.get_session_auth_level() >= self.rpcserver.get_rpc_auth_level(rpc)
|
||||||
|
|
|
@ -30,7 +30,7 @@ class EventManager(component.Component):
|
||||||
# Call any handlers for the event
|
# Call any handlers for the event
|
||||||
if event.name in self.handlers:
|
if event.name in self.handlers:
|
||||||
for handler in self.handlers[event.name]:
|
for handler in self.handlers[event.name]:
|
||||||
#log.debug("Running handler %s for event %s with args: %s", event.name, handler, event.args)
|
# log.debug("Running handler %s for event %s with args: %s", event.name, handler, event.args)
|
||||||
try:
|
try:
|
||||||
handler(*event.args)
|
handler(*event.args)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
|
|
@ -128,7 +128,7 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
|
||||||
log.debug("Received invalid rpc request: number of items "
|
log.debug("Received invalid rpc request: number of items "
|
||||||
"in request is %s", len(call))
|
"in request is %s", len(call))
|
||||||
continue
|
continue
|
||||||
#log.debug("RPCRequest: %s", format_request(call))
|
# log.debug("RPCRequest: %s", format_request(call))
|
||||||
reactor.callLater(0, self.dispatch, *call)
|
reactor.callLater(0, self.dispatch, *call)
|
||||||
|
|
||||||
def sendData(self, data): # NOQA
|
def sendData(self, data): # NOQA
|
||||||
|
|
|
@ -277,7 +277,7 @@ class Torrent(object):
|
||||||
self.set_prioritize_first_last_pieces(True)
|
self.set_prioritize_first_last_pieces(True)
|
||||||
self.write_torrentfile()
|
self.write_torrentfile()
|
||||||
|
|
||||||
## Options methods ##
|
# --- Options methods ---
|
||||||
def set_options(self, options):
|
def set_options(self, options):
|
||||||
"""Set the torrent options.
|
"""Set the torrent options.
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ class Torrent(object):
|
||||||
if self.rpcserver.get_session_auth_level() == AUTH_LEVEL_ADMIN:
|
if self.rpcserver.get_session_auth_level() == AUTH_LEVEL_ADMIN:
|
||||||
self.options["owner"] = account
|
self.options["owner"] = account
|
||||||
|
|
||||||
### End Options methods ###
|
# End Options methods #
|
||||||
|
|
||||||
def set_trackers(self, trackers):
|
def set_trackers(self, trackers):
|
||||||
"""Sets the trackers for this torrent.
|
"""Sets the trackers for this torrent.
|
||||||
|
|
|
@ -886,7 +886,7 @@ class TorrentManager(component.Component):
|
||||||
for key in self.torrents.keys():
|
for key in self.torrents.keys():
|
||||||
self.torrents[key].set_max_download_speed(value)
|
self.torrents[key].set_max_download_speed(value)
|
||||||
|
|
||||||
## Alert handlers ##
|
# --- Alert handlers ---
|
||||||
def on_alert_torrent_finished(self, alert):
|
def on_alert_torrent_finished(self, alert):
|
||||||
"""Alert handler for libtorrent torrent_finished_alert"""
|
"""Alert handler for libtorrent torrent_finished_alert"""
|
||||||
log.debug("on_alert_torrent_finished")
|
log.debug("on_alert_torrent_finished")
|
||||||
|
@ -1244,7 +1244,7 @@ class TorrentManager(component.Component):
|
||||||
|
|
||||||
# Get the torrent status for each torrent_id
|
# Get the torrent status for each torrent_id
|
||||||
for torrent_id in torrent_ids:
|
for torrent_id in torrent_ids:
|
||||||
if not torrent_id in self.torrents:
|
if torrent_id not in self.torrents:
|
||||||
# The torrent_id does not exist in the dict.
|
# The torrent_id does not exist in the dict.
|
||||||
# Could be the clients cache (sessionproxy) isn't up to speed.
|
# Could be the clients cache (sessionproxy) isn't up to speed.
|
||||||
del status_dict[torrent_id]
|
del status_dict[torrent_id]
|
||||||
|
|
|
@ -111,7 +111,7 @@ class Core(CorePluginBase):
|
||||||
def update(self):
|
def update(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
## Exported RPC methods ###
|
# Exported RPC methods #
|
||||||
@export
|
@export
|
||||||
def check_import(self, force=False):
|
def check_import(self, force=False):
|
||||||
"""Imports latest blocklist specified by blocklist url.
|
"""Imports latest blocklist specified by blocklist url.
|
||||||
|
@ -375,7 +375,7 @@ class Core(CorePluginBase):
|
||||||
|
|
||||||
def on_read_ip_range(start, end):
|
def on_read_ip_range(start, end):
|
||||||
"""Add ip range to blocklist"""
|
"""Add ip range to blocklist"""
|
||||||
#~ log.trace("Adding ip range %s - %s to ipfilter as blocked", start, end)
|
# log.trace("Adding ip range %s - %s to ipfilter as blocked", start, end)
|
||||||
self.blocklist.add_rule(start.address, end.address, BLOCK_RANGE)
|
self.blocklist.add_rule(start.address, end.address, BLOCK_RANGE)
|
||||||
self.num_blocked += 1
|
self.num_blocked += 1
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ class Core(CorePluginBase):
|
||||||
log.debug("Importing using reader: %s", self.reader)
|
log.debug("Importing using reader: %s", self.reader)
|
||||||
log.debug("Reader type: %s compression: %s", self.config["list_type"], self.config["list_compression"])
|
log.debug("Reader type: %s compression: %s", self.config["list_type"], self.config["list_compression"])
|
||||||
log.debug("Clearing current ip filtering")
|
log.debug("Clearing current ip filtering")
|
||||||
#~ self.blocklist.add_rule("0.0.0.0", "255.255.255.255", ALLOW_RANGE)
|
# self.blocklist.add_rule("0.0.0.0", "255.255.255.255", ALLOW_RANGE)
|
||||||
d = threads.deferToThread(self.reader(blocklist).read, on_read_ip_range)
|
d = threads.deferToThread(self.reader(blocklist).read, on_read_ip_range)
|
||||||
d.addCallback(on_finish_read).addErrback(on_reader_failure)
|
d.addCallback(on_finish_read).addErrback(on_reader_failure)
|
||||||
|
|
||||||
|
|
|
@ -195,8 +195,8 @@ class GtkUI(GtkPluginBase):
|
||||||
self.whitelist_treeview.set_model(self.whitelist_model)
|
self.whitelist_treeview.set_model(self.whitelist_model)
|
||||||
|
|
||||||
def on_cell_edited(self, cell, path_string, new_text, model):
|
def on_cell_edited(self, cell, path_string, new_text, model):
|
||||||
#~ iter = model.get_iter_from_string(path_string)
|
# iter = model.get_iter_from_string(path_string)
|
||||||
#~ path = model.get_path(iter)[0]
|
# path = model.get_path(iter)[0]
|
||||||
try:
|
try:
|
||||||
ip = common.IP.parse(new_text)
|
ip = common.IP.parse(new_text)
|
||||||
model.set(model.get_iter_from_string(path_string), 0, ip.address)
|
model.set(model.get_iter_from_string(path_string), 0, ip.address)
|
||||||
|
@ -223,7 +223,7 @@ class GtkUI(GtkPluginBase):
|
||||||
selection = treeview.get_selection()
|
selection = treeview.get_selection()
|
||||||
model, iter = selection.get_selected()
|
model, iter = selection.get_selected()
|
||||||
if iter:
|
if iter:
|
||||||
#~ path = model.get_path(iter)[0]
|
# path = model.get_path(iter)[0]
|
||||||
model.remove(iter)
|
model.remove(iter)
|
||||||
|
|
||||||
def populate_whitelist(self, whitelist):
|
def populate_whitelist(self, whitelist):
|
||||||
|
|
|
@ -131,7 +131,7 @@ class Core(CorePluginBase):
|
||||||
event_manager.deregister_event_handler(event, handler)
|
event_manager.deregister_event_handler(event, handler)
|
||||||
log.debug("Execute core plugin disabled!")
|
log.debug("Execute core plugin disabled!")
|
||||||
|
|
||||||
### Exported RPC methods ###
|
# Exported RPC methods #
|
||||||
@export
|
@export
|
||||||
def add_command(self, event, command):
|
def add_command(self, event, command):
|
||||||
command_id = hashlib.sha1(str(time.time())).hexdigest()
|
command_id = hashlib.sha1(str(time.time())).hexdigest()
|
||||||
|
|
|
@ -77,7 +77,7 @@ class Core(CorePluginBase):
|
||||||
self.plugin = component.get("CorePluginManager")
|
self.plugin = component.get("CorePluginManager")
|
||||||
self.plugin.register_status_field("label", self._status_get_label)
|
self.plugin.register_status_field("label", self._status_get_label)
|
||||||
|
|
||||||
#__init__
|
# __init__
|
||||||
core = component.get("Core")
|
core = component.get("Core")
|
||||||
self.config = ConfigManager("label.conf", defaults=CONFIG_DEFAULTS)
|
self.config = ConfigManager("label.conf", defaults=CONFIG_DEFAULTS)
|
||||||
self.core_cfg = ConfigManager("core.conf")
|
self.core_cfg = ConfigManager("core.conf")
|
||||||
|
@ -111,7 +111,7 @@ class Core(CorePluginBase):
|
||||||
filter_dict['All'] = len(self.torrents.keys())
|
filter_dict['All'] = len(self.torrents.keys())
|
||||||
return filter_dict
|
return filter_dict
|
||||||
|
|
||||||
## Plugin hooks ##
|
# Plugin hooks #
|
||||||
def post_torrent_add(self, torrent_id, from_state):
|
def post_torrent_add(self, torrent_id, from_state):
|
||||||
if from_state:
|
if from_state:
|
||||||
return
|
return
|
||||||
|
@ -129,11 +129,11 @@ class Core(CorePluginBase):
|
||||||
if torrent_id in self.torrent_labels:
|
if torrent_id in self.torrent_labels:
|
||||||
del self.torrent_labels[torrent_id]
|
del self.torrent_labels[torrent_id]
|
||||||
|
|
||||||
## Utils ##
|
# Utils #
|
||||||
def clean_config(self):
|
def clean_config(self):
|
||||||
"""remove invalid data from config-file"""
|
"""remove invalid data from config-file"""
|
||||||
for torrent_id, label_id in list(self.torrent_labels.iteritems()):
|
for torrent_id, label_id in list(self.torrent_labels.iteritems()):
|
||||||
if (not label_id in self.labels) or (not torrent_id in self.torrents):
|
if (label_id not in self.labels) or (torrent_id not in self.torrents):
|
||||||
log.debug("label: rm %s:%s" % (torrent_id, label_id))
|
log.debug("label: rm %s:%s" % (torrent_id, label_id))
|
||||||
del self.torrent_labels[torrent_id]
|
del self.torrent_labels[torrent_id]
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ class Core(CorePluginBase):
|
||||||
"""
|
"""
|
||||||
check_input(label_id in self.labels, _("Unknown Label"))
|
check_input(label_id in self.labels, _("Unknown Label"))
|
||||||
for key in options_dict.keys():
|
for key in options_dict.keys():
|
||||||
if not key in OPTIONS_DEFAULTS:
|
if key not in OPTIONS_DEFAULTS:
|
||||||
raise Exception("label: Invalid options_dict key:%s" % key)
|
raise Exception("label: Invalid options_dict key:%s" % key)
|
||||||
|
|
||||||
self.labels[label_id].update(options_dict)
|
self.labels[label_id].update(options_dict)
|
||||||
|
|
|
@ -19,7 +19,7 @@ sclient.set_core_uri()
|
||||||
print(sclient.get_enabled_plugins())
|
print(sclient.get_enabled_plugins())
|
||||||
|
|
||||||
# enable plugin.
|
# enable plugin.
|
||||||
if not "label" in sclient.get_enabled_plugins():
|
if "label" not in sclient.get_enabled_plugins():
|
||||||
sclient.enable_plugin("label")
|
sclient.enable_plugin("label")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -274,10 +274,8 @@ class GtkUI(GtkPluginBase, GtkUiNotifications):
|
||||||
self.glade.get_widget("popup_enabled").set_property('sensitive',
|
self.glade.get_widget("popup_enabled").set_property('sensitive',
|
||||||
False)
|
False)
|
||||||
if not SOUND_AVAILABLE:
|
if not SOUND_AVAILABLE:
|
||||||
# for widget_name in ('sound_enabled', 'sound_path', 'sounds_page',
|
# for widget_name in ('sound_enabled', 'sound_path', 'sounds_page', 'sounds_page_label'):
|
||||||
# 'sounds_page_label'):
|
# self.glade.get_widget(widget_name).set_property('sensitive', False)
|
||||||
# self.glade.get_widget(widget_name).set_property('sensitive',
|
|
||||||
# False)
|
|
||||||
self.glade.get_widget("sound_enabled").set_property('sensitive',
|
self.glade.get_widget("sound_enabled").set_property('sensitive',
|
||||||
False)
|
False)
|
||||||
self.glade.get_widget('sound_path').set_property('sensitive', False)
|
self.glade.get_widget('sound_path').set_property('sensitive', False)
|
||||||
|
|
|
@ -40,7 +40,7 @@ class TestEmailNotifications(component.Component):
|
||||||
log.debug("\n\nEnabling %s", self.__class__.__name__)
|
log.debug("\n\nEnabling %s", self.__class__.__name__)
|
||||||
for event in self.events:
|
for event in self.events:
|
||||||
if self.__imp == 'core':
|
if self.__imp == 'core':
|
||||||
# component.get("CorePlugin.Notifications").register_custom_email_notification(
|
# component.get("CorePlugin.Notifications").register_custom_email_notification(
|
||||||
component.get("Notifications").register_custom_email_notification(
|
component.get("Notifications").register_custom_email_notification(
|
||||||
event.__class__.__name__,
|
event.__class__.__name__,
|
||||||
self.custom_email_message_provider
|
self.custom_email_message_provider
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Core(CorePluginBase):
|
||||||
|
|
||||||
self.length = self.config["length"]
|
self.length = self.config["length"]
|
||||||
|
|
||||||
#self.stats = get_key(self.saved_stats, "stats") or {}
|
# self.stats = get_key(self.saved_stats, "stats") or {}
|
||||||
self.stats_keys = []
|
self.stats_keys = []
|
||||||
self.add_stats(
|
self.add_stats(
|
||||||
'upload_rate',
|
'upload_rate',
|
||||||
|
@ -126,10 +126,10 @@ class Core(CorePluginBase):
|
||||||
stats.update(self.core.get_config_values(["max_download",
|
stats.update(self.core.get_config_values(["max_download",
|
||||||
"max_upload",
|
"max_upload",
|
||||||
"max_num_connections"]))
|
"max_num_connections"]))
|
||||||
# status = self.core.session.status()
|
# status = self.core.session.status()
|
||||||
# for stat in dir(status):
|
# for stat in dir(status):
|
||||||
# if not stat.startswith('_') and stat not in stats:
|
# if not stat.startswith('_') and stat not in stats:
|
||||||
# stats[stat] = getattr(status, stat, None)
|
# stats[stat] = getattr(status, stat, None)
|
||||||
|
|
||||||
update_time = time.time()
|
update_time = time.time()
|
||||||
self.last_update[1] = update_time
|
self.last_update[1] = update_time
|
||||||
|
|
|
@ -94,9 +94,9 @@ class Graph:
|
||||||
self.stats = stats
|
self.stats = stats
|
||||||
return
|
return
|
||||||
|
|
||||||
# def set_config(self, config):
|
# def set_config(self, config):
|
||||||
# self.length = config["length"]
|
# self.length = config["length"]
|
||||||
# self.interval = config["update_interval"]
|
# self.interval = config["update_interval"]
|
||||||
|
|
||||||
def set_interval(self, interval):
|
def set_interval(self, interval):
|
||||||
self.interval = interval
|
self.interval = interval
|
||||||
|
@ -127,7 +127,7 @@ class Graph:
|
||||||
x_step = step
|
x_step = step
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# if there wasnt anything useful find a nice fitting hourly divisor
|
# If there wasnt anything useful find a nice fitting hourly divisor
|
||||||
x_step = ((duration / 5) / 3600) * 3600
|
x_step = ((duration / 5) / 3600) * 3600
|
||||||
|
|
||||||
# this doesnt allow for dst and timezones...
|
# this doesnt allow for dst and timezones...
|
||||||
|
@ -172,7 +172,7 @@ class Graph:
|
||||||
y_tick_width = max((space_required(text) for text in y_tick_text))
|
y_tick_width = max((space_required(text) for text in y_tick_text))
|
||||||
|
|
||||||
top = font_extents[2] / 2.0
|
top = font_extents[2] / 2.0
|
||||||
#bounds(left, top, right, bottom)
|
# bounds(left, top, right, bottom)
|
||||||
bounds = (y_tick_width + 4, top + 2, self.width, self.height - x_axis_space)
|
bounds = (y_tick_width + 4, top + 2, self.width, self.height - x_axis_space)
|
||||||
|
|
||||||
self.draw_x_axis(bounds)
|
self.draw_x_axis(bounds)
|
||||||
|
|
|
@ -28,7 +28,7 @@ print("\n\n")
|
||||||
|
|
||||||
if 0: # aclient non-core
|
if 0: # aclient non-core
|
||||||
methods = sorted([m for m in dir(aclient) if not m.startswith('_')
|
methods = sorted([m for m in dir(aclient) if not m.startswith('_')
|
||||||
if not m in ['add_torrent_file', 'has_callback', 'get_method', 'methodHelp',
|
if m not in ['add_torrent_file', 'has_callback', 'get_method', 'methodHelp',
|
||||||
'methodSignature', 'list_methods', 'add_torrent_file_binary']])
|
'methodSignature', 'list_methods', 'add_torrent_file_binary']])
|
||||||
|
|
||||||
for m in methods:
|
for m in methods:
|
||||||
|
@ -57,8 +57,7 @@ if 1: # baseclient/core
|
||||||
func = getattr(Core, m)
|
func = getattr(Core, m)
|
||||||
|
|
||||||
params = inspect.getargspec(func)[0][1:]
|
params = inspect.getargspec(func)[0][1:]
|
||||||
if (aclient.has_callback(method_name)
|
if (aclient.has_callback(method_name) and method_name not in ['add_torrent_file_binary']):
|
||||||
and not method_name in ['add_torrent_file_binary']):
|
|
||||||
params = ["[callback]"] + params
|
params = ["[callback]"] + params
|
||||||
|
|
||||||
print("\n'''%s(%s): '''\n" % (method_name, ", ".join(params)))
|
print("\n'''%s(%s): '''\n" % (method_name, ", ".join(params)))
|
||||||
|
|
|
@ -91,7 +91,7 @@ class TransferTestClass(DelugeTransferProtocol):
|
||||||
(len(data), len(data) - len(dobj.unused_data), len(dobj.unused_data)))
|
(len(data), len(data) - len(dobj.unused_data), len(dobj.unused_data)))
|
||||||
print("Packet count:", self.packet_count)
|
print("Packet count:", self.packet_count)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
#log.debug("Received possible invalid message (%r): %s", data, e)
|
# log.debug("Received possible invalid message (%r): %s", data, e)
|
||||||
# This could be cut-off data, so we'll save this in the buffer
|
# This could be cut-off data, so we'll save this in the buffer
|
||||||
# and try to prepend it on the next dataReceived()
|
# and try to prepend it on the next dataReceived()
|
||||||
self._buffer = data
|
self._buffer = data
|
||||||
|
|
|
@ -199,11 +199,11 @@ class Win32IcoFile(object):
|
||||||
im = im.convert('RGBA')
|
im = im.convert('RGBA')
|
||||||
im.putalpha(mask)
|
im.putalpha(mask)
|
||||||
log.debug("image mode: %s", im.mode)
|
log.debug("image mode: %s", im.mode)
|
||||||
# end if !'RGBA'
|
# end if !'RGBA'
|
||||||
# end if (png)/else(bmp)
|
# end if (png)/else(bmp)
|
||||||
|
|
||||||
return im
|
return im
|
||||||
# end frame
|
# end frame
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
s = 'Microsoft Icon: %d images (max %dx%d %dbpp)' % (
|
s = 'Microsoft Icon: %d images (max %dx%d %dbpp)' % (
|
||||||
|
|
|
@ -104,7 +104,7 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
|
||||||
|
|
||||||
if message_type == RPC_EVENT:
|
if message_type == RPC_EVENT:
|
||||||
event = request[1]
|
event = request[1]
|
||||||
#log.debug("Received RPCEvent: %s", event)
|
# log.debug("Received RPCEvent: %s", event)
|
||||||
# A RPCEvent was received from the daemon so run any handlers
|
# A RPCEvent was received from the daemon so run any handlers
|
||||||
# associated with it.
|
# associated with it.
|
||||||
if event in self.factory.event_handlers:
|
if event in self.factory.event_handlers:
|
||||||
|
@ -178,7 +178,7 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
|
||||||
# response to this request. We use the extra information when printing
|
# response to this request. We use the extra information when printing
|
||||||
# out the error for debugging purposes.
|
# out the error for debugging purposes.
|
||||||
self.__rpc_requests[request.request_id] = request
|
self.__rpc_requests[request.request_id] = request
|
||||||
#log.debug("Sending RPCRequest %s: %s", request.request_id, request)
|
# log.debug("Sending RPCRequest %s: %s", request.request_id, request)
|
||||||
# Send the request in a tuple because multiple requests can be sent at once
|
# Send the request in a tuple because multiple requests can be sent at once
|
||||||
self.transfer_message((request.format_message(),))
|
self.transfer_message((request.format_message(),))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
@ -450,7 +450,7 @@ class DaemonClassicProxy(DaemonProxy):
|
||||||
self.__daemon = None
|
self.__daemon = None
|
||||||
|
|
||||||
def call(self, method, *args, **kwargs):
|
def call(self, method, *args, **kwargs):
|
||||||
#log.debug("call: %s %s %s", method, args, kwargs)
|
# log.debug("call: %s %s %s", method, args, kwargs)
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ class DelugeHelpFormatter (optparse.IndentedHelpFormatter):
|
||||||
"\.\.\.": "{!yellow!}%s{!input!}",
|
"\.\.\.": "{!yellow!}%s{!input!}",
|
||||||
"\s\*\s": "{!blue!}%s{!input!}",
|
"\s\*\s": "{!blue!}%s{!input!}",
|
||||||
"(?<![\-a-z])(-[a-zA-Z0-9])": "{!red!}%s{!input!}",
|
"(?<![\-a-z])(-[a-zA-Z0-9])": "{!red!}%s{!input!}",
|
||||||
#"(\-[a-zA-Z0-9])": "{!red!}%s{!input!}",
|
# "(\-[a-zA-Z0-9])": "{!red!}%s{!input!}",
|
||||||
"--[_\-a-zA-Z0-9]+": "{!green!}%s{!input!}",
|
"--[_\-a-zA-Z0-9]+": "{!green!}%s{!input!}",
|
||||||
"(\[|\])": "{!info!}%s{!input!}",
|
"(\[|\])": "{!info!}%s{!input!}",
|
||||||
|
|
||||||
|
|
|
@ -810,7 +810,7 @@ class AllTorrents(BaseMode, component.Component):
|
||||||
|
|
||||||
def refresh(self, lines=None):
|
def refresh(self, lines=None):
|
||||||
# log.error("ref")
|
# log.error("ref")
|
||||||
#import traceback
|
# import traceback
|
||||||
# traceback.print_stack()
|
# traceback.print_stack()
|
||||||
# Something has requested we scroll to the top of the list
|
# Something has requested we scroll to the top of the list
|
||||||
if self._go_top:
|
if self._go_top:
|
||||||
|
|
|
@ -166,8 +166,8 @@ class Legacy(BaseMode, component.Component):
|
||||||
# simply scan for lines beginning with ">>> "
|
# simply scan for lines beginning with ">>> "
|
||||||
for i, line in enumerate(self.lines):
|
for i, line in enumerate(self.lines):
|
||||||
# if not isinstance(line, unicode):
|
# if not isinstance(line, unicode):
|
||||||
#line = line.encode(self.encoding)
|
# line = line.encode(self.encoding)
|
||||||
#self.lines[i] = line
|
# self.lines[i] = line
|
||||||
line = format_utils.remove_formatting(line)
|
line = format_utils.remove_formatting(line)
|
||||||
if line.startswith(">>> "):
|
if line.startswith(">>> "):
|
||||||
input = line[4:]
|
input = line[4:]
|
||||||
|
|
|
@ -334,7 +334,7 @@ class MessagePopup(Popup):
|
||||||
"""
|
"""
|
||||||
def __init__(self, parent_mode, title, message, align=ALIGN.DEFAULT, width_req=0.5):
|
def __init__(self, parent_mode, title, message, align=ALIGN.DEFAULT, width_req=0.5):
|
||||||
self.message = message
|
self.message = message
|
||||||
#self.width= int(parent_mode.cols/2)
|
# self.width= int(parent_mode.cols/2)
|
||||||
Popup.__init__(self, parent_mode, title, align=align, width_req=width_req)
|
Popup.__init__(self, parent_mode, title, align=align, width_req=width_req)
|
||||||
lns = format_utils.wrap_string(self.message, self.width - 2, 3, True)
|
lns = format_utils.wrap_string(self.message, self.width - 2, 3, True)
|
||||||
self.height_req = min(len(lns) + 2, int(parent_mode.rows * 2 / 3))
|
self.height_req = min(len(lns) + 2, int(parent_mode.rows * 2 / 3))
|
||||||
|
|
|
@ -274,7 +274,7 @@ class TorrentDetail(BaseMode, component.Component):
|
||||||
fl = s[3]
|
fl = s[3]
|
||||||
fe[0] = new_folder.strip("/").rpartition("/")[-1]
|
fe[0] = new_folder.strip("/").rpartition("/")[-1]
|
||||||
|
|
||||||
#self.__get_file_by_name(old_folder, self.file_list)[0] = new_folder.strip("/")
|
# self.__get_file_by_name(old_folder, self.file_list)[0] = new_folder.strip("/")
|
||||||
component.get("SessionProxy").get_torrent_status(
|
component.get("SessionProxy").get_torrent_status(
|
||||||
self.torrentid, self._status_keys).addCallback(self.set_state)
|
self.torrentid, self._status_keys).addCallback(self.set_state)
|
||||||
|
|
||||||
|
@ -284,8 +284,8 @@ class TorrentDetail(BaseMode, component.Component):
|
||||||
color_partially_selected = "magenta"
|
color_partially_selected = "magenta"
|
||||||
color_highlighted = "white"
|
color_highlighted = "white"
|
||||||
for fl in files:
|
for fl in files:
|
||||||
#from sys import stderr
|
# from sys import stderr
|
||||||
#print >> stderr, fl[6]
|
# print >> stderr, fl[6]
|
||||||
# kick out if we're going to draw too low on the screen
|
# kick out if we're going to draw too low on the screen
|
||||||
if (off >= self.rows - 1):
|
if (off >= self.rows - 1):
|
||||||
self.more_to_draw = True
|
self.more_to_draw = True
|
||||||
|
@ -469,7 +469,7 @@ class TorrentDetail(BaseMode, component.Component):
|
||||||
self.add_string(off, s)
|
self.add_string(off, s)
|
||||||
off += 1
|
off += 1
|
||||||
|
|
||||||
#Pieces and availability
|
# Pieces and availability
|
||||||
s = "{!info!}Pieces: {!yellow!}%s {!input!}x {!yellow!}%s" % (
|
s = "{!info!}Pieces: {!yellow!}%s {!input!}x {!yellow!}%s" % (
|
||||||
status["num_pieces"], fsize(status["piece_length"]))
|
status["num_pieces"], fsize(status["piece_length"]))
|
||||||
if status["distributed_copies"]:
|
if status["distributed_copies"]:
|
||||||
|
|
|
@ -137,7 +137,7 @@ class AddTorrentDialog(component.Component):
|
||||||
"move_completed_path",
|
"move_completed_path",
|
||||||
"move_completed_paths_list",
|
"move_completed_paths_list",
|
||||||
]
|
]
|
||||||
#self.core_keys += self.move_completed_path_chooser.get_config_keys()
|
# self.core_keys += self.move_completed_path_chooser.get_config_keys()
|
||||||
self.builder.get_object("notebook1").connect("switch-page", self._on_switch_page)
|
self.builder.get_object("notebook1").connect("switch-page", self._on_switch_page)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
|
|
@ -374,7 +374,6 @@ class FilesTab(Tab):
|
||||||
value[1]["size"], "", 0, 0, value[0], gtk.STOCK_FILE])
|
value[1]["size"], "", 0, 0, value[0], gtk.STOCK_FILE])
|
||||||
ret += value[1]["size"]
|
ret += value[1]["size"]
|
||||||
return ret
|
return ret
|
||||||
###
|
|
||||||
|
|
||||||
def update_files(self):
|
def update_files(self):
|
||||||
self.treestore.clear()
|
self.treestore.clear()
|
||||||
|
@ -839,7 +838,7 @@ class FilesTab(Tab):
|
||||||
client.core.rename_folder(self.torrent_id, pp + model[selected[0]][0],
|
client.core.rename_folder(self.torrent_id, pp + model[selected[0]][0],
|
||||||
parent_path + model[selected[0]][0])
|
parent_path + model[selected[0]][0])
|
||||||
else:
|
else:
|
||||||
#[(index, filepath), ...]
|
# [(index, filepath), ...]
|
||||||
to_rename = []
|
to_rename = []
|
||||||
for s in selected:
|
for s in selected:
|
||||||
to_rename.append((model[s][5], parent_path + model[s][0]))
|
to_rename.append((model[s][5], parent_path + model[s][0]))
|
||||||
|
|
|
@ -61,7 +61,7 @@ class FilterTreeView(component.Component):
|
||||||
self.sidebar.notebook.connect("hide", self._on_hide)
|
self.sidebar.notebook.connect("hide", self._on_hide)
|
||||||
|
|
||||||
# Create the treestore
|
# Create the treestore
|
||||||
#cat, value, label, count, pixmap, visible
|
# cat, value, label, count, pixmap, visible
|
||||||
self.treestore = gtk.TreeStore(str, str, str, int, gtk.gdk.Pixbuf, bool)
|
self.treestore = gtk.TreeStore(str, str, str, int, gtk.gdk.Pixbuf, bool)
|
||||||
|
|
||||||
# Create the column and cells
|
# Create the column and cells
|
||||||
|
@ -151,7 +151,7 @@ class FilterTreeView(component.Component):
|
||||||
def cb_update_filter_tree(self, filter_items):
|
def cb_update_filter_tree(self, filter_items):
|
||||||
# create missing cat_nodes
|
# create missing cat_nodes
|
||||||
for cat in filter_items:
|
for cat in filter_items:
|
||||||
if not cat in self.cat_nodes:
|
if cat not in self.cat_nodes:
|
||||||
label = _(cat)
|
label = _(cat)
|
||||||
if cat == "label":
|
if cat == "label":
|
||||||
label = _("Labels")
|
label = _("Labels")
|
||||||
|
@ -170,7 +170,7 @@ class FilterTreeView(component.Component):
|
||||||
|
|
||||||
# hide items not returned by core-plugin.
|
# hide items not returned by core-plugin.
|
||||||
for f in self.filters:
|
for f in self.filters:
|
||||||
if not f in visible_filters:
|
if f not in visible_filters:
|
||||||
self.treestore.set_value(self.filters[f], FILTER_COLUMN, False)
|
self.treestore.set_value(self.filters[f], FILTER_COLUMN, False)
|
||||||
|
|
||||||
if self.expand_rows:
|
if self.expand_rows:
|
||||||
|
@ -300,7 +300,7 @@ class FilterTreeView(component.Component):
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.debug(ex)
|
log.debug(ex)
|
||||||
|
|
||||||
### Callbacks ###
|
# Callbacks #
|
||||||
def on_button_press_event(self, widget, event):
|
def on_button_press_event(self, widget, event):
|
||||||
"""This is a callback for showing the right-click context menu."""
|
"""This is a callback for showing the right-click context menu."""
|
||||||
x, y = event.get_coords()
|
x, y = event.get_coords()
|
||||||
|
|
|
@ -109,7 +109,7 @@ class MenuBar(component.Component):
|
||||||
self.main_builder.get_object("sidebar_show_zero").set_active(self.config["sidebar_show_zero"])
|
self.main_builder.get_object("sidebar_show_zero").set_active(self.config["sidebar_show_zero"])
|
||||||
self.main_builder.get_object("sidebar_show_trackers").set_active(self.config["sidebar_show_trackers"])
|
self.main_builder.get_object("sidebar_show_trackers").set_active(self.config["sidebar_show_trackers"])
|
||||||
|
|
||||||
### Connect main window Signals ###
|
# Connect main window Signals #
|
||||||
component.get("MainWindow").connect_signals({
|
component.get("MainWindow").connect_signals({
|
||||||
# File Menu
|
# File Menu
|
||||||
"on_menuitem_addtorrent_activate": self.on_menuitem_addtorrent_activate,
|
"on_menuitem_addtorrent_activate": self.on_menuitem_addtorrent_activate,
|
||||||
|
@ -220,7 +220,7 @@ class MenuBar(component.Component):
|
||||||
sep.show()
|
sep.show()
|
||||||
return sep
|
return sep
|
||||||
|
|
||||||
### Callbacks ###
|
# Callbacks #
|
||||||
def on_torrentstatechanged_event(self, torrent_id, state):
|
def on_torrentstatechanged_event(self, torrent_id, state):
|
||||||
if state == "Paused":
|
if state == "Paused":
|
||||||
self.update_menu()
|
self.update_menu()
|
||||||
|
@ -234,7 +234,7 @@ class MenuBar(component.Component):
|
||||||
def on_sessionresumed_event(self):
|
def on_sessionresumed_event(self):
|
||||||
self.update_menu()
|
self.update_menu()
|
||||||
|
|
||||||
## File Menu ##
|
# File Menu #
|
||||||
def on_menuitem_addtorrent_activate(self, data=None):
|
def on_menuitem_addtorrent_activate(self, data=None):
|
||||||
log.debug("on_menuitem_addtorrent_activate")
|
log.debug("on_menuitem_addtorrent_activate")
|
||||||
component.get("AddTorrentDialog").show()
|
component.get("AddTorrentDialog").show()
|
||||||
|
@ -252,7 +252,7 @@ class MenuBar(component.Component):
|
||||||
log.debug("on_menuitem_quit_activate")
|
log.debug("on_menuitem_quit_activate")
|
||||||
self.window.quit()
|
self.window.quit()
|
||||||
|
|
||||||
## Edit Menu ##
|
# Edit Menu #
|
||||||
def on_menuitem_preferences_activate(self, data=None):
|
def on_menuitem_preferences_activate(self, data=None):
|
||||||
log.debug("on_menuitem_preferences_activate")
|
log.debug("on_menuitem_preferences_activate")
|
||||||
component.get("Preferences").show()
|
component.get("Preferences").show()
|
||||||
|
@ -261,7 +261,7 @@ class MenuBar(component.Component):
|
||||||
log.debug("on_menuitem_connectionmanager_activate")
|
log.debug("on_menuitem_connectionmanager_activate")
|
||||||
component.get("ConnectionManager").show()
|
component.get("ConnectionManager").show()
|
||||||
|
|
||||||
## Torrent Menu ##
|
# Torrent Menu #
|
||||||
def on_menuitem_pause_activate(self, data=None):
|
def on_menuitem_pause_activate(self, data=None):
|
||||||
log.debug("on_menuitem_pause_activate")
|
log.debug("on_menuitem_pause_activate")
|
||||||
client.core.pause_torrent(
|
client.core.pause_torrent(
|
||||||
|
@ -364,7 +364,7 @@ class MenuBar(component.Component):
|
||||||
log.debug("on_menuitem_queue_bottom_activate")
|
log.debug("on_menuitem_queue_bottom_activate")
|
||||||
client.core.queue_bottom(component.get("TorrentView").get_selected_torrents())
|
client.core.queue_bottom(component.get("TorrentView").get_selected_torrents())
|
||||||
|
|
||||||
## View Menu ##
|
# View Menu #
|
||||||
def on_menuitem_toolbar_toggled(self, value):
|
def on_menuitem_toolbar_toggled(self, value):
|
||||||
log.debug("on_menuitem_toolbar_toggled")
|
log.debug("on_menuitem_toolbar_toggled")
|
||||||
component.get("ToolBar").visible(value.get_active())
|
component.get("ToolBar").visible(value.get_active())
|
||||||
|
@ -377,7 +377,7 @@ class MenuBar(component.Component):
|
||||||
log.debug("on_menuitem_statusbar_toggled")
|
log.debug("on_menuitem_statusbar_toggled")
|
||||||
component.get("StatusBar").visible(value.get_active())
|
component.get("StatusBar").visible(value.get_active())
|
||||||
|
|
||||||
## Help Menu ##
|
# Help Menu #
|
||||||
def on_menuitem_homepage_activate(self, data=None):
|
def on_menuitem_homepage_activate(self, data=None):
|
||||||
log.debug("on_menuitem_homepage_activate")
|
log.debug("on_menuitem_homepage_activate")
|
||||||
deluge.common.open_url_in_browser("http://deluge-torrent.org")
|
deluge.common.open_url_in_browser("http://deluge-torrent.org")
|
||||||
|
|
|
@ -30,7 +30,7 @@ def singleton(cls):
|
||||||
class PathChoosersHandler(component.Component):
|
class PathChoosersHandler(component.Component):
|
||||||
|
|
||||||
def __init__(self, paths_config_key=None):
|
def __init__(self, paths_config_key=None):
|
||||||
#self.chooser_name = "PathChooser_%d" % (len(PathChooser.path_choosers) +1)
|
# self.chooser_name = "PathChooser_%d" % (len(PathChooser.path_choosers) +1)
|
||||||
component.Component.__init__(self, "PathChoosersHandler")
|
component.Component.__init__(self, "PathChoosersHandler")
|
||||||
self.path_choosers = []
|
self.path_choosers = []
|
||||||
self.paths_list_keys = []
|
self.paths_list_keys = []
|
||||||
|
@ -70,7 +70,7 @@ class PathChoosersHandler(component.Component):
|
||||||
chooser.config_key_funcs[key][1] = getattr(chooser, "set_%s" % self.config_keys_to_funcs_mapping[key])
|
chooser.config_key_funcs[key][1] = getattr(chooser, "set_%s" % self.config_keys_to_funcs_mapping[key])
|
||||||
|
|
||||||
self.path_choosers.append(chooser)
|
self.path_choosers.append(chooser)
|
||||||
if not chooser.paths_config_key in self.paths_list_keys:
|
if chooser.paths_config_key not in self.paths_list_keys:
|
||||||
self.paths_list_keys.append(chooser.paths_config_key)
|
self.paths_list_keys.append(chooser.paths_config_key)
|
||||||
if self.started:
|
if self.started:
|
||||||
self.update_config_from_core()
|
self.update_config_from_core()
|
||||||
|
@ -82,7 +82,7 @@ class PathChoosersHandler(component.Component):
|
||||||
chooser.config_key_funcs[key][1](value)
|
chooser.config_key_funcs[key][1](value)
|
||||||
|
|
||||||
# Save to core
|
# Save to core
|
||||||
if not key is "path_chooser_max_popup_rows":
|
if key is not "path_chooser_max_popup_rows":
|
||||||
client.core.set_config({key: value})
|
client.core.set_config({key: value})
|
||||||
else:
|
else:
|
||||||
# Since the max rows value can be changed fast with a spinbutton, we
|
# Since the max rows value can be changed fast with a spinbutton, we
|
||||||
|
|
|
@ -283,7 +283,7 @@ class ValueList(object):
|
||||||
next = None
|
next = None
|
||||||
|
|
||||||
# If next is None, we won't change the selection
|
# If next is None, we won't change the selection
|
||||||
if not next is None:
|
if next is not None:
|
||||||
# We move the selection either one up or down.
|
# We move the selection either one up or down.
|
||||||
# If we reach end of list, we wrap
|
# If we reach end of list, we wrap
|
||||||
index = path[0] if path else 0
|
index = path[0] if path else 0
|
||||||
|
@ -674,9 +674,9 @@ class PathChooserPopup(object):
|
||||||
def get_max_popup_rows(self):
|
def get_max_popup_rows(self):
|
||||||
return self.max_visible_rows
|
return self.max_visible_rows
|
||||||
|
|
||||||
###################################################
|
#################
|
||||||
# Callbacks
|
# Callbacks
|
||||||
###################################################
|
#################
|
||||||
|
|
||||||
def on_popup_window_button_press_event(self, window, event):
|
def on_popup_window_button_press_event(self, window, event):
|
||||||
# If we're clicking outside of the window close the popup
|
# If we're clicking outside of the window close the popup
|
||||||
|
@ -760,9 +760,9 @@ class StoredValuesPopup(StoredValuesList, PathChooserPopup):
|
||||||
# Set value selected if it exists
|
# Set value selected if it exists
|
||||||
self.set_selected_value(path_without_trailing_path_sep(self.path_entry.get_text()))
|
self.set_selected_value(path_without_trailing_path_sep(self.path_entry.get_text()))
|
||||||
|
|
||||||
###################################################
|
#################
|
||||||
# Callbacks
|
# Callbacks
|
||||||
###################################################
|
#################
|
||||||
|
|
||||||
def on_stored_values_popup_window_focus_out_event(self, entry, event):
|
def on_stored_values_popup_window_focus_out_event(self, entry, event):
|
||||||
"""
|
"""
|
||||||
|
@ -885,9 +885,9 @@ class PathCompletionPopup(CompletionList, PathChooserPopup):
|
||||||
self.text_entry.set_position(len(self.path_entry.text_entry.get_text()))
|
self.text_entry.set_position(len(self.path_entry.text_entry.get_text()))
|
||||||
self.set_selected_value(path_without_trailing_path_sep(self.path_entry.get_text()), select_first=True)
|
self.set_selected_value(path_without_trailing_path_sep(self.path_entry.get_text()), select_first=True)
|
||||||
|
|
||||||
###################################################
|
#################
|
||||||
# Callbacks
|
# Callbacks
|
||||||
###################################################
|
#################
|
||||||
|
|
||||||
def on_completion_popup_window_focus_out_event(self, entry, event):
|
def on_completion_popup_window_focus_out_event(self, entry, event):
|
||||||
"""
|
"""
|
||||||
|
@ -1104,7 +1104,7 @@ class PathChooserComboBox(gtk.HBox, StoredValuesPopup, gobject.GObject):
|
||||||
folder_name = ""
|
folder_name = ""
|
||||||
if self.show_folder_name_on_button or not self.path_entry_visible:
|
if self.show_folder_name_on_button or not self.path_entry_visible:
|
||||||
folder_name = path_without_trailing_path_sep(text)
|
folder_name = path_without_trailing_path_sep(text)
|
||||||
if not folder_name is "/" and os.path.basename(folder_name):
|
if folder_name is not "/" and os.path.basename(folder_name):
|
||||||
folder_name = os.path.basename(folder_name)
|
folder_name = os.path.basename(folder_name)
|
||||||
self.folder_name_label.set_text(folder_name)
|
self.folder_name_label.set_text(folder_name)
|
||||||
# Only trigger event if text has changed
|
# Only trigger event if text has changed
|
||||||
|
@ -1248,9 +1248,9 @@ class PathChooserComboBox(gtk.HBox, StoredValuesPopup, gobject.GObject):
|
||||||
"""
|
"""
|
||||||
self.auto_completer._end_completion(args)
|
self.auto_completer._end_completion(args)
|
||||||
|
|
||||||
######################################
|
##############
|
||||||
# Callbacks and internal functions
|
# Callbacks and internal functions
|
||||||
######################################
|
##############
|
||||||
|
|
||||||
def on_entry_text_changed(self, entry):
|
def on_entry_text_changed(self, entry):
|
||||||
self.emit("text-changed", self.get_text())
|
self.emit("text-changed", self.get_text())
|
||||||
|
@ -1348,9 +1348,9 @@ class PathChooserComboBox(gtk.HBox, StoredValuesPopup, gobject.GObject):
|
||||||
self.button_toggle.set_active(False)
|
self.button_toggle.set_active(False)
|
||||||
self._stored_values_popping_down = False
|
self._stored_values_popping_down = False
|
||||||
|
|
||||||
######################################
|
##############
|
||||||
# Config dialog
|
# Config dialog
|
||||||
######################################
|
##############
|
||||||
|
|
||||||
def _on_button_toggle_dropdown_button_press_event(self, widget, event):
|
def _on_button_toggle_dropdown_button_press_event(self, widget, event):
|
||||||
"""Show config when right clicking dropdown toggle button"""
|
"""Show config when right clicking dropdown toggle button"""
|
||||||
|
|
|
@ -462,13 +462,13 @@ class Preferences(component.Component):
|
||||||
# Update the toggle status if necessary
|
# Update the toggle status if necessary
|
||||||
self.on_toggle(widget)
|
self.on_toggle(widget)
|
||||||
|
|
||||||
## Downloads tab ##
|
# Downloads tab #
|
||||||
self.builder.get_object("chk_show_dialog").set_active(
|
self.builder.get_object("chk_show_dialog").set_active(
|
||||||
self.gtkui_config["interactive_add"])
|
self.gtkui_config["interactive_add"])
|
||||||
self.builder.get_object("chk_focus_dialog").set_active(
|
self.builder.get_object("chk_focus_dialog").set_active(
|
||||||
self.gtkui_config["focus_add_dialog"])
|
self.gtkui_config["focus_add_dialog"])
|
||||||
|
|
||||||
## Interface tab ##
|
# Interface tab #
|
||||||
self.builder.get_object("chk_use_tray").set_active(
|
self.builder.get_object("chk_use_tray").set_active(
|
||||||
self.gtkui_config["enable_system_tray"])
|
self.gtkui_config["enable_system_tray"])
|
||||||
self.builder.get_object("chk_min_on_close").set_active(
|
self.builder.get_object("chk_min_on_close").set_active(
|
||||||
|
@ -495,15 +495,15 @@ class Preferences(component.Component):
|
||||||
self.__set_color("waiting", from_config=True)
|
self.__set_color("waiting", from_config=True)
|
||||||
self.__set_color("missing", from_config=True)
|
self.__set_color("missing", from_config=True)
|
||||||
|
|
||||||
## Other tab ##
|
# Other tab #
|
||||||
self.builder.get_object("chk_show_new_releases").set_active(
|
self.builder.get_object("chk_show_new_releases").set_active(
|
||||||
self.gtkui_config["show_new_releases"])
|
self.gtkui_config["show_new_releases"])
|
||||||
|
|
||||||
## Cache tab ##
|
# Cache tab #
|
||||||
if client.connected():
|
if client.connected():
|
||||||
self.__update_cache_status()
|
self.__update_cache_status()
|
||||||
|
|
||||||
## Plugins tab ##
|
# Plugins tab #
|
||||||
all_plugins = self.all_plugins
|
all_plugins = self.all_plugins
|
||||||
enabled_plugins = self.enabled_plugins
|
enabled_plugins = self.enabled_plugins
|
||||||
# Clear the existing list so we don't duplicate entries.
|
# Clear the existing list so we don't duplicate entries.
|
||||||
|
@ -534,7 +534,7 @@ class Preferences(component.Component):
|
||||||
new_core_config = {}
|
new_core_config = {}
|
||||||
new_gtkui_config = {}
|
new_gtkui_config = {}
|
||||||
|
|
||||||
## Downloads tab ##
|
# Downloads tab #
|
||||||
new_gtkui_config["interactive_add"] = \
|
new_gtkui_config["interactive_add"] = \
|
||||||
self.builder.get_object("chk_show_dialog").get_active()
|
self.builder.get_object("chk_show_dialog").get_active()
|
||||||
new_gtkui_config["focus_add_dialog"] = \
|
new_gtkui_config["focus_add_dialog"] = \
|
||||||
|
@ -563,7 +563,7 @@ class Preferences(component.Component):
|
||||||
new_core_config["add_paused"] = self.builder.get_object("chk_add_paused").get_active()
|
new_core_config["add_paused"] = self.builder.get_object("chk_add_paused").get_active()
|
||||||
new_core_config["pre_allocate_storage"] = self.builder.get_object("chk_pre_allocation").get_active()
|
new_core_config["pre_allocate_storage"] = self.builder.get_object("chk_pre_allocation").get_active()
|
||||||
|
|
||||||
## Network tab ##
|
# Network tab #
|
||||||
listen_ports = (
|
listen_ports = (
|
||||||
self.builder.get_object("spin_port_min").get_value_as_int(),
|
self.builder.get_object("spin_port_min").get_value_as_int(),
|
||||||
self.builder.get_object("spin_port_max").get_value_as_int()
|
self.builder.get_object("spin_port_max").get_value_as_int()
|
||||||
|
@ -599,7 +599,7 @@ class Preferences(component.Component):
|
||||||
new_core_config["enc_level"] = \
|
new_core_config["enc_level"] = \
|
||||||
self.builder.get_object("combo_enclevel").get_active()
|
self.builder.get_object("combo_enclevel").get_active()
|
||||||
|
|
||||||
## Bandwidth tab ##
|
# Bandwidth tab #
|
||||||
new_core_config["max_connections_global"] = \
|
new_core_config["max_connections_global"] = \
|
||||||
self.builder.get_object(
|
self.builder.get_object(
|
||||||
"spin_max_connections_global").get_value_as_int()
|
"spin_max_connections_global").get_value_as_int()
|
||||||
|
@ -632,7 +632,7 @@ class Preferences(component.Component):
|
||||||
new_core_config["rate_limit_ip_overhead"] = \
|
new_core_config["rate_limit_ip_overhead"] = \
|
||||||
self.builder.get_object("chk_rate_limit_ip_overhead").get_active()
|
self.builder.get_object("chk_rate_limit_ip_overhead").get_active()
|
||||||
|
|
||||||
## Interface tab ##
|
# Interface tab #
|
||||||
new_gtkui_config["enable_system_tray"] = \
|
new_gtkui_config["enable_system_tray"] = \
|
||||||
self.builder.get_object("chk_use_tray").get_active()
|
self.builder.get_object("chk_use_tray").get_active()
|
||||||
new_gtkui_config["close_to_tray"] = \
|
new_gtkui_config["close_to_tray"] = \
|
||||||
|
@ -655,7 +655,7 @@ class Preferences(component.Component):
|
||||||
new_gtkui_config["focus_main_window_on_add"] = \
|
new_gtkui_config["focus_main_window_on_add"] = \
|
||||||
self.builder.get_object("chk_focus_main_window_on_add").get_active()
|
self.builder.get_object("chk_focus_main_window_on_add").get_active()
|
||||||
|
|
||||||
## Other tab ##
|
# Other tab #
|
||||||
new_gtkui_config["show_new_releases"] = \
|
new_gtkui_config["show_new_releases"] = \
|
||||||
self.builder.get_object("chk_show_new_releases").get_active()
|
self.builder.get_object("chk_show_new_releases").get_active()
|
||||||
new_core_config["send_info"] = \
|
new_core_config["send_info"] = \
|
||||||
|
@ -663,7 +663,7 @@ class Preferences(component.Component):
|
||||||
new_core_config["geoip_db_location"] = \
|
new_core_config["geoip_db_location"] = \
|
||||||
self.builder.get_object("entry_geoip").get_text()
|
self.builder.get_object("entry_geoip").get_text()
|
||||||
|
|
||||||
## Daemon tab ##
|
# Daemon tab #
|
||||||
new_core_config["daemon_port"] = \
|
new_core_config["daemon_port"] = \
|
||||||
self.builder.get_object("spin_daemon_port").get_value_as_int()
|
self.builder.get_object("spin_daemon_port").get_value_as_int()
|
||||||
new_core_config["allow_remote"] = \
|
new_core_config["allow_remote"] = \
|
||||||
|
@ -671,7 +671,7 @@ class Preferences(component.Component):
|
||||||
new_core_config["new_release_check"] = \
|
new_core_config["new_release_check"] = \
|
||||||
self.builder.get_object("chk_new_releases").get_active()
|
self.builder.get_object("chk_new_releases").get_active()
|
||||||
|
|
||||||
## Proxy tab ##
|
# Proxy tab #
|
||||||
new_core_config["proxy"] = {}
|
new_core_config["proxy"] = {}
|
||||||
new_core_config["proxy"]["type"] = self.builder.get_object("combo_proxy_type").get_active()
|
new_core_config["proxy"]["type"] = self.builder.get_object("combo_proxy_type").get_active()
|
||||||
new_core_config["proxy"]["username"] = self.builder.get_object("entry_proxy_user").get_text()
|
new_core_config["proxy"]["username"] = self.builder.get_object("entry_proxy_user").get_text()
|
||||||
|
@ -686,7 +686,7 @@ class Preferences(component.Component):
|
||||||
new_core_config["i2p_proxy"]["port"] = self.builder.get_object("spin_i2p_port").get_value_as_int()
|
new_core_config["i2p_proxy"]["port"] = self.builder.get_object("spin_i2p_port").get_value_as_int()
|
||||||
new_core_config["anonymous_mode"] = self.builder.get_object("chk_anonymous_mode").get_active()
|
new_core_config["anonymous_mode"] = self.builder.get_object("chk_anonymous_mode").get_active()
|
||||||
|
|
||||||
## Queue tab ##
|
# Queue tab #
|
||||||
new_core_config["queue_new_to_top"] = \
|
new_core_config["queue_new_to_top"] = \
|
||||||
self.builder.get_object("chk_queue_new_top").get_active()
|
self.builder.get_object("chk_queue_new_top").get_active()
|
||||||
new_core_config["max_active_seeding"] = \
|
new_core_config["max_active_seeding"] = \
|
||||||
|
@ -712,7 +712,7 @@ class Preferences(component.Component):
|
||||||
new_core_config["seed_time_limit"] = \
|
new_core_config["seed_time_limit"] = \
|
||||||
self.builder.get_object("spin_seed_time_limit").get_value()
|
self.builder.get_object("spin_seed_time_limit").get_value()
|
||||||
|
|
||||||
## Cache tab ##
|
# Cache tab #
|
||||||
new_core_config["cache_size"] = \
|
new_core_config["cache_size"] = \
|
||||||
self.builder.get_object("spin_cache_size").get_value_as_int()
|
self.builder.get_object("spin_cache_size").get_value_as_int()
|
||||||
new_core_config["cache_expiry"] = \
|
new_core_config["cache_expiry"] = \
|
||||||
|
@ -1025,8 +1025,8 @@ class Preferences(component.Component):
|
||||||
# 0:"None"
|
# 0:"None"
|
||||||
if proxy_type == 0:
|
if proxy_type == 0:
|
||||||
hides.extend(["entry_proxy_pass", "entry_proxy_user", "entry_proxy_host", "spin_proxy_port",
|
hides.extend(["entry_proxy_pass", "entry_proxy_user", "entry_proxy_host", "spin_proxy_port",
|
||||||
"label_proxy_pass", "label_proxy_user", "label_proxy_host", "label_proxy_port",
|
"label_proxy_pass", "label_proxy_user", "label_proxy_host", "label_proxy_port",
|
||||||
"chk_proxy_host_resolve", "chk_proxy_peer_conn"])
|
"chk_proxy_host_resolve", "chk_proxy_peer_conn"])
|
||||||
# 1:"Socks4", 2:"Socks5", 4:"HTTP"
|
# 1:"Socks4", 2:"Socks5", 4:"HTTP"
|
||||||
elif proxy_type in (1, 2, 4):
|
elif proxy_type in (1, 2, 4):
|
||||||
if proxy_type in (2, 4):
|
if proxy_type in (2, 4):
|
||||||
|
|
|
@ -30,7 +30,7 @@ class SideBar(component.Component):
|
||||||
self.notebook = builder.get_object("sidebar_notebook")
|
self.notebook = builder.get_object("sidebar_notebook")
|
||||||
self.hpaned = builder.get_object("main_window_hpaned")
|
self.hpaned = builder.get_object("main_window_hpaned")
|
||||||
self.config = ConfigManager("gtkui.conf")
|
self.config = ConfigManager("gtkui.conf")
|
||||||
#self.hpaned_position = self.hpaned.get_position()
|
# self.hpaned_position = self.hpaned.get_position()
|
||||||
|
|
||||||
# Tabs holds references to the Tab widgets by their name
|
# Tabs holds references to the Tab widgets by their name
|
||||||
self.tabs = {}
|
self.tabs = {}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class ToolBar(component.Component):
|
||||||
self.window = component.get("MainWindow")
|
self.window = component.get("MainWindow")
|
||||||
self.toolbar = self.window.get_builder().get_object("toolbar")
|
self.toolbar = self.window.get_builder().get_object("toolbar")
|
||||||
self.config = ConfigManager("gtkui.conf")
|
self.config = ConfigManager("gtkui.conf")
|
||||||
### Connect main window Signals ###
|
# Connect main window Signals #
|
||||||
self.window.connect_signals({
|
self.window.connect_signals({
|
||||||
"on_toolbutton_add_clicked": self.on_toolbutton_add_clicked,
|
"on_toolbutton_add_clicked": self.on_toolbutton_add_clicked,
|
||||||
"on_toolbutton_remove_clicked": self.on_toolbutton_remove_clicked,
|
"on_toolbutton_remove_clicked": self.on_toolbutton_remove_clicked,
|
||||||
|
@ -106,7 +106,7 @@ class ToolBar(component.Component):
|
||||||
"""Removes a widget from the toolbar"""
|
"""Removes a widget from the toolbar"""
|
||||||
self.toolbar.remove(widget)
|
self.toolbar.remove(widget)
|
||||||
|
|
||||||
### Callbacks (Uses the menubar's callback) ###
|
# Callbacks (Uses the menubar's callback) #
|
||||||
|
|
||||||
def on_toolbutton_add_clicked(self, data):
|
def on_toolbutton_add_clicked(self, data):
|
||||||
log.debug("on_toolbutton_add_clicked")
|
log.debug("on_toolbutton_add_clicked")
|
||||||
|
|
|
@ -284,7 +284,7 @@ class TorrentView(ListView, component.Component):
|
||||||
# Set filter to None for now
|
# Set filter to None for now
|
||||||
self.filter = None
|
self.filter = None
|
||||||
|
|
||||||
### Connect Signals ###
|
# Connect Signals #
|
||||||
# Connect to the 'button-press-event' to know when to bring up the
|
# Connect to the 'button-press-event' to know when to bring up the
|
||||||
# torrent menu popup.
|
# torrent menu popup.
|
||||||
self.treeview.connect("button-press-event", self.on_button_press_event)
|
self.treeview.connect("button-press-event", self.on_button_press_event)
|
||||||
|
@ -536,7 +536,7 @@ class TorrentView(ListView, component.Component):
|
||||||
def mark_dirty(self, torrent_id=None):
|
def mark_dirty(self, torrent_id=None):
|
||||||
for row in self.liststore:
|
for row in self.liststore:
|
||||||
if not torrent_id or row[self.columns["torrent_id"].column_indices[0]] == torrent_id:
|
if not torrent_id or row[self.columns["torrent_id"].column_indices[0]] == torrent_id:
|
||||||
#log.debug("marking %s dirty", torrent_id)
|
# log.debug("marking %s dirty", torrent_id)
|
||||||
row[self.columns["dirty"].column_indices[0]] = True
|
row[self.columns["dirty"].column_indices[0]] = True
|
||||||
if torrent_id:
|
if torrent_id:
|
||||||
break
|
break
|
||||||
|
@ -592,7 +592,7 @@ class TorrentView(ListView, component.Component):
|
||||||
def get_visible_torrents(self):
|
def get_visible_torrents(self):
|
||||||
return self.status.keys()
|
return self.status.keys()
|
||||||
|
|
||||||
### Callbacks ###
|
# Callbacks #
|
||||||
def on_button_press_event(self, widget, event):
|
def on_button_press_event(self, widget, event):
|
||||||
"""This is a callback for showing the right-click context menu."""
|
"""This is a callback for showing the right-click context menu."""
|
||||||
log.debug("on_button_press_event")
|
log.debug("on_button_press_event")
|
||||||
|
|
|
@ -212,7 +212,7 @@ class SessionProxy(component.Component):
|
||||||
break
|
break
|
||||||
|
|
||||||
return to_fetch
|
return to_fetch
|
||||||
#-----------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
if not filter_dict:
|
if not filter_dict:
|
||||||
# This means we want all the torrents status
|
# This means we want all the torrents status
|
||||||
|
|
|
@ -480,7 +480,7 @@ class TrackerIcons(Component):
|
||||||
host = self.redirects[host]
|
host = self.redirects[host]
|
||||||
return "http://%s/" % host
|
return "http://%s/" % host
|
||||||
|
|
||||||
################################ HELPER CLASSES ###############################
|
# ------- HELPER CLASSES ------
|
||||||
|
|
||||||
|
|
||||||
class FaviconParser(HTMLParser):
|
class FaviconParser(HTMLParser):
|
||||||
|
@ -525,7 +525,7 @@ class FaviconParser(HTMLParser):
|
||||||
return self.icons
|
return self.icons
|
||||||
|
|
||||||
|
|
||||||
############################### HELPER FUNCTIONS ##############################
|
# ------ HELPER FUNCTIONS ------
|
||||||
|
|
||||||
def url_to_host(url):
|
def url_to_host(url):
|
||||||
"""
|
"""
|
||||||
|
@ -604,7 +604,7 @@ def extension_to_mimetype(extension):
|
||||||
"""
|
"""
|
||||||
return MIME_MAP[extension.lower()]
|
return MIME_MAP[extension.lower()]
|
||||||
|
|
||||||
################################## EXCEPTIONS #################################
|
# ------ EXCEPTIONS ------
|
||||||
|
|
||||||
|
|
||||||
class NoIconsError(Exception):
|
class NoIconsError(Exception):
|
||||||
|
|
|
@ -21,6 +21,8 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
get_version = None
|
get_version = None
|
||||||
|
|
||||||
|
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
||||||
|
|
||||||
# If your extensions are in another directory, add it here. If the directory
|
# If your extensions are in another directory, add it here. If the directory
|
||||||
# is relative to the documentation root, use os.path.abspath to make it
|
# is relative to the documentation root, use os.path.abspath to make it
|
||||||
# absolute, like shown here.
|
# absolute, like shown here.
|
||||||
|
@ -52,6 +54,9 @@ MOCK_MODULES = ['deluge.ui.languages', 'deluge.ui.countries', 'deluge.ui.gtkui.g
|
||||||
'deluge.libtorrent', 'psyco', 'rencode', 'win32file', 'win32event',
|
'deluge.libtorrent', 'psyco', 'rencode', 'win32file', 'win32event',
|
||||||
'win32gui', 'win32api', 'win32con', '_winreg']
|
'win32gui', 'win32api', 'win32con', '_winreg']
|
||||||
|
|
||||||
|
if on_rtd:
|
||||||
|
MOCK_MODULES += ['libtorrent', 'pytgtk']
|
||||||
|
|
||||||
for mod_name in MOCK_MODULES:
|
for mod_name in MOCK_MODULES:
|
||||||
sys.modules[mod_name] = Mock()
|
sys.modules[mod_name] = Mock()
|
||||||
|
|
||||||
|
@ -93,31 +98,31 @@ release = version
|
||||||
|
|
||||||
# There are two options for replacing |today|: either, you set today to some
|
# There are two options for replacing |today|: either, you set today to some
|
||||||
# non-false value, then it is used:
|
# non-false value, then it is used:
|
||||||
#today = ''
|
# today = ''
|
||||||
# Else, today_fmt is used as the format for a strftime call.
|
# Else, today_fmt is used as the format for a strftime call.
|
||||||
today_fmt = '%B %d, %Y'
|
today_fmt = '%B %d, %Y'
|
||||||
|
|
||||||
# List of documents that shouldn't be included in the build.
|
# List of documents that shouldn't be included in the build.
|
||||||
#unused_docs = []
|
# unused_docs = []
|
||||||
|
|
||||||
# List of directories, relative to source directories, that shouldn't be searched
|
# List of directories, relative to source directories, that shouldn't be searched
|
||||||
# for source files.
|
# for source files.
|
||||||
#exclude_dirs = []
|
# exclude_dirs = []
|
||||||
exclude_pattern = ['deluge/_libtorrent.py', 'deluge/__rpcapi.py']
|
exclude_pattern = ['deluge/_libtorrent.py', 'deluge/__rpcapi.py']
|
||||||
|
|
||||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||||
#default_role = None
|
# default_role = None
|
||||||
|
|
||||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||||
#add_function_parentheses = True
|
# add_function_parentheses = True
|
||||||
|
|
||||||
# If true, the current module name will be prepended to all description
|
# If true, the current module name will be prepended to all description
|
||||||
# unit titles (such as .. function::).
|
# unit titles (such as .. function::).
|
||||||
#add_module_names = True
|
# add_module_names = True
|
||||||
|
|
||||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||||
# output. They are ignored by default.
|
# output. They are ignored by default.
|
||||||
#show_authors = False
|
# show_authors = False
|
||||||
|
|
||||||
# The name of the Pygments (syntax highlighting) style to use.
|
# The name of the Pygments (syntax highlighting) style to use.
|
||||||
pygments_style = 'sphinx'
|
pygments_style = 'sphinx'
|
||||||
|
@ -133,19 +138,19 @@ html_style = 'default.css'
|
||||||
|
|
||||||
# The name for this set of Sphinx documents. If None, it defaults to
|
# The name for this set of Sphinx documents. If None, it defaults to
|
||||||
# "<project> v<release> documentation".
|
# "<project> v<release> documentation".
|
||||||
#html_title = None
|
# html_title = None
|
||||||
|
|
||||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||||
#html_short_title = None
|
# html_short_title = None
|
||||||
|
|
||||||
# The name of an image file (within the static path) to place at the top of
|
# The name of an image file (within the static path) to place at the top of
|
||||||
# the sidebar.
|
# the sidebar.
|
||||||
#html_logo = None
|
# html_logo = None
|
||||||
|
|
||||||
# The name of an image file (within the static path) to use as favicon of the
|
# The name of an image file (within the static path) to use as favicon of the
|
||||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||||
# pixels large.
|
# pixels large.
|
||||||
#html_favicon = None
|
# html_favicon = None
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
|
@ -158,34 +163,34 @@ html_last_updated_fmt = '%b %d, %Y'
|
||||||
|
|
||||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||||
# typographically correct entities.
|
# typographically correct entities.
|
||||||
#html_use_smartypants = True
|
# html_use_smartypants = True
|
||||||
|
|
||||||
# Custom sidebar templates, maps document names to template names.
|
# Custom sidebar templates, maps document names to template names.
|
||||||
#html_sidebars = {}
|
# html_sidebars = {}
|
||||||
|
|
||||||
# Additional templates that should be rendered to pages, maps page names to
|
# Additional templates that should be rendered to pages, maps page names to
|
||||||
# template names.
|
# template names.
|
||||||
#html_additional_pages = {}
|
# html_additional_pages = {}
|
||||||
|
|
||||||
# If false, no module index is generated.
|
# If false, no module index is generated.
|
||||||
#html_use_modindex = True
|
# html_use_modindex = True
|
||||||
|
|
||||||
# If false, no index is generated.
|
# If false, no index is generated.
|
||||||
#html_use_index = True
|
# html_use_index = True
|
||||||
|
|
||||||
# If true, the index is split into individual pages for each letter.
|
# If true, the index is split into individual pages for each letter.
|
||||||
#html_split_index = False
|
# html_split_index = False
|
||||||
|
|
||||||
# If true, the reST sources are included in the HTML build as _sources/<name>.
|
# If true, the reST sources are included in the HTML build as _sources/<name>.
|
||||||
#html_copy_source = True
|
# html_copy_source = True
|
||||||
|
|
||||||
# If true, an OpenSearch description file will be output, and all pages will
|
# If true, an OpenSearch description file will be output, and all pages will
|
||||||
# contain a <link> tag referring to it. The value of this option must be the
|
# contain a <link> tag referring to it. The value of this option must be the
|
||||||
# base URL from which the finished HTML is served.
|
# base URL from which the finished HTML is served.
|
||||||
#html_use_opensearch = ''
|
# html_use_opensearch = ''
|
||||||
|
|
||||||
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
|
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
|
||||||
#html_file_suffix = ''
|
# html_file_suffix = ''
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
# Output file base name for HTML help builder.
|
||||||
htmlhelp_basename = 'delugedoc'
|
htmlhelp_basename = 'delugedoc'
|
||||||
|
@ -195,10 +200,10 @@ htmlhelp_basename = 'delugedoc'
|
||||||
# ------------------------
|
# ------------------------
|
||||||
|
|
||||||
# The paper size ('letter' or 'a4').
|
# The paper size ('letter' or 'a4').
|
||||||
#latex_paper_size = 'letter'
|
# latex_paper_size = 'letter'
|
||||||
|
|
||||||
# The font size ('10pt', '11pt' or '12pt').
|
# The font size ('10pt', '11pt' or '12pt').
|
||||||
#latex_font_size = '10pt'
|
# latex_font_size = '10pt'
|
||||||
|
|
||||||
# Grouping the document tree into LaTeX files. List of tuples
|
# Grouping the document tree into LaTeX files. List of tuples
|
||||||
# (source start file, target name, title, author, document class [howto/manual]).
|
# (source start file, target name, title, author, document class [howto/manual]).
|
||||||
|
@ -209,17 +214,17 @@ latex_documents = [
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top of
|
# The name of an image file (relative to this directory) to place at the top of
|
||||||
# the title page.
|
# the title page.
|
||||||
#latex_logo = None
|
# latex_logo = None
|
||||||
|
|
||||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||||
# not chapters.
|
# not chapters.
|
||||||
#latex_use_parts = False
|
# latex_use_parts = False
|
||||||
|
|
||||||
# Additional stuff for the LaTeX preamble.
|
# Additional stuff for the LaTeX preamble.
|
||||||
#latex_preamble = ''
|
# latex_preamble = ''
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
# Documents to append as an appendix to all manuals.
|
||||||
#latex_appendices = []
|
# latex_appendices = []
|
||||||
|
|
||||||
# If false, no module index is generated.
|
# If false, no module index is generated.
|
||||||
#latex_use_modindex = True
|
# latex_use_modindex = True
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -189,11 +189,11 @@ class BuildDocs(BuildDoc):
|
||||||
try:
|
try:
|
||||||
return old_import(name, globals, locals, fromlist, level)
|
return old_import(name, globals, locals, fromlist, level)
|
||||||
except ImportError as ex:
|
except ImportError as ex:
|
||||||
#sys.stdout.write("ImportError: %s\n" % ex)
|
# sys.stdout.write("ImportError: %s\n" % ex)
|
||||||
return Mock()
|
return Mock()
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
#sys.stdout.write("Skipping Exception: %s\n" % ex)
|
# sys.stdout.write("Skipping Exception: %s\n" % ex)
|
||||||
return Mock()
|
return Mock()
|
||||||
__builtins__.__import__ = new_import
|
__builtins__.__import__ = new_import
|
||||||
|
|
||||||
|
|
133
win32/icon.py
133
win32/icon.py
|
@ -28,114 +28,127 @@ import types
|
||||||
try:
|
try:
|
||||||
StringTypes = types.StringTypes
|
StringTypes = types.StringTypes
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
StringTypes = [ type("") ]
|
StringTypes = [type("")]
|
||||||
|
|
||||||
|
|
||||||
class Structure:
|
class Structure:
|
||||||
def __init__ (self):
|
def __init__(self):
|
||||||
size = self._sizeInBytes = struct.calcsize (self._format_)
|
size = self._sizeInBytes = struct.calcsize(self._format_)
|
||||||
self._fields_ = list (struct.unpack (self._format_, '\000' * size))
|
self._fields_ = list(struct.unpack(self._format_, '\000' * size))
|
||||||
indexes = self._indexes_ = {}
|
indexes = self._indexes_ = {}
|
||||||
for i in range (len (self._names_)):
|
for i in range(len(self._names_)):
|
||||||
indexes[self._names_[i]] = i
|
indexes[self._names_[i]] = i
|
||||||
def dump (self):
|
|
||||||
#print "I: DUMP of", self
|
def dump(self):
|
||||||
|
# print "I: DUMP of", self
|
||||||
for name in self._names_:
|
for name in self._names_:
|
||||||
if name[0] != '_':
|
if name[0] != '_':
|
||||||
#print "I: %20s = %s" % (name, getattr (self, name))
|
# print "I: %20s = %s" % (name, getattr(self, name))
|
||||||
pass
|
pass
|
||||||
def __getattr__ (self, name):
|
|
||||||
|
def __getattr__(self, name):
|
||||||
if name in self._names_:
|
if name in self._names_:
|
||||||
index = self._indexes_[name]
|
index = self._indexes_[name]
|
||||||
return self._fields_[index]
|
return self._fields_[index]
|
||||||
try:
|
try:
|
||||||
return self.__dict__[name]
|
return self.__dict__[name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise AttributeError, name
|
raise AttributeError(name)
|
||||||
def __setattr__ (self, name, value):
|
|
||||||
|
def __setattr__(self, name, value):
|
||||||
if name in self._names_:
|
if name in self._names_:
|
||||||
index = self._indexes_[name]
|
index = self._indexes_[name]
|
||||||
self._fields_[index] = value
|
self._fields_[index] = value
|
||||||
else:
|
else:
|
||||||
self.__dict__[name] = value
|
self.__dict__[name] = value
|
||||||
def tostring (self):
|
|
||||||
return apply (struct.pack, [self._format_,] + self._fields_)
|
|
||||||
def fromfile (self, file):
|
|
||||||
data = file.read (self._sizeInBytes)
|
|
||||||
self._fields_ = list (struct.unpack (self._format_, data))
|
|
||||||
|
|
||||||
class ICONDIRHEADER (Structure):
|
def tostring(self):
|
||||||
|
return apply(struct.pack, [self._format_, ] + self._fields_)
|
||||||
|
|
||||||
|
def fromfile(self, file):
|
||||||
|
data = file.read(self._sizeInBytes)
|
||||||
|
self._fields_ = list(struct.unpack(self._format_, data))
|
||||||
|
|
||||||
|
|
||||||
|
class ICONDIRHEADER(Structure):
|
||||||
_names_ = "idReserved", "idType", "idCount"
|
_names_ = "idReserved", "idType", "idCount"
|
||||||
_format_ = "hhh"
|
_format_ = "hhh"
|
||||||
|
|
||||||
class ICONDIRENTRY (Structure):
|
|
||||||
|
class ICONDIRENTRY(Structure):
|
||||||
_names_ = "bWidth", "bHeight", "bColorCount", "bReserved", "wPlanes", "wBitCount", "dwBytesInRes", "dwImageOffset"
|
_names_ = "bWidth", "bHeight", "bColorCount", "bReserved", "wPlanes", "wBitCount", "dwBytesInRes", "dwImageOffset"
|
||||||
_format_ = "bbbbhhii"
|
_format_ = "bbbbhhii"
|
||||||
|
|
||||||
class GRPICONDIR (Structure):
|
|
||||||
|
class GRPICONDIR(Structure):
|
||||||
_names_ = "idReserved", "idType", "idCount"
|
_names_ = "idReserved", "idType", "idCount"
|
||||||
_format_ = "hhh"
|
_format_ = "hhh"
|
||||||
|
|
||||||
class GRPICONDIRENTRY (Structure):
|
|
||||||
|
class GRPICONDIRENTRY(Structure):
|
||||||
_names_ = "bWidth", "bHeight", "bColorCount", "bReserved", "wPlanes", "wBitCount", "dwBytesInRes", "nID"
|
_names_ = "bWidth", "bHeight", "bColorCount", "bReserved", "wPlanes", "wBitCount", "dwBytesInRes", "nID"
|
||||||
_format_ = "bbbbhhih"
|
_format_ = "bbbbhhih"
|
||||||
|
|
||||||
|
|
||||||
class IconFile:
|
class IconFile:
|
||||||
def __init__ (self, path):
|
def __init__(self, path):
|
||||||
self.path = path
|
self.path = path
|
||||||
file = open (path, "rb")
|
file = open(path, "rb")
|
||||||
self.entries = []
|
self.entries = []
|
||||||
self.images = []
|
self.images = []
|
||||||
header = self.header = ICONDIRHEADER()
|
header = self.header = ICONDIRHEADER()
|
||||||
header.fromfile (file)
|
header.fromfile(file)
|
||||||
for i in range (header.idCount):
|
for i in range(header.idCount):
|
||||||
entry = ICONDIRENTRY()
|
entry = ICONDIRENTRY()
|
||||||
entry.fromfile (file)
|
entry.fromfile(file)
|
||||||
self.entries.append (entry)
|
self.entries.append(entry)
|
||||||
for e in self.entries:
|
for e in self.entries:
|
||||||
file.seek (e.dwImageOffset, 0)
|
file.seek(e.dwImageOffset, 0)
|
||||||
self.images.append (file.read (e.dwBytesInRes))
|
self.images.append(file.read(e.dwBytesInRes))
|
||||||
|
|
||||||
def grp_icon_dir (self):
|
def grp_icon_dir(self):
|
||||||
return self.header.tostring()
|
return self.header.tostring()
|
||||||
|
|
||||||
def grp_icondir_entries (self, id=1):
|
def grp_icondir_entries(self, id=1):
|
||||||
data = ""
|
data = ""
|
||||||
for entry in self.entries:
|
for entry in self.entries:
|
||||||
e = GRPICONDIRENTRY()
|
e = GRPICONDIRENTRY()
|
||||||
for n in e._names_[:-1]:
|
for n in e._names_[:-1]:
|
||||||
setattr(e, n, getattr (entry, n))
|
setattr(e, n, getattr(entry, n))
|
||||||
e.nID = id
|
e.nID = id
|
||||||
id = id + 1
|
id = id + 1
|
||||||
data = data + e.tostring()
|
data = data + e.tostring()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def CopyIcons_FromIco (dstpath, srcpath, id=1):
|
def CopyIcons_FromIco(dstpath, srcpath, id=1): # NOQA
|
||||||
import win32api #, win32con
|
import win32api
|
||||||
icons = map(IconFile, srcpath)
|
icons = map(IconFile, srcpath)
|
||||||
print "I: Updating icons from", srcpath, "to", dstpath
|
print "I: Updating icons from", srcpath, "to", dstpath
|
||||||
|
|
||||||
hdst = win32api.BeginUpdateResource (dstpath, 0)
|
hdst = win32api.BeginUpdateResource(dstpath, 0)
|
||||||
|
|
||||||
iconid = 1
|
iconid = 1
|
||||||
for i in range(len(icons)):
|
for i in range(len(icons)):
|
||||||
f = icons[i]
|
f = icons[i]
|
||||||
data = f.grp_icon_dir()
|
data = f.grp_icon_dir()
|
||||||
data = data + f.grp_icondir_entries(iconid)
|
data = data + f.grp_icondir_entries(iconid)
|
||||||
win32api.UpdateResource (hdst, RT_GROUP_ICON, i, data)
|
win32api.UpdateResource(hdst, RT_GROUP_ICON, i, data)
|
||||||
#print "I: Writing RT_GROUP_ICON %d resource with %d bytes" % (i, len(data))
|
# print "I: Writing RT_GROUP_ICON %d resource with %d bytes" % (i, len(data))
|
||||||
for data in f.images:
|
for data in f.images:
|
||||||
win32api.UpdateResource (hdst, RT_ICON, iconid, data)
|
win32api.UpdateResource(hdst, RT_ICON, iconid, data)
|
||||||
#print "I: Writing RT_ICON %d resource with %d bytes" % (iconid, len (data))
|
# print "I: Writing RT_ICON %d resource with %d bytes" % (iconid, len(data))
|
||||||
iconid = iconid + 1
|
iconid = iconid + 1
|
||||||
|
|
||||||
win32api.EndUpdateResource (hdst, 0)
|
win32api.EndUpdateResource(hdst, 0)
|
||||||
|
|
||||||
def CopyIcons (dstpath, srcpath):
|
|
||||||
import os.path, string
|
def CopyIcons(dstpath, srcpath): # NOQA
|
||||||
|
import os.path
|
||||||
|
import string
|
||||||
|
|
||||||
if type(srcpath) in StringTypes:
|
if type(srcpath) in StringTypes:
|
||||||
srcpath = [ srcpath ]
|
srcpath = [srcpath]
|
||||||
|
|
||||||
def splitter(s):
|
def splitter(s):
|
||||||
try:
|
try:
|
||||||
|
@ -145,7 +158,7 @@ def CopyIcons (dstpath, srcpath):
|
||||||
return s, None
|
return s, None
|
||||||
|
|
||||||
srcpath = map(splitter, srcpath)
|
srcpath = map(splitter, srcpath)
|
||||||
#print "I: SRCPATH", srcpath
|
# print "I: SRCPATH", srcpath
|
||||||
|
|
||||||
if len(srcpath) > 1:
|
if len(srcpath) > 1:
|
||||||
# At the moment, we support multiple icons only from .ico files
|
# At the moment, we support multiple icons only from .ico files
|
||||||
|
@ -153,36 +166,36 @@ def CopyIcons (dstpath, srcpath):
|
||||||
for s in srcpath:
|
for s in srcpath:
|
||||||
e = os.path.splitext(s[0])[1]
|
e = os.path.splitext(s[0])[1]
|
||||||
if string.lower(e) != '.ico':
|
if string.lower(e) != '.ico':
|
||||||
raise ValueError, "multiple icons supported only from .ico files"
|
raise ValueError("multiple icons supported only from .ico files")
|
||||||
if s[1] is not None:
|
if s[1] is not None:
|
||||||
raise ValueError, "index not allowed for .ico files"
|
raise ValueError("index not allowed for .ico files")
|
||||||
srcs.append(s[0])
|
srcs.append(s[0])
|
||||||
return CopyIcons_FromIco(dstpath, srcs)
|
return CopyIcons_FromIco(dstpath, srcs)
|
||||||
|
|
||||||
srcpath,index = srcpath[0]
|
srcpath, index = srcpath[0]
|
||||||
srcext = os.path.splitext(srcpath)[1]
|
srcext = os.path.splitext(srcpath)[1]
|
||||||
if string.lower (srcext) == '.ico':
|
if string.lower(srcext) == '.ico':
|
||||||
return CopyIcons_FromIco (dstpath, [srcpath])
|
return CopyIcons_FromIco(dstpath, [srcpath])
|
||||||
if index is not None:
|
if index is not None:
|
||||||
print "I: Updating icons from", srcpath, ", %d to" % index, dstpath
|
print "I: Updating icons from", srcpath, ", %d to" % index, dstpath
|
||||||
else:
|
else:
|
||||||
print "I: Updating icons from", srcpath, "to", dstpath
|
print "I: Updating icons from", srcpath, "to", dstpath
|
||||||
import win32api #, win32con
|
import win32api
|
||||||
hdst = win32api.BeginUpdateResource (dstpath, 0)
|
hdst = win32api.BeginUpdateResource(dstpath, 0)
|
||||||
hsrc = win32api.LoadLibraryEx (srcpath, 0, LOAD_LIBRARY_AS_DATAFILE)
|
hsrc = win32api.LoadLibraryEx(srcpath, 0, LOAD_LIBRARY_AS_DATAFILE)
|
||||||
if index is None:
|
if index is None:
|
||||||
grpname = win32api.EnumResourceNames (hsrc, RT_GROUP_ICON)[0]
|
grpname = win32api.EnumResourceNames(hsrc, RT_GROUP_ICON)[0]
|
||||||
elif index >= 0:
|
elif index >= 0:
|
||||||
grpname = win32api.EnumResourceNames (hsrc, RT_GROUP_ICON)[index]
|
grpname = win32api.EnumResourceNames(hsrc, RT_GROUP_ICON)[index]
|
||||||
else:
|
else:
|
||||||
grpname = -index
|
grpname = -index
|
||||||
data = win32api.LoadResource (hsrc, RT_GROUP_ICON, grpname)
|
data = win32api.LoadResource(hsrc, RT_GROUP_ICON, grpname)
|
||||||
win32api.UpdateResource (hdst, RT_GROUP_ICON, grpname, data)
|
win32api.UpdateResource(hdst, RT_GROUP_ICON, grpname, data)
|
||||||
for iconname in win32api.EnumResourceNames (hsrc, RT_ICON):
|
for iconname in win32api.EnumResourceNames(hsrc, RT_ICON):
|
||||||
data = win32api.LoadResource (hsrc, RT_ICON, iconname)
|
data = win32api.LoadResource(hsrc, RT_ICON, iconname)
|
||||||
win32api.UpdateResource (hdst, RT_ICON, iconname, data)
|
win32api.UpdateResource(hdst, RT_ICON, iconname, data)
|
||||||
win32api.FreeLibrary (hsrc)
|
win32api.FreeLibrary(hsrc)
|
||||||
win32api.EndUpdateResource (hdst, 0)
|
win32api.EndUpdateResource(hdst, 0)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue