1
0
mirror of https://github.com/pyro2927/SouthwestCheckin.git synced 2025-12-06 01:13:19 +00:00

enable verbose output (#55)

* 	modified:   checkin.py
	modified:   southwest/southwest.py

* 	modified:   .codeclimate.yml

* 	modified:   checkin.py
	modified:   southwest/southwest.py

* 	modified:   southwest.py
This commit is contained in:
bllfr0g
2019-10-27 19:29:14 -07:00
committed by Joseph Pintozzi
parent defb2bdbbc
commit f9572fae19
3 changed files with 20 additions and 7 deletions

View File

@@ -5,3 +5,6 @@ plugins:
checks:
E501:
enabled: false
argument-count:
config:
threshold: 5

View File

@@ -50,8 +50,8 @@ def schedule_checkin(flight_time, reservation):
print("{} got {}{}!".format(doc['name'], doc['boardingGroup'], doc['boardingPosition']))
def auto_checkin(reservation_number, first_name, last_name, notify=[]):
r = Reservation(reservation_number, first_name, last_name, notify)
def auto_checkin(reservation_number, first_name, last_name, notify=[], verbose=False):
r = Reservation(reservation_number, first_name, last_name, notify, verbose)
body = r.lookup_existing_reservation()
# Get our local current time
@@ -89,12 +89,13 @@ def auto_checkin(reservation_number, first_name, last_name, notify=[]):
if __name__ == '__main__':
arguments = docopt(__doc__, version='Southwest Checkin 1')
arguments = docopt(__doc__, version='Southwest Checkin 2')
reservation_number = arguments['CONFIRMATION_NUMBER']
first_name = arguments['FIRST_NAME']
last_name = arguments['LAST_NAME']
email = arguments['--email']
mobile = arguments['--mobile']
verbose = arguments['--verbose']
# build out notifications
notifications = []
@@ -104,7 +105,7 @@ if __name__ == '__main__':
notifications.append({'mediaType': 'SMS', 'phoneNumber': mobile})
try:
auto_checkin(reservation_number, first_name, last_name, notifications)
auto_checkin(reservation_number, first_name, last_name, notifications, verbose)
except KeyboardInterrupt:
print("Ctrl+C detected, canceling checkin")
sys.exit()

View File

@@ -1,5 +1,6 @@
from time import sleep
import requests
import json
import sys
import uuid
@@ -10,11 +11,12 @@ MAX_ATTEMPTS = 40
class Reservation():
def __init__(self, number, first, last, notifications=[]):
def __init__(self, number, first, last, notifications=[], verbose=False):
self.number = number
self.first = first
self.last = last
self.notifications = notifications
self.verbose = verbose
@staticmethod
def generate_headers():
@@ -45,11 +47,18 @@ class Reservation():
data = r.json()
if 'httpStatusCode' in data and data['httpStatusCode'] in ['NOT_FOUND', 'BAD_REQUEST', 'FORBIDDEN']:
attempts += 1
if not self.verbose:
print(data['message'])
else:
print(r.headers)
print(json.dumps(data, indent=2))
if attempts > MAX_ATTEMPTS:
sys.exit("Unable to get data, killing self")
sleep(CHECKIN_INTERVAL_SECONDS)
continue
if self.verbose:
print(r.headers)
print(json.dumps(data, indent=2))
return data
except ValueError:
# Ignore responses with no json data in body