From 0c11a1971e9e48fef84d7e40e3d50f643c47c95e Mon Sep 17 00:00:00 2001 From: moiSentineL Date: Sun, 11 Aug 2024 14:56:06 +0530 Subject: [PATCH 1/3] create outfile to write progress --- flomo/ui.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flomo/ui.py b/flomo/ui.py index d45f587..7708282 100644 --- a/flomo/ui.py +++ b/flomo/ui.py @@ -31,6 +31,7 @@ def __init__( f"bold {self.tag_color}" if self.status == 0 else "bold red" ) + self.out = helpers.get_path("bruh", in_data=True) self.terminal = blessed.Terminal() @@ -58,10 +59,14 @@ def show_live_panel(self): time.sleep(1) if self.status == 0: self.stopwatch += 1 + with open(self.out, "w") as f: + f.write(f"{helpers.format_time(self.stopwatch)} - flowing") elif self.status == 1 and self.chilling_time: if not (self.chilling_time > 1): break self.chilling_time -= 1 + with open(self.out, "w") as f: + f.write(f"{helpers.format_time(self.chilling_time)} - chillin") _live.update(self.generate_panel()) def get_input(self): From 417606e68daa64327485e8f2f48e6823cbe4ecd0 Mon Sep 17 00:00:00 2001 From: moiSentineL Date: Sun, 11 Aug 2024 15:01:39 +0530 Subject: [PATCH 2/3] del file --- flomo/ui.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flomo/ui.py b/flomo/ui.py index 7708282..54523d5 100644 --- a/flomo/ui.py +++ b/flomo/ui.py @@ -1,6 +1,7 @@ import datetime import threading import time +import os import blessed from rich.align import Align @@ -133,3 +134,4 @@ def main(tag: str, name: str, session_id: str): # chilling_panel_thread.join() finally: tracker.end_session(session_id) + os.remove(UI("","","").out) From 0d265d74de08a0d015e1b0faa1a98e23c4367fc3 Mon Sep 17 00:00:00 2001 From: moiSentineL Date: Tue, 12 Nov 2024 13:43:33 +0530 Subject: [PATCH 3/3] add helper function --- flomo/helpers.py | 10 +++++++++- flomo/ui.py | 9 ++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/flomo/helpers.py b/flomo/helpers.py index b5738dd..72315f7 100644 --- a/flomo/helpers.py +++ b/flomo/helpers.py @@ -89,4 +89,12 @@ def tag_color(tag: str) -> str: for k, v in config.Config().get_config(config.TAG_COLORS).items() } - return tag_colors.get(tag, "blue") \ No newline at end of file + return tag_colors.get(tag, "blue") + +def outfile(status: str, file: str, time: int) -> str: + + with open(file, "w") as f: + f.write(f"{format_time(time)} - {status}") + +if __name__ == "__main__": + outfile(1, "tst", 22) diff --git a/flomo/ui.py b/flomo/ui.py index 54523d5..9ace80b 100644 --- a/flomo/ui.py +++ b/flomo/ui.py @@ -32,7 +32,7 @@ def __init__( f"bold {self.tag_color}" if self.status == 0 else "bold red" ) - self.out = helpers.get_path("bruh", in_data=True) + self.out = helpers.get_path("outfile", in_data=True) self.terminal = blessed.Terminal() @@ -60,14 +60,13 @@ def show_live_panel(self): time.sleep(1) if self.status == 0: self.stopwatch += 1 - with open(self.out, "w") as f: - f.write(f"{helpers.format_time(self.stopwatch)} - flowing") + helpers.outfile("flowing", self.out, self.stopwatch) elif self.status == 1 and self.chilling_time: if not (self.chilling_time > 1): break self.chilling_time -= 1 - with open(self.out, "w") as f: - f.write(f"{helpers.format_time(self.chilling_time)} - chillin") + helpers.outfile("chillin", self.out, self.chilling_time) + _live.update(self.generate_panel()) def get_input(self):