From 940075e21ef39978ec21587a80f64998f8f49020 Mon Sep 17 00:00:00 2001 From: garland Date: Sun, 18 Aug 2024 11:45:46 -0700 Subject: [PATCH 1/3] nexus7 --- .../nexus-trusted-traveler-scheduler-1.yml | 2 +- .../src/notifcation_handler.py | 28 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.github/workflows/nexus-trusted-traveler-scheduler-1.yml b/.github/workflows/nexus-trusted-traveler-scheduler-1.yml index 8e126b0a..b2c87647 100644 --- a/.github/workflows/nexus-trusted-traveler-scheduler-1.yml +++ b/.github/workflows/nexus-trusted-traveler-scheduler-1.yml @@ -6,7 +6,7 @@ name: "nexus 1" on: # Push is for testing only to allow you to test this workflow without # a merge and just a push. -# push: + push: # pull_request: # types: # - closed diff --git a/nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/notifcation_handler.py b/nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/notifcation_handler.py index c7f30f81..a0c358c4 100644 --- a/nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/notifcation_handler.py +++ b/nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/notifcation_handler.py @@ -52,15 +52,25 @@ def send_notification(self, body: str, level: int = 1) -> None: title = "Trusted Traveler Scheduler" - apobj = apprise.Apprise(self.notification_urls) - result = apobj.notify(title=title, body=body, body_format=apprise.NotifyFormat.TEXT) - - # If you encounter Apprise errors, https://github.com/caronc/apprise/wiki/Development_LogCapture - # may be useful. - if result is None: - print('{datetime.today():%Y/%m/%d %H:%M:%S}: error: No notifications sent (configuration error)') - elif result is False: - print('{datetime.today():%Y/%m/%d %H:%M:%S}: error: At least 1 notification failed to send') + pattern = r"Sun|Fri|Sat" + match = re.search(pattern, body) + print("GarDebug: in sending notification") + + if match: + print(f"GarDebug: Sending notification: {body}") + + apobj = apprise.Apprise(self.notification_urls) + result = apobj.notify(title=title, body=body, body_format=apprise.NotifyFormat.TEXT) + + # If you encounter Apprise errors, https://github.com/caronc/apprise/wiki/Development_LogCapture + # may be useful. + if result is None: + print('{datetime.today():%Y/%m/%d %H:%M:%S}: error: No notifications sent (configuration error)') + elif result is False: + print('{datetime.today():%Y/%m/%d %H:%M:%S}: error: At least 1 notification failed to send') + + else: + print(f"GarDebug: Skipping notification: {body}") def new_appointment(self, location_id: int, appointments: List[Schedule]) -> None: """ From a3a2c9016388cbacaed9c1fb7d611555b6bb1d2b Mon Sep 17 00:00:00 2001 From: garland Date: Sun, 18 Aug 2024 11:48:10 -0700 Subject: [PATCH 2/3] nexus7 --- .../trusted-traveler-scheduler/src/notifcation_handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/notifcation_handler.py b/nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/notifcation_handler.py index a0c358c4..fe491773 100644 --- a/nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/notifcation_handler.py +++ b/nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/notifcation_handler.py @@ -1,5 +1,6 @@ from __future__ import annotations from datetime import datetime +import re from typing import TYPE_CHECKING, List From fef25735724265f6f780f268e9e9ec36aa6a9eb5 Mon Sep 17 00:00:00 2001 From: garland Date: Sun, 18 Aug 2024 13:12:06 -0700 Subject: [PATCH 3/3] nexus7 --- .github/workflows/nexus-trusted-traveler-scheduler-1.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nexus-trusted-traveler-scheduler-1.yml b/.github/workflows/nexus-trusted-traveler-scheduler-1.yml index b2c87647..78efbf27 100644 --- a/.github/workflows/nexus-trusted-traveler-scheduler-1.yml +++ b/.github/workflows/nexus-trusted-traveler-scheduler-1.yml @@ -6,7 +6,7 @@ name: "nexus 1" on: # Push is for testing only to allow you to test this workflow without # a merge and just a push. - push: +# push: # pull_request: # types: # - closed @@ -23,12 +23,12 @@ on: ## │ │ │ │ │ ## │ │ │ │ │ ## * * * * * -# schedule: + schedule: # ## Testing run every 5 minutes # - cron: '*/5 * * * *' ## Run every 5 hours on minute 37 - # - cron: '37 */5 * * *' + - cron: '37 */5 * * *' env: SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN_NEXUS }} # Sends to the nexus channel. In the format of: slack://xxx/xxx/xxx