mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-11 03:55:43 +00:00
estimate time remaining
This commit is contained in:
parent
b4404b9883
commit
effeb72b31
@ -85,6 +85,15 @@ class DelugePreferences:
|
||||
f.flush()
|
||||
f.close()
|
||||
|
||||
def estimate_eta(state):
|
||||
try:
|
||||
return ftime(get_eta(state["total_size"], state["total_download"], state["download_rate"]))
|
||||
except ZeroDivisionError:
|
||||
return "Infinity"
|
||||
|
||||
def get_eta(size, done, rate):
|
||||
return int( (size - done) / rate )
|
||||
|
||||
# Returns formatted string describing filesize
|
||||
# fsize_b should be in bytes
|
||||
# Returned value will be in either KB, MB, or GB
|
||||
@ -111,6 +120,27 @@ def fseed(state):
|
||||
|
||||
def fpeer(state):
|
||||
return str(str(state['num_peers']) + " (" + str(state['total_peers']) + ")")
|
||||
|
||||
def ftime(seconds):
|
||||
if seconds < 60:
|
||||
return '%ds'%(seconds)
|
||||
minutes = int(seconds/60)
|
||||
seconds = seconds % 60
|
||||
if minutes < 60:
|
||||
return '%dm %ds'%(minutes, seconds)
|
||||
hours = int(minutes/60)
|
||||
minutes = minutes % 60
|
||||
if hours < 24:
|
||||
return '%dh %dm'%(hours, minutes)
|
||||
days = int(hours/24)
|
||||
hours = hours % 24
|
||||
if days < 7:
|
||||
return '%dd %dh'%(days, hours)
|
||||
weeks = int(days/7)
|
||||
days = days % 7
|
||||
if weeks < 10:
|
||||
return '%dw %dd'%(weeks, days)
|
||||
return 'unknown'
|
||||
|
||||
|
||||
def get_glade_file(fname):
|
||||
|
@ -347,7 +347,7 @@ class DelugeGTK(dbus.service.Object):
|
||||
peers = dcommon.fpeer(state)
|
||||
dlrate = dcommon.frate(state['download_rate'])
|
||||
ulrate = dcommon.frate(state['upload_rate'])
|
||||
eta = "NULL"
|
||||
eta = dcommon.estimate_eta(state)
|
||||
share = self.calc_share_ratio(unique_id, state)
|
||||
return [unique_id, queue, name, size, progress, message,
|
||||
seeds, peers, dlrate, ulrate, eta, share]
|
||||
@ -402,7 +402,7 @@ class DelugeGTK(dbus.service.Object):
|
||||
self.text_summary_tracker_status.set_text(str(state["tracker_ok"]))
|
||||
self.text_summary_next_announce.set_text(str(state["next_announce"]))
|
||||
#self.text_summary_compact_allocation.set_text(str(state[""]))
|
||||
#self.text_summary_eta.set_text(str(state[""]))
|
||||
self.text_summary_eta.set_text(dcommon.estimate_eta(state))
|
||||
elif tab == 1: #Peers List
|
||||
uid = self.get_selected_torrent()
|
||||
self.peer_store.clear()
|
||||
|
Loading…
x
Reference in New Issue
Block a user