36 lines
1.1 KiB
Python
Executable File
36 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import logging
|
|
import traceback
|
|
import asyncio
|
|
from crossfit_booker import CrossFitBooker
|
|
|
|
if __name__ == "__main__":
|
|
# Configure logging once at script startup
|
|
logging.basicConfig(
|
|
level=logging.DEBUG, # Change to DEBUG for more detailed logs
|
|
format='%(asctime)s - %(levelname)s - %(message)s',
|
|
handlers=[
|
|
logging.FileHandler("log/crossfit_booking.log"),
|
|
logging.StreamHandler()
|
|
]
|
|
)
|
|
|
|
# Reduce the verbosity of the requests library's logging
|
|
logging.getLogger("requests").setLevel(logging.WARNING)
|
|
logging.info("Logging enhanced with request library noise reduction")
|
|
|
|
# Create an instance of the CrossFitBooker class
|
|
booker = CrossFitBooker()
|
|
|
|
# Attempt to log in to the CrossFit booking system
|
|
# TODO: Make a authentication during running request to not get kicked out
|
|
if not booker.login():
|
|
# If login fails, log the error and exit the script
|
|
logging.error("Failed to login - Traceback: %s", traceback.format_exc())
|
|
exit(1)
|
|
|
|
# Start the continuous booking loop
|
|
booker.run()
|
|
logging.info("Script completed")
|