From: will Date: Mon, 20 May 2024 21:32:12 +0000 (+0100) Subject: fixed last transcript detection X-Git-Url: https://git.ozva.co.uk/?a=commitdiff_plain;h=d042a7c84086032c1dbd4441f584b317d896a166;p=spaceweather fixed last transcript detection --- diff --git a/.gitignore b/.gitignore index 41833bf..8a6f8dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/config/last /spaceweather.wav /spaceweather.mp3 /media/graph* diff --git a/config/last b/config/last old mode 100755 new mode 100644 diff --git a/spaceweather.py b/spaceweather.py index ec5f1aa..0053de4 100755 --- a/spaceweather.py +++ b/spaceweather.py @@ -192,15 +192,20 @@ transcript = generate_transcript() text = "\n".join(transcript) # check the last generated transcript -with open("config/last", "r") as f: - last = f.read() - -# quit if the transcript is the same as the last -if last == text: - print("no change!") - quit() -else: - print("proceeding...") +try: + with open("config/last", "r") as f: + last = f.read() + + # quit if the transcript is the same as the last + if last == text: + print("no change!") + quit() + else: + print("New spaceweather issued!") +except FileNotFoundError: + print("no previous spaceweather detected!") + +print("Generating new spaceweather...") # write the raw transcript to a file with open("config/last", "w") as f: f.write(text) diff --git a/testfile b/testfile new file mode 100644 index 0000000..a8d8fd2 --- /dev/null +++ b/testfile @@ -0,0 +1 @@ +testing!