From a680d6f4c04a1c289b70f9ab6d4416882f6302e6 Mon Sep 17 00:00:00 2001 From: Joseph Pintozzi Date: Sun, 28 Apr 2019 20:01:16 -0700 Subject: [PATCH] Removing dependance on tz_local Allows easier usage inside of Docker containers --- checkin.py | 5 ++--- requirements.txt | 1 - tests/checkin_test.py | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/checkin.py b/checkin.py index 1206444..c1276e7 100755 --- a/checkin.py +++ b/checkin.py @@ -22,7 +22,6 @@ from math import trunc from pytz import utc from southwest import Reservation, openflights from threading import Thread -from tzlocal import get_localzone import sys import time @@ -31,7 +30,7 @@ CHECKIN_EARLY_SECONDS = 5 def schedule_checkin(flight_time, reservation): checkin_time = flight_time - timedelta(days=1) - current_time = datetime.now(utc).astimezone(get_localzone()) + current_time = datetime.utcnow().replace(tzinfo=utc) # check to see if we need to sleep until 24 hours before flight if checkin_time > current_time: # calculate duration to sleep @@ -52,7 +51,7 @@ def auto_checkin(reservation_number, first_name, last_name, notify=[]): body = r.lookup_existing_reservation() # Get our local current time - now = datetime.now(utc).astimezone(get_localzone()) + now = datetime.utcnow().replace(tzinfo=utc) tomorrow = now + timedelta(days=1) threads = [] diff --git a/requirements.txt b/requirements.txt index c227ea4..f286d6c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,6 +9,5 @@ python-dateutil pytz requests requests_mock -tzlocal uuid vcrpy diff --git a/tests/checkin_test.py b/tests/checkin_test.py index 9a09adb..453bb32 100644 --- a/tests/checkin_test.py +++ b/tests/checkin_test.py @@ -5,8 +5,7 @@ import southwest import checkin from datetime import datetime, timedelta from .my_vcr import custom_vcr -from pytz import timezone, utc -from tzlocal import get_localzone +from pytz import timezone my_vcr = custom_vcr() r = southwest.Reservation('XXXXXX', 'John', 'Smith') @@ -19,7 +18,6 @@ def test_generate_headers(): @my_vcr.use_cassette() def test_reservation_lookup(): - print(r.notifications) try: r.lookup_existing_reservation() except Exception: