Skip to content

Commit

Permalink
nexus5
Browse files Browse the repository at this point in the history
  • Loading branch information
garland committed Aug 18, 2024
1 parent b5f80e7 commit 6f4d624
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nexus-trusted-traveler-scheduler-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ on:
## * * * * *
schedule:
## Testing run every 5 minutes
# - cron: '*/5 * * * *'
- 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import TYPE_CHECKING, List

import apprise
import re
from .schedule import Schedule

from .notification_level import NotificationLevel
Expand Down Expand Up @@ -53,23 +52,15 @@ def send_notification(self, body: str, level: int = 1) -> None:

title = "Trusted Traveler Scheduler"

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}")
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')

def new_appointment(self, location_id: int, appointments: List[Schedule]) -> None:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ def _get_schedule(self, location_id: int) -> None:
"""
try:
time.sleep(1)
print("getting appointments")
print("getting schedule")
appointments = requests.get(
GOES_URL_FORMAT.format(location_id), timeout=30
).json()
print("got appointments")
print("got schedule")

if not appointments:
print(f"{datetime.today():%Y/%m/%d %H:%M:%S}: No active appointments available for location {location_id}.")
Expand All @@ -164,9 +164,6 @@ def _get_schedule(self, location_id: int) -> None:
schedule = self._evaluate_timestamp(
schedule, location_id, appointment["startTimestamp"]
)

print(f"GarDebug: appointment-startTimestamp: {appointment["startTimestamp"]}")

all_active_appointments.append(datetime.strptime(appointment["startTimestamp"], "%Y-%m-%dT%H:%M").isoformat())

self._clear_database_of_claimed_appointments(location_id, all_active_appointments)
Expand Down

0 comments on commit 6f4d624

Please sign in to comment.