diff --git a/deluge/plugins/Stats/deluge/plugins/stats/core.py b/deluge/plugins/Stats/deluge/plugins/stats/core.py index ab44d2f31..57bc00497 100644 --- a/deluge/plugins/Stats/deluge/plugins/stats/core.py +++ b/deluge/plugins/Stats/deluge/plugins/stats/core.py @@ -164,7 +164,7 @@ class Core(CorePluginBase): update_interval(300, 30, 10) except Exception as ex: - log.error("Stats update error %s" % ex) + log.error("Stats update error %s", ex) return True def save_stats(self): @@ -173,7 +173,7 @@ class Core(CorePluginBase): self.saved_stats.config.update(self.get_totals()) self.saved_stats.save() except Exception as ex: - log.error("Stats save error", ex) + log.error("Stats save error %s", ex) return True # export: diff --git a/deluge/plugins/Stats/deluge/plugins/stats/graph.py b/deluge/plugins/Stats/deluge/plugins/stats/graph.py index f72e8a430..085f4e261 100644 --- a/deluge/plugins/Stats/deluge/plugins/stats/graph.py +++ b/deluge/plugins/Stats/deluge/plugins/stats/graph.py @@ -182,8 +182,8 @@ class Graph: """Given a value x create an array of tick points to got with the graph The number of ticks returned can be constrained by limit, minimum of 3 """ - # Limit is the number of ticks which is 1 + the number of steps as we - # count the 0 tick in limit + # Limit is the number of ticks which is 1 + the number of steps as we + # count the 0 tick in limit if limit is not None: if limit < 3: limit = 2 @@ -194,9 +194,9 @@ class Graph: scale = self.left_axis['formatter_scale'](x) x = x / float(scale) - # Find the largest power of 10 less than x - log = math.log10(x) - intbit = math.floor(log) + # Find the largest power of 10 less than x + comm_log = math.log10(x) + intbit = math.floor(comm_log) interval = math.pow(10, intbit) steps = int(math.ceil(x / interval)) diff --git a/deluge/plugins/Stats/deluge/plugins/stats/gtkui.py b/deluge/plugins/Stats/deluge/plugins/stats/gtkui.py index 74409aabb..5104501d5 100644 --- a/deluge/plugins/Stats/deluge/plugins/stats/gtkui.py +++ b/deluge/plugins/Stats/deluge/plugins/stats/gtkui.py @@ -46,9 +46,9 @@ DEFAULT_CONF = {'version': 1, } -def neat_time(column, cell, model, iter): +def neat_time(column, cell, model, data): """Render seconds as seconds or minutes with label""" - seconds = model.get_value(iter, 0) + seconds = model.get_value(data, 0) if seconds > 60: text = "%d %s" % (seconds / 60, _("minutes")) elif seconds == 60: @@ -62,7 +62,7 @@ def neat_time(column, cell, model, iter): def int_str(number): - return (str(int(number))) + return str(int(number)) def gtk_to_graph_color(color): @@ -186,15 +186,15 @@ class GraphsTab(Tab): self.intervals_combo.set_model(liststore) try: current = intervals.index(self.selected_interval) - except: + except Exception: current = 0 # should select the value saved in config self.intervals_combo.set_active(current) def _on_selected_interval_changed(self, combobox): model = combobox.get_model() - iter = combobox.get_active_iter() - self.selected_interval = model.get_value(iter, 0) + tree_iter = combobox.get_active_iter() + self.selected_interval = model.get_value(tree_iter, 0) self.update() return True @@ -241,7 +241,7 @@ class GtkUI(GtkPluginBase): try: color_btn = self.glade.get_widget("%s_%s_color" % (graph, value)) gtkconf[graph][value] = str(color_btn.get_color()) - except: + except Exception: gtkconf[graph][value] = DEFAULT_CONF['colors'][graph][value] self.config['colors'] = gtkconf self.graphs_tab.set_colors(self.config['colors']) @@ -255,8 +255,8 @@ class GtkUI(GtkPluginBase): try: color_btn = self.glade.get_widget("%s_%s_color" % (graph, value)) color_btn.set_color(gtk.gdk.Color(color)) - except: - log.debug("Unable to set %s %s %s" % (graph, value, color)) + except Exception: + log.debug("Unable to set %s %s %s", graph, value, color) client.stats.get_config().addCallback(self.cb_get_config) def cb_get_config(self, config): diff --git a/deluge/plugins/Stats/deluge/plugins/stats/tests/.test.py b/deluge/plugins/Stats/deluge/plugins/stats/tests/.test.py index 10491c49a..12e2f3775 100644 --- a/deluge/plugins/Stats/deluge/plugins/stats/tests/.test.py +++ b/deluge/plugins/Stats/deluge/plugins/stats/tests/.test.py @@ -9,12 +9,13 @@ sclient.set_core_uri() def test_sync(): - if 1: - upload = sclient.graph_get_upload() - download = sclient.graph_get_download() - print(upload) - print(download) - else: + + upload = sclient.graph_get_upload() + download = sclient.graph_get_download() + print(upload) + print(download) + + """ upload = [66804, 66915, 66974, 67447, 67540, 67318, 67320, 67249, 66659, 66489, 67027, 66914, 66802, 67303, 67654, 67643, 67763, 67528, 67523, 67431, 67214, 66939, 67316, 67020, 66881, 67103, 67377, 67141, 67366, 67492, 67375, 67203, 67056, 67010, 67029, 66741, 66695, 66868, 66805, 66264, 66249, 66317, @@ -37,6 +38,7 @@ def test_sync(): 15268, 14793, 15305, 16354, 16720, 17502, 17857, 16622, 18447, 19929, 31138, 36965, 36158, 32795, 30445, 21997, 18100, 22491, 27227, 29317, 32436, 35700, 39140, 36258, 33697, 24751, 20354, 8211, 3836, 1560, 834, 2034, 1744, 1637, 1637, 1637, 0, 0] + """ from .graph import NetworkGraph n = NetworkGraph() @@ -81,8 +83,8 @@ def test_write(): def __init__(self): self.data = [] - def write(self, str): - self.data.append(str) + def write(self, string): + self.data.append(string) g = graph.Graph() g.add_stat('download_rate', color=graph.green) diff --git a/deluge/plugins/Stats/deluge/plugins/stats/tests/test_stats.py b/deluge/plugins/Stats/deluge/plugins/stats/tests/test_stats.py index e992ba64d..bf501d486 100644 --- a/deluge/plugins/Stats/deluge/plugins/stats/tests/test_stats.py +++ b/deluge/plugins/Stats/deluge/plugins/stats/tests/test_stats.py @@ -4,6 +4,7 @@ # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # +from __future__ import print_function from twisted.internet import defer from twisted.trial import unittest diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 98cedb8c2..ddda2f5f0 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -941,7 +941,7 @@ class Preferences(component.Component): def on_plugin_action(arg): if not value and arg is False: - log.warn("Failed to enable plugin '%s'", name) + log.warn("Failed to enable plugin '%s'", name) self.plugin_liststore.set_value(row, 1, False) d.addBoth(on_plugin_action)