From 0e2de1ead31f7306cb34bf70cc9cc2c1459384f6 Mon Sep 17 00:00:00 2001 From: CompactCow <67137312+CompactCow@users.noreply.github.com> Date: Thu, 24 Feb 2022 14:02:03 -0600 Subject: [PATCH 1/2] Fix uptime calculation The old version was testing impossible conditions, and was also rounding values from "//" which will always be integers. If the numbers are intended to be rounded rather than floored, a single slash should be used. --- AVR_Miner.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/AVR_Miner.py b/AVR_Miner.py index 4515bf96..517a2e48 100644 --- a/AVR_Miner.py +++ b/AVR_Miner.py @@ -959,16 +959,16 @@ def periodic_report(start_time, end_time, shares, def calculate_uptime(start_time): uptime = time() - start_time - if uptime <= 59: - return str(round(uptime)) + get_string('uptime_seconds') - elif uptime == 60: - return str(round(uptime // 60)) + get_string('uptime_minute') - elif uptime >= 60: - return str(round(uptime // 60)) + get_string('uptime_minutes') - elif uptime == 3600: - return str(round(uptime // 3600)) + get_string('uptime_hour') - elif uptime >= 3600: - return str(round(uptime // 3600)) + get_string('uptime_hours') + if uptime >= 7200: # 2 hours, plural + return str(uptime // 3600) + get_string('uptime_hours') + elif uptime >= 3600: # 1 hour, not plural + return str(uptime // 3600) + get_string('uptime_hour') + elif uptime >= 120: # 2 minutes, plural + return str(uptime // 60) + get_string('uptime_minutes') + elif uptime >= 60: # 1 minute, not plural + return str(uptime // 60) + get_string('uptime_minute') + else: # less than 1 minute + return str(round(uptime)) + get_string('uptime_seconds') if __name__ == '__main__': From 201e6021598dba42df2c5f4f991ca787fd41e50d Mon Sep 17 00:00:00 2001 From: CompactCow <67137312+CompactCow@users.noreply.github.com> Date: Thu, 24 Feb 2022 15:00:45 -0600 Subject: [PATCH 2/2] Update PC_Miner.py --- PC_Miner.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/PC_Miner.py b/PC_Miner.py index a089c0c9..c0b339df 100644 --- a/PC_Miner.py +++ b/PC_Miner.py @@ -362,16 +362,16 @@ def calculate_uptime(start_time): Returns seconds, minutes or hours passed since timestamp """ uptime = time() - start_time - if uptime <= 59: - return str(round(uptime)) + get_string("uptime_seconds") - elif uptime == 60: - return str(round(uptime // 60)) + get_string("uptime_minute") - elif uptime >= 60: - return str(round(uptime // 60)) + get_string("uptime_minutes") - elif uptime == 3600: - return str(round(uptime // 3600)) + get_string("uptime_hour") - elif uptime >= 3600: - return str(round(uptime // 3600)) + get_string("uptime_hours") + if uptime >= 7200: # 2 hours, plural + return str(uptime // 3600) + get_string('uptime_hours') + elif uptime >= 3600: # 1 hour, not plural + return str(uptime // 3600) + get_string('uptime_hour') + elif uptime >= 120: # 2 minutes, plural + return str(uptime // 60) + get_string('uptime_minutes') + elif uptime >= 60: # 1 minute, not plural + return str(uptime // 60) + get_string('uptime_minute') + else: # less than 1 minute + return str(round(uptime)) + get_string('uptime_seconds') def pretty_print(msg: str = None,