From f964c9bd8939fbe4936b80c8a99ba803386838f8 Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Sun, 3 Dec 2023 21:42:07 +0100 Subject: [PATCH] wip --- rpmbuild/bin/copr-builder | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/rpmbuild/bin/copr-builder b/rpmbuild/bin/copr-builder index 380de27d8..4d0aa984f 100755 --- a/rpmbuild/bin/copr-builder +++ b/rpmbuild/bin/copr-builder @@ -83,21 +83,14 @@ class CMDShow: return pid return None - @property - def uptime_seconds(self): - with open("/proc/uptime", "r") as f: - return float(f.readline().split()[0]) - @property def expiration(self): - # TODO We are implementing the same thing on backend, move it to common try: with open(EXPIRATION_PATH, "r") as fp: timestamp = float(fp.read()) return datetime.fromtimestamp(timestamp) except (OSError, ValueError): - boot = datetime.now() - timedelta(seconds=self.uptime_seconds) - return boot + timedelta(seconds=DEFAULT_EXPIRATION) + return None @property @@ -105,10 +98,12 @@ class CMDShow: """ Human friendly representation of remaining time for the VM """ - # TODO We are implementing the same thing on backend, move it to common + if not self.expiration: + return "unknown" + delta = self.expiration - datetime.now() if delta.total_seconds() < 0: - return "Expired" + return "expired" days, hours, minutes, seconds = timedelta_to_dhms(delta) return ("{0} days, {1} hours, {2} minutes, {3} seconds"