mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-26 10:05:19 +00:00
The Stats plugin should not be using the old logging system.
This commit is contained in:
parent
e016b2106f
commit
bad228645c
@ -33,11 +33,11 @@
|
|||||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||||
# this exception statement from your version. If you delete this exception
|
# this exception statement from your version. If you delete this exception
|
||||||
|
|
||||||
from twisted.internet.task import LoopingCall
|
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
|
from twisted.internet.task import LoopingCall
|
||||||
|
|
||||||
import deluge
|
import deluge
|
||||||
from deluge.log import LOG as log
|
|
||||||
from deluge.plugins.pluginbase import CorePluginBase
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge import configmanager
|
from deluge import configmanager
|
||||||
@ -57,6 +57,8 @@ DEFAULT_TOTALS = {
|
|||||||
"stats": {}
|
"stats": {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
def get_key(config, key):
|
def get_key(config, key):
|
||||||
try:
|
try:
|
||||||
return config[key]
|
return config[key]
|
||||||
@ -78,14 +80,14 @@ class Core(CorePluginBase):
|
|||||||
self.stats ={}
|
self.stats ={}
|
||||||
self.count = {}
|
self.count = {}
|
||||||
self.intervals = [1, 5, 30, 300]
|
self.intervals = [1, 5, 30, 300]
|
||||||
|
|
||||||
self.last_update = {}
|
self.last_update = {}
|
||||||
t = time.time()
|
t = time.time()
|
||||||
for i in self.intervals:
|
for i in self.intervals:
|
||||||
self.stats[i] = {}
|
self.stats[i] = {}
|
||||||
self.last_update[i] = t
|
self.last_update[i] = t
|
||||||
self.count[i] = 0
|
self.count[i] = 0
|
||||||
|
|
||||||
|
|
||||||
self.config = configmanager.ConfigManager("stats.conf", DEFAULT_PREFS)
|
self.config = configmanager.ConfigManager("stats.conf", DEFAULT_PREFS)
|
||||||
self.saved_stats = configmanager.ConfigManager("stats.totals", DEFAULT_TOTALS)
|
self.saved_stats = configmanager.ConfigManager("stats.totals", DEFAULT_TOTALS)
|
||||||
@ -162,7 +164,7 @@ class Core(CorePluginBase):
|
|||||||
stat_list.insert(0, 0)
|
stat_list.insert(0, 0)
|
||||||
if len(stat_list) > self.length:
|
if len(stat_list) > self.length:
|
||||||
stat_list.pop()
|
stat_list.pop()
|
||||||
|
|
||||||
def update_interval(interval, base, multiplier):
|
def update_interval(interval, base, multiplier):
|
||||||
self.count[interval] = self.count[interval] + 1
|
self.count[interval] = self.count[interval] + 1
|
||||||
if self.count[interval] >= interval:
|
if self.count[interval] >= interval:
|
||||||
@ -206,7 +208,7 @@ class Core(CorePluginBase):
|
|||||||
for key in keys:
|
for key in keys:
|
||||||
if key in self.stats[interval]:
|
if key in self.stats[interval]:
|
||||||
stats_dict[key] = self.stats[interval][key]
|
stats_dict[key] = self.stats[interval][key]
|
||||||
|
|
||||||
stats_dict["_last_update"] = self.last_update[interval]
|
stats_dict["_last_update"] = self.last_update[interval]
|
||||||
stats_dict["_length"] = self.config["length"]
|
stats_dict["_length"] = self.config["length"]
|
||||||
stats_dict["_update_interval"] = interval
|
stats_dict["_update_interval"] = interval
|
||||||
|
@ -40,9 +40,11 @@ port of old plugin by markybob.
|
|||||||
import time
|
import time
|
||||||
import math
|
import math
|
||||||
import cairo
|
import cairo
|
||||||
from deluge.log import LOG as log
|
import logging
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
black = (0, 0, 0)
|
black = (0, 0, 0)
|
||||||
gray = (0.75, 0.75, 0.75)
|
gray = (0.75, 0.75, 0.75)
|
||||||
white = (1.0, 1.0, 1.0)
|
white = (1.0, 1.0, 1.0)
|
||||||
@ -137,7 +139,7 @@ class Graph:
|
|||||||
duration = self.length * self.interval
|
duration = self.length * self.interval
|
||||||
start = self.last_update - duration
|
start = self.last_update - duration
|
||||||
ratio = (right - left) / float(duration)
|
ratio = (right - left) / float(duration)
|
||||||
|
|
||||||
if duration < 1800 * 10:
|
if duration < 1800 * 10:
|
||||||
#try rounding to nearest 1min, 5mins, 10mins, 30mins
|
#try rounding to nearest 1min, 5mins, 10mins, 30mins
|
||||||
for step in [60, 300, 600, 1800]:
|
for step in [60, 300, 600, 1800]:
|
||||||
@ -194,7 +196,7 @@ class Graph:
|
|||||||
|
|
||||||
self.draw_x_axis(bounds)
|
self.draw_x_axis(bounds)
|
||||||
self.draw_left_axis(bounds, y_ticks, y_tick_text)
|
self.draw_left_axis(bounds, y_ticks, y_tick_text)
|
||||||
|
|
||||||
def intervalise(self, x, limit=None):
|
def intervalise(self, x, limit=None):
|
||||||
"""Given a value x create an array of tick points to got with the 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
|
The number of ticks returned can be constrained by limit, minimum of 3
|
||||||
@ -215,9 +217,9 @@ class Graph:
|
|||||||
log = math.log10(x)
|
log = math.log10(x)
|
||||||
intbit = math.floor(log)
|
intbit = math.floor(log)
|
||||||
|
|
||||||
interval = math.pow(10, intbit)
|
interval = math.pow(10, intbit)
|
||||||
steps = int(math.ceil(x / interval))
|
steps = int(math.ceil(x / interval))
|
||||||
|
|
||||||
if steps <= 1 and (limit is None or limit >= 10*steps):
|
if steps <= 1 and (limit is None or limit >= 10*steps):
|
||||||
interval = interval * 0.1
|
interval = interval * 0.1
|
||||||
steps = steps * 10
|
steps = steps * 10
|
||||||
@ -234,7 +236,7 @@ class Graph:
|
|||||||
interval = interval * 5
|
interval = interval * 5
|
||||||
else:
|
else:
|
||||||
interval = interval * 2
|
interval = interval * 2
|
||||||
|
|
||||||
intervals = [i * interval * scale for i in xrange(1+int(math.ceil(x/ interval)))]
|
intervals = [i * interval * scale for i in xrange(1+int(math.ceil(x/ interval)))]
|
||||||
return intervals
|
return intervals
|
||||||
|
|
||||||
|
@ -37,12 +37,12 @@
|
|||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
import gobject
|
import gobject
|
||||||
|
import logging
|
||||||
from gtk.glade import XML
|
from gtk.glade import XML
|
||||||
|
|
||||||
import graph
|
import graph
|
||||||
import deluge
|
import deluge
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.log import LOG as log
|
|
||||||
from deluge.common import fspeed
|
from deluge.common import fspeed
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.ui.gtkui.torrentdetails import Tab
|
from deluge.ui.gtkui.torrentdetails import Tab
|
||||||
@ -50,6 +50,8 @@ from deluge.plugins.pluginbase import GtkPluginBase
|
|||||||
|
|
||||||
import common
|
import common
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_CONF = { 'version': 1,
|
DEFAULT_CONF = { 'version': 1,
|
||||||
'colors' :{
|
'colors' :{
|
||||||
'bandwidth_graph': {'upload_rate': str(gtk.gdk.Color("blue")),
|
'bandwidth_graph': {'upload_rate': str(gtk.gdk.Color("blue")),
|
||||||
|
@ -37,17 +37,19 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
import logging
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.plugins.pluginbase import WebPluginBase
|
from deluge.plugins.pluginbase import WebPluginBase
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class WebUI(WebPluginBase):
|
class WebUI(WebPluginBase):
|
||||||
|
|
||||||
scripts = [get_resource("stats.js")]
|
scripts = [get_resource("stats.js")]
|
||||||
|
|
||||||
# The enable and disable methods are not scrictly required on the WebUI
|
# The enable and disable methods are not scrictly required on the WebUI
|
||||||
# plugins. They are only here if you need to register images/stylesheets
|
# plugins. They are only here if you need to register images/stylesheets
|
||||||
# with the webserver.
|
# with the webserver.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user