diff --git a/app/monitor-planning.py b/app/monitor-planning.py index d9b5843..15d05f5 100644 --- a/app/monitor-planning.py +++ b/app/monitor-planning.py @@ -2,7 +2,6 @@ import os import sys import traceback from datetime import datetime, time -from sqlite3 import Cursor import pause import requests @@ -25,9 +24,9 @@ web_opts.add_argument('--no-sandbox') web_opts.add_argument('--headless') web_opts.add_argument('--disable-dev-shm-usage') -def notify(title, message): +def notify(message): api_url = 'https://hass.jennett-wheeler.co.uk/api/webhook/-Qx6jHsGLHwbBlJpLek5Nj8qS' - requests.post(api_url, json={"title": title, "message": message}) + requests.post(api_url, json={"title": "Monitor Planning", "message": message}) def update_other_applications(): there_were_newly_decided_applications = False @@ -63,11 +62,12 @@ def update_other_applications(): print("") if there_were_newly_decided_applications: - notify("New decisions found", f"Council has uploaded {len(weekly_list.new_applications)} new decisions ({chris_decisions} by Chris)") + notify(f"Council has uploaded {len(weekly_list.new_applications)} new decisions ({chris_decisions} by Chris)") return there_were_newly_decided_applications if __name__ == '__main__': + notify(f"Script Restarted") try: with sqlite3.connect("./database.db") as connection: cursor = connection.cursor() @@ -82,7 +82,7 @@ if __name__ == '__main__': application.scrape_portal(browser, force=True, count_documents=True) if application.new_documents_found: - notify("New Documents Found", f"Application now has {application.num_documents} documents") + notify(f"New Documents Found: Application now has {application.num_documents} documents") print("") if is_working_hours(): @@ -120,7 +120,7 @@ if __name__ == '__main__': except Exception as e: print(f'Error found: {repr(e)}') print(traceback.format_exc()) - notify("Error in planning monitor", repr(e)) + notify(f"Error in planning monitor: {repr(e)}") try: sys.exit(130)