diff --git a/execute_book_session.py b/execute_book_session.py new file mode 100755 index 0000000..6b7c9e0 --- /dev/null +++ b/execute_book_session.py @@ -0,0 +1,46 @@ +#!/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 ") + 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) \ No newline at end of file diff --git a/test_book_session.sh b/test_book_session.sh new file mode 100755 index 0000000..376f7a0 --- /dev/null +++ b/test_book_session.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Test script to demonstrate how to use the execute_book_session.py script + +# Sample session ID (this should be a valid session ID from the crossfit booking system) +SESSION_ID="19291768" + +# Run the script with the sample session ID +echo "Attempting to book session with ID: $SESSION_ID" +python execute_book_session.py $SESSION_ID \ No newline at end of file