job_status: add eta
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import logging
|
||||
|
||||
import datetime
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
@@ -128,7 +128,6 @@ class ScreenPanel:
|
||||
def format_time(seconds):
|
||||
if seconds is None or seconds <= 0:
|
||||
return "-"
|
||||
seconds = int(seconds)
|
||||
days = seconds // 86400
|
||||
seconds %= 86400
|
||||
hours = seconds // 3600
|
||||
@@ -140,6 +139,22 @@ class ScreenPanel:
|
||||
f"{f'{minutes:2.0f}m ' if minutes > 0 else ''}" \
|
||||
f"{f'{seconds:2.0f}s' if days == 0 and hours == 0 and minutes == 0 else ''}"
|
||||
|
||||
def format_eta(self, total, elapsed):
|
||||
if total is None:
|
||||
return "-"
|
||||
seconds = total - elapsed
|
||||
if seconds <= 0:
|
||||
return "-"
|
||||
days = seconds // 86400
|
||||
seconds %= 86400
|
||||
hours = seconds // 3600
|
||||
seconds %= 3600
|
||||
minutes = seconds // 60
|
||||
eta = datetime.datetime.now() + datetime.timedelta(days=days, hours=hours, minutes=minutes)
|
||||
if self._config.get_main_config().getboolean("24htime", True):
|
||||
return f"{self.format_time(total - elapsed)} | {eta:%H:%M} {f' +{days:2.0f}d' if days > 0 else ''}"
|
||||
return f"{self.format_time(total - elapsed)} | {eta:%I:%M %p} {f' +{days:2.0f}d' if days > 0 else ''}"
|
||||
|
||||
@staticmethod
|
||||
def format_size(size):
|
||||
size = float(size)
|
||||
|
Reference in New Issue
Block a user