46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Script to demonstrate how to execute the book_session method from crossfit_booker.py
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import logging
|
|
from crossfit_booker import CrossFitBooker
|
|
|
|
# Configure logging
|
|
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
|
|
|
def main():
|
|
# Check if a session ID was provided as an argument
|
|
if len(sys.argv) < 2:
|
|
print("Usage: python execute_book_session.py <session_id>")
|
|
sys.exit(1)
|
|
|
|
session_id = sys.argv[1]
|
|
|
|
# Create an instance of CrossFitBooker
|
|
booker = CrossFitBooker()
|
|
|
|
# Login to authenticate
|
|
print("Attempting to authenticate...")
|
|
if not booker.login():
|
|
print("Failed to authenticate. Please check your credentials and try again.")
|
|
sys.exit(1)
|
|
print("Authentication successful!")
|
|
|
|
# Book the session
|
|
print(f"Attempting to book session with ID: {session_id}")
|
|
success = booker.book_session(session_id)
|
|
|
|
if success:
|
|
print(f"Successfully booked session {session_id}")
|
|
else:
|
|
print(f"Failed to book session {session_id}")
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
main()
|
|
except Exception as e:
|
|
print(f"An error occurred: {e}")
|
|
sys.exit(1) |