From 5e06dcb98640ac58ad8d5fea9a8a99fd3482db98 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Mon, 12 Aug 2024 15:07:01 -0700 Subject: [PATCH] chg: user: try rounding a Decimal for timer status * revert app icon back to red Signed-off-by: Stephen L Arnold --- scripts/timew-status-indicator | 6 +++++- src/timew_status/utils.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/timew-status-indicator b/scripts/timew-status-indicator index 6ba7e51..32daac5 100755 --- a/scripts/timew-status-indicator +++ b/scripts/timew-status-indicator @@ -10,6 +10,7 @@ import time import typing from collections import Counter from datetime import timedelta +from decimal import Decimal from threading import Thread from typing import cast @@ -210,7 +211,8 @@ class Indicator: def reset_counter(self, source): """Reset the seat_time counter""" - seat_minutes = COUNT["SeatTick"] / 60 + seat_time = COUNT["SeatTick"] / 60 + seat_minutes = round(Decimal(seat_time), 1) COUNT.clear() msg = f'INFO: seat timer reset from {seat_minutes} to 0 min' Notify.Notification.new("Timew status", msg, None).show() @@ -227,6 +229,8 @@ class Indicator: def statusd(self, source): _, svc_msg = run_cmd() + seat_minutes = round(Decimal(COUNT["SeatTick"] / 60), 1) + svc_msg = f'INFO: current seat time is {seat_minutes} mins \n' + svc_msg Notify.Notification.new("Timew status", svc_msg, None).show() def stopd(self, source): diff --git a/src/timew_status/utils.py b/src/timew_status/utils.py index 9f94452..372fd41 100644 --- a/src/timew_status/utils.py +++ b/src/timew_status/utils.py @@ -195,7 +195,7 @@ def run_cmd(action='status', tag=None): print(f'run_cmd {action} return code: {result.returncode}') print(f'run_cmd {action} result msg: {result.stdout.decode().strip()}') - return result, result.stdout.decode().strip() + return result, result.stdout.decode() except Exception as exc: print(f'run_cmd exception: {exc}')