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:
@@ -4,4 +4,7 @@ plugins:
|
|||||||
enabled: true
|
enabled: true
|
||||||
checks:
|
checks:
|
||||||
E501:
|
E501:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
argument-count:
|
||||||
|
config:
|
||||||
|
threshold: 5
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ def schedule_checkin(flight_time, reservation):
|
|||||||
print("{} got {}{}!".format(doc['name'], doc['boardingGroup'], doc['boardingPosition']))
|
print("{} got {}{}!".format(doc['name'], doc['boardingGroup'], doc['boardingPosition']))
|
||||||
|
|
||||||
|
|
||||||
def auto_checkin(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)
|
r = Reservation(reservation_number, first_name, last_name, notify, verbose)
|
||||||
body = r.lookup_existing_reservation()
|
body = r.lookup_existing_reservation()
|
||||||
|
|
||||||
# Get our local current time
|
# Get our local current time
|
||||||
@@ -89,12 +89,13 @@ def auto_checkin(reservation_number, first_name, last_name, notify=[]):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
arguments = docopt(__doc__, version='Southwest Checkin 1')
|
arguments = docopt(__doc__, version='Southwest Checkin 2')
|
||||||
reservation_number = arguments['CONFIRMATION_NUMBER']
|
reservation_number = arguments['CONFIRMATION_NUMBER']
|
||||||
first_name = arguments['FIRST_NAME']
|
first_name = arguments['FIRST_NAME']
|
||||||
last_name = arguments['LAST_NAME']
|
last_name = arguments['LAST_NAME']
|
||||||
email = arguments['--email']
|
email = arguments['--email']
|
||||||
mobile = arguments['--mobile']
|
mobile = arguments['--mobile']
|
||||||
|
verbose = arguments['--verbose']
|
||||||
|
|
||||||
# build out notifications
|
# build out notifications
|
||||||
notifications = []
|
notifications = []
|
||||||
@@ -104,7 +105,7 @@ if __name__ == '__main__':
|
|||||||
notifications.append({'mediaType': 'SMS', 'phoneNumber': mobile})
|
notifications.append({'mediaType': 'SMS', 'phoneNumber': mobile})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
auto_checkin(reservation_number, first_name, last_name, notifications)
|
auto_checkin(reservation_number, first_name, last_name, notifications, verbose)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("Ctrl+C detected, canceling checkin")
|
print("Ctrl+C detected, canceling checkin")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
import requests
|
import requests
|
||||||
|
import json
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@@ -10,11 +11,12 @@ MAX_ATTEMPTS = 40
|
|||||||
|
|
||||||
class Reservation():
|
class Reservation():
|
||||||
|
|
||||||
def __init__(self, number, first, last, notifications=[]):
|
def __init__(self, number, first, last, notifications=[], verbose=False):
|
||||||
self.number = number
|
self.number = number
|
||||||
self.first = first
|
self.first = first
|
||||||
self.last = last
|
self.last = last
|
||||||
self.notifications = notifications
|
self.notifications = notifications
|
||||||
|
self.verbose = verbose
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_headers():
|
def generate_headers():
|
||||||
@@ -45,11 +47,18 @@ class Reservation():
|
|||||||
data = r.json()
|
data = r.json()
|
||||||
if 'httpStatusCode' in data and data['httpStatusCode'] in ['NOT_FOUND', 'BAD_REQUEST', 'FORBIDDEN']:
|
if 'httpStatusCode' in data and data['httpStatusCode'] in ['NOT_FOUND', 'BAD_REQUEST', 'FORBIDDEN']:
|
||||||
attempts += 1
|
attempts += 1
|
||||||
print(data['message'])
|
if not self.verbose:
|
||||||
|
print(data['message'])
|
||||||
|
else:
|
||||||
|
print(r.headers)
|
||||||
|
print(json.dumps(data, indent=2))
|
||||||
if attempts > MAX_ATTEMPTS:
|
if attempts > MAX_ATTEMPTS:
|
||||||
sys.exit("Unable to get data, killing self")
|
sys.exit("Unable to get data, killing self")
|
||||||
sleep(CHECKIN_INTERVAL_SECONDS)
|
sleep(CHECKIN_INTERVAL_SECONDS)
|
||||||
continue
|
continue
|
||||||
|
if self.verbose:
|
||||||
|
print(r.headers)
|
||||||
|
print(json.dumps(data, indent=2))
|
||||||
return data
|
return data
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# Ignore responses with no json data in body
|
# Ignore responses with no json data in body
|
||||||
|
|||||||
Reference in New Issue
Block a user