mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-18 06:16:29 +00:00
[Py2to3] Passes libfuturize.fixes.fix_division_safe
This commit is contained in:
parent
81334389a9
commit
9fab98a6ce
@ -8,7 +8,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
"""Common functions for various parts of Deluge to use."""
|
"""Common functions for various parts of Deluge to use."""
|
||||||
from __future__ import print_function
|
from __future__ import division, print_function
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import functools
|
import functools
|
||||||
@ -321,16 +321,16 @@ def fsize(fsize_b, precision=1, shortform=False):
|
|||||||
|
|
||||||
# Bigger than 1 TiB
|
# Bigger than 1 TiB
|
||||||
if fsize_b >= 1099511627776:
|
if fsize_b >= 1099511627776:
|
||||||
return "%.*f %s" % (precision, fsize_b / 1099511627776.0, tib_txt_short if shortform else tib_txt)
|
return "%.*f %s" % (precision, fsize_b / 1099511627776, tib_txt_short if shortform else tib_txt)
|
||||||
# Bigger than 1 GiB
|
# Bigger than 1 GiB
|
||||||
elif fsize_b >= 1073741824:
|
elif fsize_b >= 1073741824:
|
||||||
return "%.*f %s" % (precision, fsize_b / 1073741824.0, gib_txt_short if shortform else gib_txt)
|
return "%.*f %s" % (precision, fsize_b / 1073741824, gib_txt_short if shortform else gib_txt)
|
||||||
# Bigger than 1 MiB
|
# Bigger than 1 MiB
|
||||||
elif fsize_b >= 1048576:
|
elif fsize_b >= 1048576:
|
||||||
return "%.*f %s" % (precision, fsize_b / 1048576.0, mib_txt_short if shortform else mib_txt)
|
return "%.*f %s" % (precision, fsize_b / 1048576, mib_txt_short if shortform else mib_txt)
|
||||||
# Bigger than 1 KiB
|
# Bigger than 1 KiB
|
||||||
elif fsize_b >= 1024:
|
elif fsize_b >= 1024:
|
||||||
return "%.*f %s" % (precision, fsize_b / 1024.0, kib_txt_short if shortform else kib_txt)
|
return "%.*f %s" % (precision, fsize_b / 1024, kib_txt_short if shortform else kib_txt)
|
||||||
else:
|
else:
|
||||||
return "%d %s" % (fsize_b, byte_txt)
|
return "%d %s" % (fsize_b, byte_txt)
|
||||||
|
|
||||||
@ -376,16 +376,16 @@ def fspeed(bps, precision=1, shortform=False):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
fspeed_kb = bps / 1024.0
|
fspeed_kb = bps / 1024
|
||||||
if fspeed_kb < 1024:
|
if fspeed_kb < 1024:
|
||||||
return "%.*f %s" % (precision, fspeed_kb, _("K/s") if shortform else _("KiB/s"))
|
return "%.*f %s" % (precision, fspeed_kb, _("K/s") if shortform else _("KiB/s"))
|
||||||
fspeed_mb = fspeed_kb / 1024.0
|
fspeed_mb = fspeed_kb / 1024
|
||||||
if fspeed_mb < 1024:
|
if fspeed_mb < 1024:
|
||||||
return "%.*f %s" % (precision, fspeed_mb, _("M/s") if shortform else _("MiB/s"))
|
return "%.*f %s" % (precision, fspeed_mb, _("M/s") if shortform else _("MiB/s"))
|
||||||
fspeed_gb = fspeed_mb / 1024.0
|
fspeed_gb = fspeed_mb / 1024
|
||||||
if fspeed_gb < 1024:
|
if fspeed_gb < 1024:
|
||||||
return "%.*f %s" % (precision, fspeed_gb, _("G/s") if shortform else _("GiB/s"))
|
return "%.*f %s" % (precision, fspeed_gb, _("G/s") if shortform else _("GiB/s"))
|
||||||
fspeed_tb = fspeed_gb / 1024.0
|
fspeed_tb = fspeed_gb / 1024
|
||||||
return "%.*f %s" % (precision, fspeed_tb, _("T/s") if shortform else _("TiB/s"))
|
return "%.*f %s" % (precision, fspeed_tb, _("T/s") if shortform else _("TiB/s"))
|
||||||
|
|
||||||
|
|
||||||
@ -433,23 +433,23 @@ def ftime(seconds):
|
|||||||
return ""
|
return ""
|
||||||
if seconds < 60:
|
if seconds < 60:
|
||||||
return '%ds' % (seconds)
|
return '%ds' % (seconds)
|
||||||
minutes = seconds / 60
|
minutes = seconds // 60
|
||||||
if minutes < 60:
|
if minutes < 60:
|
||||||
seconds = seconds % 60
|
seconds = seconds % 60
|
||||||
return '%dm %ds' % (minutes, seconds)
|
return '%dm %ds' % (minutes, seconds)
|
||||||
hours = minutes / 60
|
hours = minutes // 60
|
||||||
if hours < 24:
|
if hours < 24:
|
||||||
minutes = minutes % 60
|
minutes = minutes % 60
|
||||||
return '%dh %dm' % (hours, minutes)
|
return '%dh %dm' % (hours, minutes)
|
||||||
days = hours / 24
|
days = hours // 24
|
||||||
if days < 7:
|
if days < 7:
|
||||||
hours = hours % 24
|
hours = hours % 24
|
||||||
return '%dd %dh' % (days, hours)
|
return '%dd %dh' % (days, hours)
|
||||||
weeks = days / 7
|
weeks = days // 7
|
||||||
if weeks < 52:
|
if weeks < 52:
|
||||||
days = days % 7
|
days = days % 7
|
||||||
return '%dw %dd' % (weeks, days)
|
return '%dw %dd' % (weeks, days)
|
||||||
years = weeks / 52
|
years = weeks // 52
|
||||||
weeks = weeks % 52
|
weeks = weeks % 52
|
||||||
return '%dy %dw' % (years, weeks)
|
return '%dy %dw' % (years, weeks)
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import glob
|
import glob
|
||||||
import logging
|
import logging
|
||||||
@ -413,13 +415,12 @@ class Core(component.Component):
|
|||||||
|
|
||||||
# Add in a couple ratios
|
# Add in a couple ratios
|
||||||
try:
|
try:
|
||||||
cache["write_hit_ratio"] = float((cache["blocks_written"] -
|
cache["write_hit_ratio"] = (cache["blocks_written"] - cache["writes"]) / cache["blocks_written"]
|
||||||
cache["writes"])) / float(cache["blocks_written"])
|
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
cache["write_hit_ratio"] = 0.0
|
cache["write_hit_ratio"] = 0.0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cache["read_hit_ratio"] = float(cache["blocks_read_hit"]) / float(cache["blocks_read"])
|
cache["read_hit_ratio"] = cache["blocks_read_hit"] / cache["blocks_read"]
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
cache["read_hit_ratio"] = 0.0
|
cache["read_hit_ratio"] = 0.0
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from hashlib import sha1 as sha
|
from hashlib import sha1 as sha
|
||||||
@ -102,11 +104,11 @@ class TorrentMetadata(object):
|
|||||||
else:
|
else:
|
||||||
# We need to calculate a piece size
|
# We need to calculate a piece size
|
||||||
piece_size = 16384
|
piece_size = 16384
|
||||||
while (datasize / piece_size) > 1024 and piece_size < (8192 * 1024):
|
while (datasize // piece_size) > 1024 and piece_size < (8192 * 1024):
|
||||||
piece_size *= 2
|
piece_size *= 2
|
||||||
|
|
||||||
# Calculate the number of pieces we will require for the data
|
# Calculate the number of pieces we will require for the data
|
||||||
num_pieces = datasize / piece_size
|
num_pieces = datasize // piece_size
|
||||||
if datasize % piece_size:
|
if datasize % piece_size:
|
||||||
num_pieces += 1
|
num_pieces += 1
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
@ -169,7 +171,7 @@ def makeinfo(path, piece_length, progress, name=None, content_type=None, private
|
|||||||
totalsize += os.path.getsize(f)
|
totalsize += os.path.getsize(f)
|
||||||
if totalsize >= piece_length:
|
if totalsize >= piece_length:
|
||||||
import math
|
import math
|
||||||
num_pieces = math.ceil(float(totalsize) / float(piece_length))
|
num_pieces = math.ceil(totalsize / piece_length)
|
||||||
else:
|
else:
|
||||||
num_pieces = 1
|
num_pieces = 1
|
||||||
|
|
||||||
@ -216,7 +218,7 @@ def makeinfo(path, piece_length, progress, name=None, content_type=None, private
|
|||||||
else:
|
else:
|
||||||
size = os.path.getsize(path)
|
size = os.path.getsize(path)
|
||||||
if size >= piece_length:
|
if size >= piece_length:
|
||||||
num_pieces = size / piece_length
|
num_pieces = size // piece_length
|
||||||
else:
|
else:
|
||||||
num_pieces = 1
|
num_pieces = 1
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@ -288,7 +290,7 @@ class Core(CorePluginBase):
|
|||||||
"""
|
"""
|
||||||
def on_retrieve_data(data, current_length, total_length):
|
def on_retrieve_data(data, current_length, total_length):
|
||||||
if total_length:
|
if total_length:
|
||||||
fp = float(current_length) / total_length
|
fp = current_length / total_length
|
||||||
if fp > 1.0:
|
if fp > 1.0:
|
||||||
fp = 1.0
|
fp = 1.0
|
||||||
else:
|
else:
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
@ -38,9 +40,9 @@ class SchedulerSelectWidget(gtk.DrawingArea):
|
|||||||
self.connect("motion_notify_event", self.mouse_hover)
|
self.connect("motion_notify_event", self.mouse_hover)
|
||||||
self.connect("leave_notify_event", self.mouse_leave)
|
self.connect("leave_notify_event", self.mouse_leave)
|
||||||
|
|
||||||
self.colors = [[115.0 / 255, 210.0 / 255, 22.0 / 255],
|
self.colors = [[115 / 255, 210 / 255, 22 / 255],
|
||||||
[237.0 / 255, 212.0 / 255, 0.0 / 255],
|
[237 / 255, 212 / 255, 0 / 255],
|
||||||
[204.0 / 255, 0.0 / 255, 0.0 / 255]]
|
[204 / 255, 0 / 255, 0 / 255]]
|
||||||
self.button_state = [[0] * 7 for dummy in xrange(24)]
|
self.button_state = [[0] * 7 for dummy in xrange(24)]
|
||||||
|
|
||||||
self.start_point = [0, 0]
|
self.start_point = [0, 0]
|
||||||
@ -70,8 +72,8 @@ class SchedulerSelectWidget(gtk.DrawingArea):
|
|||||||
context.set_source_rgba(self.colors[self.button_state[x][y]][0],
|
context.set_source_rgba(self.colors[self.button_state[x][y]][0],
|
||||||
self.colors[self.button_state[x][y]][1],
|
self.colors[self.button_state[x][y]][1],
|
||||||
self.colors[self.button_state[x][y]][2], 0.7)
|
self.colors[self.button_state[x][y]][2], 0.7)
|
||||||
context.rectangle(width * (6 * x / 145.0 + 1 / 145.0), height * (6 * y / 43.0 + 1 / 43.0),
|
context.rectangle(width * (6 * x / 145 + 1 / 145), height * (6 * y / 43 + 1 / 43),
|
||||||
5 * width / 145.0, 5 * height / 43.0)
|
5 * width / 145, 5 * height / 43)
|
||||||
context.fill_preserve()
|
context.fill_preserve()
|
||||||
context.set_source_rgba(0.5, 0.5, 0.5, 0.5)
|
context.set_source_rgba(0.5, 0.5, 0.5, 0.5)
|
||||||
context.stroke()
|
context.stroke()
|
||||||
@ -79,8 +81,8 @@ class SchedulerSelectWidget(gtk.DrawingArea):
|
|||||||
# coordinates --> which box
|
# coordinates --> which box
|
||||||
def get_point(self, event):
|
def get_point(self, event):
|
||||||
size = self.window.get_size()
|
size = self.window.get_size()
|
||||||
x = int((event.x - size[0] * 0.5 / 145.0) / (6 * size[0] / 145.0))
|
x = int((event.x - size[0] * 0.5 / 145) / (6 * size[0] / 145))
|
||||||
y = int((event.y - size[1] * 0.5 / 43.0) / (6 * size[1] / 43.0))
|
y = int((event.y - size[1] * 0.5 / 43) / (6 * size[1] / 43))
|
||||||
|
|
||||||
if x > 23:
|
if x > 23:
|
||||||
x = 23
|
x = 23
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -46,7 +48,7 @@ def get_key(config, key):
|
|||||||
|
|
||||||
def mean(items):
|
def mean(items):
|
||||||
try:
|
try:
|
||||||
return sum(items) / len(items)
|
return sum(items) // len(items)
|
||||||
except Exception:
|
except Exception:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
"""
|
"""
|
||||||
port of old plugin by markybob.
|
port of old plugin by markybob.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import time
|
import time
|
||||||
@ -40,7 +43,7 @@ def size_formatter_scale(value):
|
|||||||
scale = 1.0
|
scale = 1.0
|
||||||
for i in range(0, 3):
|
for i in range(0, 3):
|
||||||
scale = scale * 1024.0
|
scale = scale * 1024.0
|
||||||
if value / scale < 1024:
|
if value // scale < 1024:
|
||||||
return scale
|
return scale
|
||||||
|
|
||||||
|
|
||||||
@ -118,22 +121,22 @@ class Graph(object):
|
|||||||
(left, top, right, bottom) = bounds
|
(left, top, right, bottom) = bounds
|
||||||
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) / 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]:
|
||||||
if duration / step < 10:
|
if duration // step < 10:
|
||||||
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...
|
||||||
seconds_to_step = math.ceil(start / float(x_step)) * x_step - start
|
seconds_to_step = math.ceil(start / x_step) * x_step - start
|
||||||
|
|
||||||
for i in xrange(0, duration / x_step + 1):
|
for i in xrange(0, duration // x_step + 1):
|
||||||
text = time.strftime('%H:%M', time.localtime(start + seconds_to_step + i * x_step))
|
text = time.strftime('%H:%M', time.localtime(start + seconds_to_step + i * x_step))
|
||||||
# + 0.5 to allign x to nearest pixel
|
# + 0.5 to allign x to nearest pixel
|
||||||
x = int(ratio * (seconds_to_step + i * x_step) + left) + 0.5
|
x = int(ratio * (seconds_to_step + i * x_step) + left) + 0.5
|
||||||
@ -144,10 +147,10 @@ class Graph(object):
|
|||||||
|
|
||||||
def draw_graph(self):
|
def draw_graph(self):
|
||||||
font_extents = self.ctx.font_extents()
|
font_extents = self.ctx.font_extents()
|
||||||
x_axis_space = font_extents[2] + 2 + self.line_size / 2.0
|
x_axis_space = font_extents[2] + 2 + self.line_size / 2
|
||||||
plot_height = self.height - x_axis_space
|
plot_height = self.height - x_axis_space
|
||||||
# lets say we need 2n-1*font height pixels to plot the y ticks
|
# lets say we need 2n-1*font height pixels to plot the y ticks
|
||||||
tick_limit = (plot_height / font_extents[3]) # / 2.0
|
tick_limit = plot_height / font_extents[3]
|
||||||
|
|
||||||
max_value = 0
|
max_value = 0
|
||||||
for stat in self.stat_info:
|
for stat in self.stat_info:
|
||||||
@ -171,7 +174,7 @@ class Graph(object):
|
|||||||
return math.ceil(te[4] - te[0])
|
return math.ceil(te[4] - te[0])
|
||||||
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
|
||||||
# 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)
|
||||||
|
|
||||||
@ -192,7 +195,7 @@ class Graph(object):
|
|||||||
scale = 1
|
scale = 1
|
||||||
if 'formatter_scale' in self.left_axis:
|
if 'formatter_scale' in self.left_axis:
|
||||||
scale = self.left_axis['formatter_scale'](x)
|
scale = self.left_axis['formatter_scale'](x)
|
||||||
x = x / float(scale)
|
x = x / scale
|
||||||
|
|
||||||
# Find the largest power of 10 less than x
|
# Find the largest power of 10 less than x
|
||||||
comm_log = math.log10(x)
|
comm_log = math.log10(x)
|
||||||
@ -212,7 +215,7 @@ class Graph(object):
|
|||||||
steps = steps * 2
|
steps = steps * 2
|
||||||
|
|
||||||
if limit is not None and steps > limit:
|
if limit is not None and steps > limit:
|
||||||
multi = steps / float(limit)
|
multi = steps / limit
|
||||||
if multi > 2:
|
if multi > 2:
|
||||||
interval = interval * 5
|
interval = interval * 5
|
||||||
else:
|
else:
|
||||||
@ -261,7 +264,7 @@ class Graph(object):
|
|||||||
self.ctx.line_to(right, int(bottom - values[0] * ratio))
|
self.ctx.line_to(right, int(bottom - values[0] * ratio))
|
||||||
|
|
||||||
x = right
|
x = right
|
||||||
step = (right - left) / float(self.length - 1)
|
step = (right - left) / (self.length - 1)
|
||||||
for i, value in enumerate(values):
|
for i, value in enumerate(values):
|
||||||
if i == self.length - 1:
|
if i == self.length - 1:
|
||||||
x = left
|
x = left
|
||||||
@ -290,7 +293,7 @@ class Graph(object):
|
|||||||
height = fe[2]
|
height = fe[2]
|
||||||
x_bearing = te[0]
|
x_bearing = te[0]
|
||||||
width = te[2]
|
width = te[2]
|
||||||
self.ctx.move_to(int(x - width / 2.0 + x_bearing), int(y + height))
|
self.ctx.move_to(int(x - width / 2 + x_bearing), int(y + height))
|
||||||
self.ctx.set_source_rgba(*self.black)
|
self.ctx.set_source_rgba(*self.black)
|
||||||
self.ctx.show_text(text)
|
self.ctx.show_text(text)
|
||||||
|
|
||||||
@ -302,7 +305,7 @@ class Graph(object):
|
|||||||
ascent = fe[0]
|
ascent = fe[0]
|
||||||
x_bearing = te[0]
|
x_bearing = te[0]
|
||||||
width = te[4]
|
width = te[4]
|
||||||
self.ctx.move_to(int(x - width - x_bearing - 2), int(y + (ascent - descent) / 2.0))
|
self.ctx.move_to(int(x - width - x_bearing - 2), int(y + (ascent - descent) / 2))
|
||||||
self.ctx.set_source_rgba(*self.black)
|
self.ctx.set_source_rgba(*self.black)
|
||||||
self.ctx.show_text(text)
|
self.ctx.show_text(text)
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
@ -52,7 +54,7 @@ def neat_time(column, cell, model, data):
|
|||||||
"""Render seconds as seconds or minutes with label"""
|
"""Render seconds as seconds or minutes with label"""
|
||||||
seconds = model.get_value(data, 0)
|
seconds = model.get_value(data, 0)
|
||||||
if seconds > 60:
|
if seconds > 60:
|
||||||
text = "%d %s" % (seconds / 60, _("minutes"))
|
text = "%d %s" % (seconds // 60, _("minutes"))
|
||||||
elif seconds == 60:
|
elif seconds == 60:
|
||||||
text = _("1 minute")
|
text = _("1 minute")
|
||||||
elif seconds == 1:
|
elif seconds == 1:
|
||||||
@ -69,11 +71,10 @@ def int_str(number):
|
|||||||
|
|
||||||
def gtk_to_graph_color(color):
|
def gtk_to_graph_color(color):
|
||||||
"""Turns a gtk.gdk.Color into a tuple with range 0-1 as used by the graph"""
|
"""Turns a gtk.gdk.Color into a tuple with range 0-1 as used by the graph"""
|
||||||
max_val = float(65535)
|
|
||||||
gtk_color = gtk.gdk.Color(color)
|
gtk_color = gtk.gdk.Color(color)
|
||||||
red = gtk_color.red / max_val
|
red = gtk_color.red / 65535
|
||||||
green = gtk_color.green / max_val
|
green = gtk_color.green / 65535
|
||||||
blue = gtk_color.blue / max_val
|
blue = gtk_color.blue / 65535
|
||||||
return (red, green, blue)
|
return (red, green, blue)
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,6 +44,8 @@ Example icon to test with `down.ico`_
|
|||||||
.. _down.ico: http://www.axialis.com/tutorials/iw/down.ico
|
.. _down.ico: http://www.axialis.com/tutorials/iw/down.ico
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
@ -132,7 +134,7 @@ class Win32IcoFile(object):
|
|||||||
log.debug("Loaded image: %s %s %s %s", im.format, im.mode, im.size, im.info)
|
log.debug("Loaded image: %s %s %s %s", im.format, im.mode, im.size, im.info)
|
||||||
|
|
||||||
# change tile dimension to only encompass XOR image
|
# change tile dimension to only encompass XOR image
|
||||||
im.size = im.size[0], im.size[1] / 2
|
im.size = im.size[0], im.size[1] // 2
|
||||||
d, e, o, a = im.tile[0]
|
d, e, o, a = im.tile[0]
|
||||||
im.tile[0] = d, (0, 0) + im.size, o, a
|
im.tile[0] = d, (0, 0) + im.size, o, a
|
||||||
|
|
||||||
@ -145,7 +147,7 @@ class Win32IcoFile(object):
|
|||||||
break
|
break
|
||||||
# end for
|
# end for
|
||||||
log.debug("o:%s, w:%s, h:%s, bpp:%s", o, im.size[0], im.size[1], bpp)
|
log.debug("o:%s, w:%s, h:%s, bpp:%s", o, im.size[0], im.size[1], bpp)
|
||||||
and_mask_offset = o + (im.size[0] * im.size[1] * (bpp / 8.0))
|
and_mask_offset = o + (im.size[0] * im.size[1] * (bpp / 8))
|
||||||
|
|
||||||
if bpp == 32:
|
if bpp == 32:
|
||||||
# 32-bit color depth icon image allows semitransparent areas
|
# 32-bit color depth icon image allows semitransparent areas
|
||||||
@ -178,7 +180,7 @@ class Win32IcoFile(object):
|
|||||||
# bitmap row data is aligned to word boundaries
|
# bitmap row data is aligned to word boundaries
|
||||||
w += 32 - (im.size[0] % 32)
|
w += 32 - (im.size[0] % 32)
|
||||||
# the total mask data is padded row size * height / bits per char
|
# the total mask data is padded row size * height / bits per char
|
||||||
total_bytes = int((w * im.size[1]) / 8)
|
total_bytes = (w * im.size[1]) // 8
|
||||||
log.debug("tot=%d, off=%d, w=%d, size=%d", len(data), and_mask_offset, w, total_bytes)
|
log.debug("tot=%d, off=%d, w=%d, size=%d", len(data), and_mask_offset, w, total_bytes)
|
||||||
|
|
||||||
self.buf.seek(and_mask_offset)
|
self.buf.seek(and_mask_offset)
|
||||||
@ -190,7 +192,7 @@ class Win32IcoFile(object):
|
|||||||
im.size, # (w, h)
|
im.size, # (w, h)
|
||||||
mask_data, # source chars
|
mask_data, # source chars
|
||||||
'raw', # raw decoder
|
'raw', # raw decoder
|
||||||
('1;I', int(w / 8), -1) # 1bpp inverted, padded, reversed
|
('1;I', w // 8, -1) # 1bpp inverted, padded, reversed
|
||||||
)
|
)
|
||||||
|
|
||||||
# now we have two images, im is XOR image and mask is AND image
|
# now we have two images, im is XOR image and mask is AND image
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
from os.path import sep as dirsep
|
from os.path import sep as dirsep
|
||||||
|
|
||||||
import deluge.common as common
|
import deluge.common as common
|
||||||
@ -363,7 +365,7 @@ class Command(BaseCommand):
|
|||||||
s += " {!cyan!}%s" % torrent_id
|
s += " {!cyan!}%s" % torrent_id
|
||||||
else:
|
else:
|
||||||
# Shorten the ID
|
# Shorten the ID
|
||||||
a = int(space_left * 2 / 3.0)
|
a = space_left * 2 // 3
|
||||||
b = space_left - a
|
b = space_left - a
|
||||||
if a < 8:
|
if a < 8:
|
||||||
b = b - (8 - a)
|
b = b - (8 - a)
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
@ -390,14 +392,14 @@ class AllTorrents(BaseMode, component.Component):
|
|||||||
self.column_widths = [self.config["%s_width" % c] for c in self.__cols_to_show]
|
self.column_widths = [self.config["%s_width" % c] for c in self.__cols_to_show]
|
||||||
requested_width = sum([width for width in self.column_widths if width >= 0])
|
requested_width = sum([width for width in self.column_widths if width >= 0])
|
||||||
if requested_width > self.cols: # can't satisfy requests, just spread out evenly
|
if requested_width > self.cols: # can't satisfy requests, just spread out evenly
|
||||||
cw = int(self.cols / len(self.__columns))
|
cw = self.cols // len(self.__columns)
|
||||||
for i in range(0, len(self.column_widths)):
|
for i in range(0, len(self.column_widths)):
|
||||||
self.column_widths[i] = cw
|
self.column_widths[i] = cw
|
||||||
else:
|
else:
|
||||||
rem = self.cols - requested_width
|
rem = self.cols - requested_width
|
||||||
var_cols = len([width for width in self.column_widths if width < 0])
|
var_cols = len([width for width in self.column_widths if width < 0])
|
||||||
if var_cols > 0:
|
if var_cols > 0:
|
||||||
vw = int(rem / var_cols)
|
vw = rem // var_cols
|
||||||
for i in range(0, len(self.column_widths)):
|
for i in range(0, len(self.column_widths)):
|
||||||
if self.column_widths[i] < 0:
|
if self.column_widths[i] < 0:
|
||||||
self.column_widths[i] = vw
|
self.column_widths[i] = vw
|
||||||
@ -1173,14 +1175,14 @@ class AllTorrents(BaseMode, component.Component):
|
|||||||
if not self._scroll_up(1):
|
if not self._scroll_up(1):
|
||||||
effected_lines = [self.cursel - 1, self.cursel]
|
effected_lines = [self.cursel - 1, self.cursel]
|
||||||
elif c == curses.KEY_PPAGE:
|
elif c == curses.KEY_PPAGE:
|
||||||
self._scroll_up(int(self.rows / 2))
|
self._scroll_up(self.rows // 2)
|
||||||
elif c == curses.KEY_DOWN:
|
elif c == curses.KEY_DOWN:
|
||||||
if self.cursel >= self.numtorrents:
|
if self.cursel >= self.numtorrents:
|
||||||
return
|
return
|
||||||
if not self._scroll_down(1):
|
if not self._scroll_down(1):
|
||||||
effected_lines = [self.cursel - 2, self.cursel - 1]
|
effected_lines = [self.cursel - 2, self.cursel - 1]
|
||||||
elif c == curses.KEY_NPAGE:
|
elif c == curses.KEY_NPAGE:
|
||||||
self._scroll_down(int(self.rows / 2))
|
self._scroll_down(self.rows // 2)
|
||||||
elif c == curses.KEY_HOME:
|
elif c == curses.KEY_HOME:
|
||||||
self._scroll_up(self.cursel)
|
self._scroll_up(self.cursel)
|
||||||
elif c == curses.KEY_END:
|
elif c == curses.KEY_END:
|
||||||
|
@ -9,10 +9,7 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
try:
|
from __future__ import division
|
||||||
import curses
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -21,6 +18,12 @@ import os.path
|
|||||||
from deluge.ui.console import colors
|
from deluge.ui.console import colors
|
||||||
from deluge.ui.console.modes.popup import ALIGN, Popup
|
from deluge.ui.console.modes.popup import ALIGN, Popup
|
||||||
|
|
||||||
|
try:
|
||||||
|
import curses
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -877,7 +880,7 @@ class InputPopup(Popup):
|
|||||||
|
|
||||||
if self.content_height > (self.height - 2):
|
if self.content_height > (self.height - 2):
|
||||||
lts = self.content_height - (self.height - 3)
|
lts = self.content_height - (self.height - 3)
|
||||||
perc_sc = float(self.lineoff) / lts
|
perc_sc = self.lineoff / lts
|
||||||
sb_pos = int((self.height - 2) * perc_sc) + 1
|
sb_pos = int((self.height - 2) * perc_sc) + 1
|
||||||
if (sb_pos == 1) and (self.lineoff != 0):
|
if (sb_pos == 1) and (self.lineoff != 0):
|
||||||
sb_pos += 1
|
sb_pos += 1
|
||||||
|
@ -7,14 +7,17 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from deluge.ui.console.modes import format_utils
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import curses
|
import curses
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from deluge.ui.console.modes import format_utils
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -97,7 +100,7 @@ class Popup(object):
|
|||||||
|
|
||||||
# Height
|
# Height
|
||||||
if hr == 0:
|
if hr == 0:
|
||||||
hr = int(self.parent.rows / 2)
|
hr = self.parent.rows // 2
|
||||||
elif hr == -1:
|
elif hr == -1:
|
||||||
hr = self.parent.rows - 2
|
hr = self.parent.rows - 2
|
||||||
elif hr > self.parent.rows - 2:
|
elif hr > self.parent.rows - 2:
|
||||||
@ -105,7 +108,7 @@ class Popup(object):
|
|||||||
|
|
||||||
# Width
|
# Width
|
||||||
if wr == 0:
|
if wr == 0:
|
||||||
wr = int(self.parent.cols / 2)
|
wr = self.parent.cols // 2
|
||||||
elif wr == -1:
|
elif wr == -1:
|
||||||
wr = self.parent.cols
|
wr = self.parent.cols
|
||||||
elif wr >= self.parent.cols:
|
elif wr >= self.parent.cols:
|
||||||
@ -114,14 +117,14 @@ class Popup(object):
|
|||||||
if self.align in [ALIGN.TOP_CENTER, ALIGN.TOP_LEFT, ALIGN.TOP_RIGHT]:
|
if self.align in [ALIGN.TOP_CENTER, ALIGN.TOP_LEFT, ALIGN.TOP_RIGHT]:
|
||||||
by = 1
|
by = 1
|
||||||
elif self.align in [ALIGN.MIDDLE_CENTER, ALIGN.MIDDLE_LEFT, ALIGN.MIDDLE_RIGHT]:
|
elif self.align in [ALIGN.MIDDLE_CENTER, ALIGN.MIDDLE_LEFT, ALIGN.MIDDLE_RIGHT]:
|
||||||
by = (self.parent.rows / 2) - (hr / 2)
|
by = (self.parent.rows // 2) - (hr // 2)
|
||||||
elif self.align in [ALIGN.BOTTOM_CENTER, ALIGN.BOTTOM_LEFT, ALIGN.BOTTOM_RIGHT]:
|
elif self.align in [ALIGN.BOTTOM_CENTER, ALIGN.BOTTOM_LEFT, ALIGN.BOTTOM_RIGHT]:
|
||||||
by = self.parent.rows - hr - 1
|
by = self.parent.rows - hr - 1
|
||||||
|
|
||||||
if self.align in [ALIGN.TOP_LEFT, ALIGN.MIDDLE_LEFT, ALIGN.BOTTOM_LEFT]:
|
if self.align in [ALIGN.TOP_LEFT, ALIGN.MIDDLE_LEFT, ALIGN.BOTTOM_LEFT]:
|
||||||
bx = 0
|
bx = 0
|
||||||
elif self.align in [ALIGN.TOP_CENTER, ALIGN.MIDDLE_CENTER, ALIGN.BOTTOM_CENTER]:
|
elif self.align in [ALIGN.TOP_CENTER, ALIGN.MIDDLE_CENTER, ALIGN.BOTTOM_CENTER]:
|
||||||
bx = (self.parent.cols / 2) - (wr / 2)
|
bx = (self.parent.cols // 2) - (wr // 2)
|
||||||
elif self.align in [ALIGN.TOP_RIGHT, ALIGN.MIDDLE_RIGHT, ALIGN.BOTTOM_RIGHT]:
|
elif self.align in [ALIGN.TOP_RIGHT, ALIGN.MIDDLE_RIGHT, ALIGN.BOTTOM_RIGHT]:
|
||||||
bx = self.parent.cols - wr - 1
|
bx = self.parent.cols - wr - 1
|
||||||
|
|
||||||
@ -139,7 +142,7 @@ class Popup(object):
|
|||||||
self._refresh_lines()
|
self._refresh_lines()
|
||||||
if len(self._lines) > (self.height - 2):
|
if len(self._lines) > (self.height - 2):
|
||||||
lts = len(self._lines) - (self.height - 3)
|
lts = len(self._lines) - (self.height - 3)
|
||||||
perc_sc = float(self.lineoff) / lts
|
perc_sc = self.lineoff / lts
|
||||||
sb_pos = int((self.height - 2) * perc_sc) + 1
|
sb_pos = int((self.height - 2) * perc_sc) + 1
|
||||||
if (sb_pos == 1) and (self.lineoff != 0):
|
if (sb_pos == 1) and (self.lineoff != 0):
|
||||||
sb_pos += 1
|
sb_pos += 1
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
@ -205,7 +207,7 @@ class TorrentDetail(BaseMode, component.Component):
|
|||||||
for f in fs:
|
for f in fs:
|
||||||
if f[3]: # dir, has some children
|
if f[3]: # dir, has some children
|
||||||
bd = self.__fill_progress(f[3], progs)
|
bd = self.__fill_progress(f[3], progs)
|
||||||
f[5] = format_utils.format_progress((bd / f[2]) * 100)
|
f[5] = format_utils.format_progress(bd / f[2] * 100)
|
||||||
else: # file, update own prog and add to total
|
else: # file, update own prog and add to total
|
||||||
bd = f[2] * progs[f[1]]
|
bd = f[2] * progs[f[1]]
|
||||||
f[5] = format_utils.format_progress(progs[f[1]] * 100)
|
f[5] = format_utils.format_progress(progs[f[1]] * 100)
|
||||||
@ -226,13 +228,13 @@ class TorrentDetail(BaseMode, component.Component):
|
|||||||
self.column_widths = [-1, 15, 15, 20]
|
self.column_widths = [-1, 15, 15, 20]
|
||||||
req = sum([col_width for col_width in self.column_widths if col_width >= 0])
|
req = sum([col_width for col_width in self.column_widths if col_width >= 0])
|
||||||
if req > self.cols: # can't satisfy requests, just spread out evenly
|
if req > self.cols: # can't satisfy requests, just spread out evenly
|
||||||
cw = int(self.cols / len(self.column_names))
|
cw = self.cols // len(self.column_names)
|
||||||
for i in range(0, len(self.column_widths)):
|
for i in range(0, len(self.column_widths)):
|
||||||
self.column_widths[i] = cw
|
self.column_widths[i] = cw
|
||||||
else:
|
else:
|
||||||
rem = self.cols - req
|
rem = self.cols - req
|
||||||
var_cols = len([col_width for col_width in self.column_widths if col_width < 0])
|
var_cols = len([col_width for col_width in self.column_widths if col_width < 0])
|
||||||
vw = int(rem / var_cols)
|
vw = rem // var_cols
|
||||||
for i in range(0, len(self.column_widths)):
|
for i in range(0, len(self.column_widths)):
|
||||||
if self.column_widths[i] < 0:
|
if self.column_widths[i] < 0:
|
||||||
self.column_widths[i] = vw
|
self.column_widths[i] = vw
|
||||||
@ -404,7 +406,7 @@ class TorrentDetail(BaseMode, component.Component):
|
|||||||
if self.popup:
|
if self.popup:
|
||||||
self.popup.handle_resize()
|
self.popup.handle_resize()
|
||||||
|
|
||||||
self._listing_start = self.rows / 2
|
self._listing_start = self.rows // 2
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def render_header(self, off):
|
def render_header(self, off):
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -620,7 +622,7 @@ class AddTorrentDialog(component.Component):
|
|||||||
|
|
||||||
def on_part(data, current_length, total_length):
|
def on_part(data, current_length, total_length):
|
||||||
if total_length:
|
if total_length:
|
||||||
percent = float(current_length) / float(total_length)
|
percent = current_length / total_length
|
||||||
pb.set_fraction(percent)
|
pb.set_fraction(percent)
|
||||||
pb.set_text("%.2f%% (%s / %s)" % (
|
pb.set_text("%.2f%% (%s / %s)" % (
|
||||||
percent * 100,
|
percent * 100,
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import logging
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
@ -124,7 +126,7 @@ class CreateTorrentDialog(object):
|
|||||||
model = self.builder.get_object("combo_piece_size").get_model()
|
model = self.builder.get_object("combo_piece_size").get_model()
|
||||||
for index, value in enumerate(model):
|
for index, value in enumerate(model):
|
||||||
psize = self.parse_piece_size_text(value[0])
|
psize = self.parse_piece_size_text(value[0])
|
||||||
pieces = size / psize
|
pieces = size // psize
|
||||||
if pieces < 2048 or (index + 1) == len(model):
|
if pieces < 2048 or (index + 1) == len(model):
|
||||||
self.builder.get_object("combo_piece_size").set_active(index)
|
self.builder.get_object("combo_piece_size").set_active(index)
|
||||||
break
|
break
|
||||||
@ -376,7 +378,7 @@ class CreateTorrentDialog(object):
|
|||||||
{"download_location": os.path.split(path)[0]})
|
{"download_location": os.path.split(path)[0]})
|
||||||
|
|
||||||
def _on_create_torrent_progress(self, value, num_pieces):
|
def _on_create_torrent_progress(self, value, num_pieces):
|
||||||
percent = float(value) / float(num_pieces)
|
percent = value / num_pieces
|
||||||
|
|
||||||
def update_pbar_with_gobject(percent):
|
def update_pbar_with_gobject(percent):
|
||||||
pbar = self.builder.get_object("progressbar")
|
pbar = self.builder.get_object("progressbar")
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import cPickle
|
import cPickle
|
||||||
import logging
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
@ -423,12 +425,12 @@ class FilesTab(Tab):
|
|||||||
if self.treestore.iter_children(row):
|
if self.treestore.iter_children(row):
|
||||||
completed_bytes += get_completed_bytes(self.treestore.iter_children(row))
|
completed_bytes += get_completed_bytes(self.treestore.iter_children(row))
|
||||||
else:
|
else:
|
||||||
completed_bytes += self.treestore[row][1] * (float(self.treestore[row][3]) / 100.0)
|
completed_bytes += self.treestore[row][1] * self.treestore[row][3] / 100
|
||||||
|
|
||||||
row = self.treestore.iter_next(row)
|
row = self.treestore.iter_next(row)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
value = (float(completed_bytes) / float(self.treestore[parent][1])) * 100
|
value = completed_bytes / self.treestore[parent][1] * 100
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
# Catch the unusal error found when moving folders around
|
# Catch the unusal error found when moving folders around
|
||||||
value = 0
|
value = 0
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import division, print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -596,7 +596,7 @@ class PathChooserPopup(object):
|
|||||||
# Adjust height according to number of list items
|
# Adjust height according to number of list items
|
||||||
if len(self.tree_store) > 0 and self.max_visible_rows > 0:
|
if len(self.tree_store) > 0 and self.max_visible_rows > 0:
|
||||||
# The height for one row in the list
|
# The height for one row in the list
|
||||||
self.row_height = self.treeview.size_request()[1] / len(self.tree_store)
|
self.row_height = self.treeview.size_request()[1] // len(self.tree_store)
|
||||||
# Set height to number of rows
|
# Set height to number of rows
|
||||||
height = len(self.tree_store) * self.row_height + height_extra
|
height = len(self.tree_store) * self.row_height + height_extra
|
||||||
# Adjust the height according to the max number of rows
|
# Adjust the height according to the max number of rows
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from math import pi
|
from math import pi
|
||||||
|
|
||||||
@ -104,9 +106,9 @@ class PiecesBar(gtk.DrawingArea):
|
|||||||
|
|
||||||
def __create_roundcorners_subpath(self, ctx, x, y, width, height):
|
def __create_roundcorners_subpath(self, ctx, x, y, width, height):
|
||||||
aspect = 1.0
|
aspect = 1.0
|
||||||
corner_radius = height / 10.0
|
corner_radius = height / 10
|
||||||
radius = corner_radius / aspect
|
radius = corner_radius / aspect
|
||||||
degrees = pi / 180.0
|
degrees = pi / 180
|
||||||
ctx.new_sub_path()
|
ctx.new_sub_path()
|
||||||
ctx.arc(x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees)
|
ctx.arc(x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees)
|
||||||
ctx.arc(x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees)
|
ctx.arc(x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees)
|
||||||
@ -125,14 +127,14 @@ class PiecesBar(gtk.DrawingArea):
|
|||||||
ctx = cairo.Context(self.__pieces_overlay)
|
ctx = cairo.Context(self.__pieces_overlay)
|
||||||
start_pos = 0
|
start_pos = 0
|
||||||
num_pieces = self.__num_pieces and self.__num_pieces or len(self.__pieces)
|
num_pieces = self.__num_pieces and self.__num_pieces or len(self.__pieces)
|
||||||
piece_width = self.__width * 1.0 / num_pieces
|
piece_width = self.__width * 1 / num_pieces
|
||||||
|
|
||||||
for state in self.__pieces:
|
for state in self.__pieces:
|
||||||
color = self.gtkui_config["pieces_color_%s" % COLOR_STATES[state]]
|
color = self.gtkui_config["pieces_color_%s" % COLOR_STATES[state]]
|
||||||
ctx.set_source_rgb(
|
ctx.set_source_rgb(
|
||||||
color[0] / 65535.0,
|
color[0] / 65535,
|
||||||
color[1] / 65535.0,
|
color[1] / 65535,
|
||||||
color[2] / 65535.0,
|
color[2] / 65535,
|
||||||
)
|
)
|
||||||
ctx.rectangle(start_pos, 0, piece_width, self.__height)
|
ctx.rectangle(start_pos, 0, piece_width, self.__height)
|
||||||
ctx.fill()
|
ctx.fill()
|
||||||
@ -149,15 +151,15 @@ class PiecesBar(gtk.DrawingArea):
|
|||||||
cairo.FORMAT_ARGB32, self.__width, self.__height
|
cairo.FORMAT_ARGB32, self.__width, self.__height
|
||||||
)
|
)
|
||||||
ctx = cairo.Context(self.__pieces_overlay)
|
ctx = cairo.Context(self.__pieces_overlay)
|
||||||
piece_width = self.__width * 1.0 / self.__num_pieces
|
piece_width = self.__width * 1 / self.__num_pieces
|
||||||
start = 0
|
start = 0
|
||||||
for _ in range(self.__num_pieces):
|
for _ in range(self.__num_pieces):
|
||||||
# Like this to keep same aspect ratio
|
# Like this to keep same aspect ratio
|
||||||
color = self.gtkui_config["pieces_color_%s" % COLOR_STATES[3]]
|
color = self.gtkui_config["pieces_color_%s" % COLOR_STATES[3]]
|
||||||
ctx.set_source_rgb(
|
ctx.set_source_rgb(
|
||||||
color[0] / 65535.0,
|
color[0] / 65535,
|
||||||
color[1] / 65535.0,
|
color[1] / 65535,
|
||||||
color[2] / 65535.0,
|
color[2] / 65535,
|
||||||
)
|
)
|
||||||
ctx.rectangle(start, 0, piece_width, self.__height)
|
ctx.rectangle(start, 0, piece_width, self.__height)
|
||||||
ctx.fill()
|
ctx.fill()
|
||||||
@ -214,11 +216,11 @@ class PiecesBar(gtk.DrawingArea):
|
|||||||
log.trace("PiecesBar text %r", text)
|
log.trace("PiecesBar text %r", text)
|
||||||
pl.set_text(text)
|
pl.set_text(text)
|
||||||
plsize = pl.get_size()
|
plsize = pl.get_size()
|
||||||
text_width = plsize[0] / pango.SCALE
|
text_width = plsize[0] // pango.SCALE
|
||||||
text_height = plsize[1] / pango.SCALE
|
text_height = plsize[1] // pango.SCALE
|
||||||
area_width_without_text = self.__width - text_width
|
area_width_without_text = self.__width - text_width
|
||||||
area_height_without_text = self.__height - text_height
|
area_height_without_text = self.__height - text_height
|
||||||
ctx.move_to(area_width_without_text / 2, area_height_without_text / 2)
|
ctx.move_to(area_width_without_text // 2, area_height_without_text // 2)
|
||||||
ctx.set_source_rgb(1.0, 1.0, 1.0)
|
ctx.set_source_rgb(1.0, 1.0, 1.0)
|
||||||
pg.update_layout(pl)
|
pg.update_layout(pl)
|
||||||
pg.show_layout(pl)
|
pg.show_layout(pl)
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
@ -305,8 +307,8 @@ class StatusBar(component.Component):
|
|||||||
def _on_get_session_status(self, status):
|
def _on_get_session_status(self, status):
|
||||||
self.download_rate = fspeed(status["payload_download_rate"], precision=0, shortform=True)
|
self.download_rate = fspeed(status["payload_download_rate"], precision=0, shortform=True)
|
||||||
self.upload_rate = fspeed(status["payload_upload_rate"], precision=0, shortform=True)
|
self.upload_rate = fspeed(status["payload_upload_rate"], precision=0, shortform=True)
|
||||||
self.download_protocol_rate = (status["download_rate"] - status["payload_download_rate"]) / 1024
|
self.download_protocol_rate = (status["download_rate"] - status["payload_download_rate"]) // 1024
|
||||||
self.upload_protocol_rate = (status["upload_rate"] - status["payload_upload_rate"]) / 1024
|
self.upload_protocol_rate = (status["upload_rate"] - status["payload_upload_rate"]) // 1024
|
||||||
self.num_connections = status["num_peers"]
|
self.num_connections = status["num_peers"]
|
||||||
self.update_download_label()
|
self.update_download_label()
|
||||||
self.update_upload_label()
|
self.update_upload_label()
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
@ -590,8 +592,8 @@ class WebApi(JSONComponent):
|
|||||||
dirinfo["priority"] = 9
|
dirinfo["priority"] = 9
|
||||||
|
|
||||||
progresses = dirinfo.setdefault("progresses", [])
|
progresses = dirinfo.setdefault("progresses", [])
|
||||||
progresses.append(torrent_file["size"] * (torrent_file["progress"] / 100.0))
|
progresses.append(torrent_file["size"] * torrent_file["progress"] / 100)
|
||||||
dirinfo["progress"] = float(sum(progresses)) / dirinfo["size"] * 100
|
dirinfo["progress"] = sum(progresses) / dirinfo["size"] * 100
|
||||||
dirinfo["path"] = dirname
|
dirinfo["path"] = dirname
|
||||||
dirname = os.path.dirname(dirname)
|
dirname = os.path.dirname(dirname)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user