Skip to content

Commit

Permalink
[#30] Add ETA in progress list
Browse files Browse the repository at this point in the history
  • Loading branch information
llaumgui committed Jun 22, 2020
1 parent 4830616 commit 700aded
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions seedboxsync/controllers/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#

import os
import datetime
from cement import Controller, fs, ex
from ..core.dao.torrent import Torrent
from ..core.dao.download import Download
Expand Down Expand Up @@ -80,19 +81,22 @@ def list_in_progress(self):
full_path = fs.join(download_path, torrent.get('path') + part_suffix)
try:
local_size = os.stat(full_path).st_size
progress = str(round(100 * (1 - ((torrent.get('seedbox_size') - local_size) / torrent.get('seedbox_size')))))
progress = round(100 * (1 - ((torrent.get('seedbox_size') - local_size) / torrent.get('seedbox_size'))))
eta = str(round(((datetime.datetime.now() - torrent.get('started')).total_seconds() / (progress / 100)) / 60)) + ' mn'
except FileNotFoundError:
self.app.log.warning('File not found "%s"' % full_path)
progress = '0'
progress = 0
eta = "-"

in_progress.append({
'id': torrent.get('id'),
'path': torrent.get('path'),
'started': torrent.get('started'),
'size': torrent.get('size'),
'progress': progress + '%'
'progress': str(progress) + '%',
'eta': eta
})
self.app.render(reversed(in_progress), headers={'id': 'Id', 'started': 'Started', 'path': 'Path', 'progress': 'Progress', 'size': 'Size'})
self.app.render(reversed(in_progress), headers={'id': 'Id', 'started': 'Started', 'path': 'Path', 'progress': 'Progress', 'eta': 'ETA', 'size': 'Size'})

@ex(help='clean the list of files currently in download from seedbox')
def clean_in_progress(self):
Expand Down

0 comments on commit 700aded

Please sign in to comment.