feat(voice_to_text_tray): enhance journal creation with error handling and timestamp formatting
Signed-off-by: Max P. <Mail@MPassarello.de>
This commit is contained in:
@@ -100,9 +100,17 @@ class WhisperWorker(QThread):
|
|||||||
today = datetime.date.today().strftime("%Y.%m.%d")
|
today = datetime.date.today().strftime("%Y.%m.%d")
|
||||||
journal_path = os.path.join(CONFIGURATION["journal_path"], f"{today} - {CURRENT_PRESET['journal_name']}.md")
|
journal_path = os.path.join(CONFIGURATION["journal_path"], f"{today} - {CURRENT_PRESET['journal_name']}.md")
|
||||||
now = datetime.datetime.now().strftime("%H:%M")
|
now = datetime.datetime.now().strftime("%H:%M")
|
||||||
|
if not os.path.exists(journal_path):
|
||||||
|
try:
|
||||||
|
with open(journal_path, "w") as f:
|
||||||
|
f.write(f"# {CURRENT_PRESET['journal_name']} - {today}\n\n")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Journal Erstellungsfehler: {e}")
|
||||||
|
notify("Fehler", "Ein Fehler beim Erstellen des Journals ist aufgetreten!")
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
with open(journal_path, "a") as f:
|
with open(journal_path, "a") as f:
|
||||||
f.write(f"## {now}\n")
|
f.write(f"## {now} Uhr\n")
|
||||||
f.write(f"{formatted_result}\n\n")
|
f.write(f"{formatted_result}\n\n")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Journal Fehler: {e}")
|
print(f"Journal Fehler: {e}")
|
||||||
|
Reference in New Issue
Block a user