fix: exit non-zero on Mastodon post failure
The script was swallowing exceptions and exiting 0, so systemd considered the service successful and never triggered OnFailure to notify via Gitea. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
317af2142e
commit
77aa0b3706
@@ -7,6 +7,7 @@ Optionally posts to Mastodon with the --post flag.
|
|||||||
import argparse
|
import argparse
|
||||||
import csv
|
import csv
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
@@ -195,6 +196,8 @@ def main():
|
|||||||
print("No saint's day today (or today is a holiday/feast day).")
|
print("No saint's day today (or today is a holiday/feast day).")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
post_errors = []
|
||||||
|
|
||||||
for saint in saints:
|
for saint in saints:
|
||||||
print(f"Saint: {saint['name']}")
|
print(f"Saint: {saint['name']}")
|
||||||
print(f"French: {saint['french_name']}")
|
print(f"French: {saint['french_name']}")
|
||||||
@@ -216,9 +219,14 @@ def main():
|
|||||||
print(f" Posted! URL: {status['url']}")
|
print(f" Posted! URL: {status['url']}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f" Error posting: {e}")
|
print(f" Error posting: {e}")
|
||||||
|
post_errors.append(str(e))
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
if post_errors:
|
||||||
|
print(f"{len(post_errors)} post(s) failed", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user